Reputation: 611
I'm trying to make this information insert into my table in mysql database with this script I wrote.
<?php
require("../includes/db.php");
$nme = $_POST["nme"];
$email = $_POST["email"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$phone = $_POST["phone"];
$options = implode($_POST["options"],", ");
$query = mysql_query("insert into peeps (name, email, address, city, zip, phone, type) values ('$nme','$email','$address','$city','$state','$zip','$phone','$options')");
if($query)
print "yes";
else
print "no";
?>
The output of this code is no.
Upvotes: 0
Views: 120
Reputation: 6190
If you modify this part of your code you can see the exact error you get.
if($query)
{
print "yes";
}
else
{
print mysql_error(); ;
}
However the way you have written may generate errors if you do not have enabled Magic Quotes. If you have that kind of error you better use mysql_escape_string
Upvotes: 1
Reputation: 2416
If mysql_query() returns false, it means the query failed.
Try this:
if (false === $query) // make sure it's actually boolean false
print mysql_error(); // print a nice plain-english description of the problem.
else
print "Yes";
This should give you a good idea of where the problem is.
Upvotes: 1