HTML/CSS/JS/ASP/PHP/SQL help/coding thread.

I saw that nobody had done this except for the programming thread (which was centered at programs not websites) so I decided that this would prove as a useful thread for some. So this is a thread where you can post all website coding related discussions and “help needed” etc.

EDIT: Huge thanks to Flatline and Hyperbyte for helping me out.

Try changing the double quotes in your POST variables to single quotes as the double quotes are not being escaped and probably causing problems. It’s been a while since I did PHP so I could be wrong.


$con = mysql_connect($mysql_host, $mysql_user, $mysql_password);
if (!$con)
  die('Could not connect: ' . mysql_error());

$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$age = mysql_real_escape_string($_POST['age']);

mysql_select_db($mysql_database, $con);
mysql_query("INSERT INTO Persons (fname, lname, age) VALUES ('$fname', '$lname', '$age')");
mysql_close($con);
 

I think that’s it. Please learn what the difference is between ’ and ", when you should which one, and especially when you shouldn’t use either of them. Also learn how to prevent SQL injections with mysql_real_escape_string.

Good luck!

Founded in 2004, Leakfree.org became one of the first online communities dedicated to Valve’s Source engine development. It is more famously known for the formation of Black Mesa: Source under the 'Leakfree Modification Team' handle in September 2004.