Solved previous part of problem, still need to understand why this isn’t working though 🙂
Reverting back to escaping the strings separately, I have this.
mysql_query("INSERT INTO users (firstname,surname,email,password,birthday,birthmonth,birthyear,houseno,streetname,town,country,postcode,phonenumber,singer,songwriter,producer,composer,band,instrument,instrument2,extra,confirmcode) VALUES ('".$firstname."','".$surname."','".$email."','".$password."',".$birthday.",".$birthmonth.",".$birthyear.",'".$houseno."','".$streetname."','".$town."','".$country."','".$postcode."',".$phonenumber.",".$singer.",".$songwriter.",".$producer.",".$composer.", ".$band.",'".$instrument."','".$instrument2."','".$extra."','".$rand."')",
mysql_real_escape_string($surname),
mysql_real_escape_string($firstname),
mysql_real_escape_string($stown),
mysql_real_escape_string($houseno),
mysql_real_escape_string($streetname),
mysql_real_escape_string($extra),
mysql_real_escape_string($email)) or die ('pood');
echo $streetname;
I’m getting the die error – so it doesn’t echo $streetname; (which should be ‘Clark\’s Way’), and doesn’t seem to backslash apostrophe as it’s not being entered into the database.
Apologies if I haven’t done my research to your standards, but I’ve been trying to understand why this isn’t working for hours.
Thanks 🙂
mysql_query()doesn’t take multiple arguments like that. You need to escape each variable within the string of the query. Like this:So, you’d end up with something like this:
Sorry if there’s a typo in there. But I think you get the idea.
Here’s an (untested) example of how a parameterized query might work, adapted from the examples in the manual: