Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Other » PHP issue
Re: PHP issue [message #439274 is a reply to message #439272] Thu, 11 November 2010 12:37 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
cnc95fan wrote on Thu, 11 November 2010 19:15

mysql_query("INSERT INTO USERS ('id','user','password') VALUES ('$regnum','$_POST['user']','$_POST['pass']')");



You can't use things like $_POST['pass'] directly in a string, you have to either put curly braces around the variables;

mysql_query("INSERT INTO USERS ('id','user','password') VALUES ('{$regnum}','{$_POST['user']}','{$_POST['pass']}')");


Or concatenate them with the string

mysql_query("INSERT INTO USERS ('id','user','password') VALUES ('".$regnum."','".$_POST['user']."','".$_POST['pass']."')");


My personal preference is the second method (concatenation), but it really doesnt matter which you use. The first variable ($regnum) is actually OK without these, but its good practice to follow the same method for all variables as it makes it clear what you were intending to do.




For more information;
http://www.php.net/manual/en/language.types.string.php#language.types.string.par sing


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Thu, 11 November 2010 12:42]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: GameSpy
Next Topic: Generals... AGAIN
Goto Forum:
  


Current Time: Fri Nov 22 19:24:20 MST 2024

Total time taken to generate the page: 0.01079 seconds