Ask a question about how to obtain a field from the database-php Tutorial

Source: Internet
Author: User
Ask a question about how to obtain a field from the database on mobile. ask a question about how to obtain a field from the database on mobile = ''.

A program for sending text messages
Obtain a piece of data based on xingming_iD. how can I assign the property of one of the mobile phones to the back of mobile?

Trouble

The source code is as follows:

$ Con = mysql_connect ("localhost", "XXX", "XXXX ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}

Mysql_select_db ("sfsdb", $ con );
$ Xingming_id = $ _ GET ['xingming _ id'];

$ SQL = "select * from sfsdbplayers where xingming_id = '". $ _ GET ['xingming _ id']. "'";
$ Result = mysql_query ($ SQL, $ con );
If ($ row = mysql_fetch_array ($ result )){
}


?>






Header ("Content-Type: text/html; charset = UTF-8 ");


$ Flag = 0;
$ Params = ''; // data to be post
$ Verify = rand (123456,999 999); // Obtain the random verification code

// Enter the following information.
$ Mobile = ''; (how can I assign the field of the obtained mobile phone number here? thank you)
$ Argv = array (
'Name' => 'xxxxxxxxxxxxxxxxxxxxxx', // required parameter. User account
'Pwd' => 'xxxxxxxxxxxxxxxxxxxx', // required parameter. (Web platform: interface password in basic information)
'Content' => 'text message verification code: '. $ verify.'. do not provide the verification code to others. ', // Required parameter. Sending content (1-500 Chinese characters) UTF-8 encoding
'Mobile' => $ mobile, // required parameter. Mobile phone number. Multiple IDs are separated by commas (,).
'Stime' => '', // optional parameter. Sending Time: the time that has been filled in to send the message. if not filled in, the message is sent at the current time.
'Sign' => 'xxxxxx', // required parameter. User signature.
'Type' => 'pt', // required parameter. Fixed pt
'Extno' => ''// optional parameter, extended code, user-defined extended code, can only be a number
);
// Print_r ($ argv); exit;
// Construct the string to post
// Echo $ argv ['content'];
Foreach ($ argv as $ key => $ value ){
If ($ flag! = 0 ){
$ Params. = "&";
$ Flag = 1;
}
$ Params. = $ key. "="; $ params. = urlencode ($ value); // urlencode ($ value );
$ Flag = 1;
}
$ Url = "http://web.duanxinwang.cc/asmx/smsservice.aspx? ". $ Params; // submitted url
$ Con = substr (file_get_contents ($ url), 0, 1); // obtain the status after the message is sent.

If ($ con = '0 '){
Echo "script" alert ('sent successfully! '); Script ";
} Else {
Echo "script" alert ('failed to send! '); History. back (); script ";
}

?>


Reply to discussion (solution)

You have already made it. You can write a method in the model to obtain the mobile phone number, and use this method in ctrl. $ mobel = XXX; // get the model

You have already made it. You can write a method in the model to obtain the mobile phone number, and use this method in ctrl. $ mobel = XXX; // get the model



Can you write it down for me?
I'm not a beginner!
Thank you l

Check whether your $ row is a one-dimensional array or a two-dimensional array.
For a one-dimensional array, $ row ['field'] is $ row [0] ['field'] --- $ row [n] ['field'].

Check whether your $ row is a one-dimensional array or a two-dimensional array.
For a one-dimensional array, $ row ['field'] is $ row [0] ['field'] --- $ row [n] ['field'].



Is a one-dimensional array, the key output must be displayed here

$ Mobile = 'output items must be displayed here ';

You mean $ mobile = '$ row ['shoujihaoma'] ';
This is not correct!
Trouble!


Check whether your $ row is a one-dimensional array or a two-dimensional array.
For a one-dimensional array, $ row ['field'] is $ row [0] ['field'] --- $ row [n] ['field'].



Is a one-dimensional array, the key output must be displayed here

$ Mobile = 'output items must be displayed here ';

You mean $ mobile = '$ row ['shoujihaoma'] ';
This is not correct!
Trouble!



Do not use single quotes...
$ Mobile = $ row ['shoujihaoma '];



Check whether your $ row is a one-dimensional array or a two-dimensional array.
For a one-dimensional array, $ row ['field'] is $ row [0] ['field'] --- $ row [n] ['field'].



Is a one-dimensional array, the key output must be displayed here

$ Mobile = 'output items must be displayed here ';

You mean $ mobile = '$ row ['shoujihaoma'] ';
This is not correct!
Trouble!



Do not use single quotes...
$ Mobile = $ row ['shoujihaoma '];



This method is very helpful.
Awesome
Why remove the single quotes?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.