开发者

Code not giving output

I have been brainstorming with this piece of code since a very long time but no success.

$name = $_GET['name'];
$email = $_GET['email'];
$question = $_GET['question'];
mysql_connect ("localhost", "root", "") or die ('Error: ' . mysql_error());
mysql_select_db ("contact");
$query ="INSERT INTO contactus (name, email, question) VALUES ('".$name."', '".$email."', '".$question."')";
$done=mysql_query($query); 
echo "Hello $na开发者_JAVA技巧me {$_GET["name"]}";
echo "\nYour query $question {$_GET["question"]}";


Replace quotes around name and question with single quotes:

echo "Hello $name {$_GET['name']}";

echo "\nYour query $question {$_GET['question']}";

Since you already define the string with double quotes, use single quotes to specify a string within your string.


If you use double quotes you can also use the PHP3-esque notation without curly braces:

echo "\nYour query $question $_GET[question]";

Note the lack of quotes around the array key. This syntax is only valid within double quotes, though. In normal PHP context you do need them.


another option:

echo "hello" . $name . "{" .$_GET['name']."}"; ....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜