I know that I need to utilize the mysqli_escape_real_string to prevent apostrophes from crashing my insertion script :
<?php
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$when_it_happened = $_POST['whenithappened'];
$how_long = $_POST['howlong'];
$how_many= $_POST['howmany'];
$alien_description = $_POST['aliendescription'];
$what_they_did = $_POST['whattheydid'];
$fang_spotted = $_POST['fangspotted'];
$email = $_POST['email'];
$other = $_POST['other'];
$dbc = mysqli_connect('localhost','fang','aprildawn','aliendatabase')
or die('error connecting to MYSQL server.');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) ".
"VALUES('$first_name', '$last_name', '$when_it_happened','$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysqli_query($dbc, $query)
or die('DO NOT USe APOSTROPHES!');
mysqli_close($dbc);
.
My question is this...
how do I use mysqli_escape_real_string? I've tried the following syntax: VALUES('".mysqli_real_escape_string( '$first_name')"; but this doesn't work:mad::mad:
Seriously, if anyone can give me a solution to the mysqli_real_escape_string quandary I'll buy you a cappuccino !
cheers April
Edited by Roger, 01 April 2011 - 11:20 AM.
added code tags


Sign In
Create Account

Back to top









