If I run this:
I get this:
I have Bolded the problem line. The problem line is just above the last if-else. I have re-written it several times/ways to make sure that wasnt the case either. To double check i wrote it exactly as it is from a tutorial/book I have. Fair warning this is my first PHP/SQL integration so any generic tips would also be appreciates.
Thank you!!
Edited by DanNEBTD - 5/4/12 at 7:34pm
Code:
<html>
<body>
<?php
$query = "select * from address where ".$searchtype."like '%".$searchterm."%'";
$StreetAddress=$_POST['Street Address'];
$Address2=$_POST['Address2'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zipcode'];
$Notes=$_POST['Site Notes'];
//Required Address Fields
if (!$StreetAddress || !$City || !$State)
{
echo "Please fill out the Street address, City, and State and resubmit";
exit;
}
if (!get_magic_quotes_gpc())
{
$StreetAddress = addslashes($StreetAddress);
$Address2 = addslashes($Address2);
$City = addslashes($City);
$State = addslashes($State);
$Zip = addslashes($Zip);
$Notes = addslashes($Notes);
//Connect to Database
@$db = new mysqli('xxxxxxxx', 'xxxxxxx', 'xxxxxx', 'XXXXXXX');
//Display Error upon failed connection
if (mysqli_connect_errno())
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
$query = "insert into address values
('".$StreetAddress."', '".$Address2."', '".$City."', '".$State."', '".$Zip."', '".$Notes."')";
$result=$db->query($query);
if ($result)
{
echo $db->affected_rows." Address entered into database.";
}else
{
echo "An error has occured. The address was not added.";
}
$db->close();
?>
</body>
</html>
I get this:
Code:
query($query); if ($result) { echo $db->affected_rows." Address entered into database."; }else { echo "An error has occurred. The address was not added."; } $db->close(); ?>
I have Bolded the problem line. The problem line is just above the last if-else. I have re-written it several times/ways to make sure that wasnt the case either. To double check i wrote it exactly as it is from a tutorial/book I have. Fair warning this is my first PHP/SQL integration so any generic tips would also be appreciates.
Thank you!!
Edited by DanNEBTD - 5/4/12 at 7:34pm








