Jump to content

Recommended Posts

Depends what you want it to do. Syntax wise there are no errors, it probably won't do what you want though.

 

More than likely your looking for....

 

$new_link = "<a href='game.php?title={$_POST['title']}'>{$_POST['title']}</a>";

 

Variables are not interpolated within single quoted strings.

Link to comment
https://forums.phpfreaks.com/topic/84186-correct-variable/#findComment-428591
Share on other sites

Don't use single quotes...using single quotes php won't place the variable's value in it's place.  For example:

 

$var1 = 'abc';
$var2 = 'def';

echo 'var1 is $var1 and var2 is $var2'; //you get "var1 is $var1 and var2 is $var2"
echo "var1 is $var1 and var2 is $var2"; //you get "var1 is abc and var2 is def"

 

And, what thorpe said...( beat me to it )

Link to comment
https://forums.phpfreaks.com/topic/84186-correct-variable/#findComment-428594
Share on other sites

i am getting this error when i clcik submit

 

Error in query: . You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'game.php?title=angry'>angry', 'afsdadsf', 'asdfh', 'gggg', 'gggg', 'ggg', ' at line 2

 

 

this is where the prpoblem is

$title= $_POST["title"];
  $new_link = "<a href='game.php?title={$title}'>{$title}</a>";

 

whats the matter with it.???

Link to comment
https://forums.phpfreaks.com/topic/84186-correct-variable/#findComment-428621
Share on other sites

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\newcreate.php on line 4

 

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\newcreate.php on line 4

 

ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. any ideas?

Link to comment
https://forums.phpfreaks.com/topic/84186-correct-variable/#findComment-428727
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.