Hi Guys,
Would the following code work?
Thanks for your help guys!PHP Code:$query = mysql_escape_string("SELECT FirstName, LastName FROM affiliates WHERE AffID ='$affid'");
| SitePoint Sponsor |


Hi Guys,
Would the following code work?
Thanks for your help guys!PHP Code:$query = mysql_escape_string("SELECT FirstName, LastName FROM affiliates WHERE AffID ='$affid'");

Maybe, but you shouldn't do it like that, but rather
or you could use concatenation, likePHP Code:$query=sprintf('SELECT FirstName, LastName FROM affiliates WHERE AffID="%s"', mysql_real_escape_string($affid));
PHP Code:$query='SELECT FirstName, LastName FROM affiliates WHERE AffID="'.mysql_real_escape_string($affid).'"';
![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy


Thanks ScallioXTX, You've been a big help![]()


Infact i cant get it working, syntax error
Any help would be great please.$query="INSERT INTO data VALUES ('',"'.mysql_real_escape_string($affid).'","'.mysql_real_escape_string($p).'","'.mysql_real_escape_string($title).'","'.mysql_real_escape_string($first).'","'.mysql_real_escape_string($last).'","'.mysql_real_escape_string($email).'","'.mysql_real_escape_string($dob).'",'$ip',"'.mysql_real_escape_string($subid).'",'$datenow','$timenow')";
Thank you.
You've got your single and double quotes mixed up.
String ends at the red mark... so what does PHP try and do with that single quote?Code:$query="INSERT INTO data VALUES ('',"'

Try this:
See how much cleaner that is?PHP Code:$query=sprintf(
'INSERT INTO data VALUES ("", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")',
mysql_real_escape_string($affid),
mysql_real_escape_string($p),
mysql_real_escape_string($title),
mysql_real_escape_string($first),
mysql_real_escape_string($last),
mysql_real_escape_string($email),
mysql_real_escape_string($dob),
$ip
mysql_real_escape_string($subid),
$datenow,
$timenow,
);
![]()
Rémon - Hosting Advisor
Minimal Bookmarks Tree
My Google Chrome extension: browsing bookmarks made easy
incidentally, both datenow and timenow can probably be replaced by MySQL functions.


Big thank you guys for help me out. Keep up the good work guys
Stari ion i cant as the server is based in the USA and i need it to log UK times/dates that why i have done that![]()
Bookmarks