||11-16-2012 12:32 AM
PHP/form insert statement to mysql
I'm trying to insert this form data into mysql database but I keep getting a server error what am I doing wrong?
$db_s = "localhost";
$db_u = "bs_72";
$db_p = "tmmd2f";
$db_n = "bs_72";
$co = mysqli_connect($db_s,$db_u,$db_p)
or die('Error connecting to MySQL server.');
$first_name = $_POST['firstname'];
$last_name = $_POST['lastname'];
$e_mail = $_POST['email'];
$when_it_happened = $_POST['whenithappened'];
$phone_number = $_POST['phonenumber'];
$i_description = $_POST['idescription'];
$query = “INSERT INTO las_cruces (first_name, last_name, e_mail, when_it_happened, “ .
“phone_number, i_description) “ .
“VALUES (‘$first_name’, ‘$last_name’,‘$e_mail’, ‘$when_it_happened’ , ‘$phone_number’, “ .
$result = mysqli_query($co, $query);
or die('Error querying database.');
echo 'Hello, ' . $first_name . ' ' . $last_name . '<br />';
echo 'Thanks for submitting the form.<br />';
echo 'Your email is ' . $e_mail . '<br />';
echo 'Your phone number? ' . $phone_number . '<br />';
echo 'The date of the incidence was ' . $when_it_happened . '<br />';
echo 'What Happened: ' . $i_description . '<br />';
<form method="post" action="report.php">
||11-16-2012 04:48 AM
I think it might be your query, I've never seen any query written like that in php only in mysql but I might be wrong. Maybe someone could clarify??
Also I noticed you got your
<form> after the closing
Also, what error message are you getting?
|All times are GMT +1. The time now is 05:20 AM.
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.