$user = $_SESSION['email']; $time = time(); $name = $_POST['name']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $owner = $_POST['owner']; $price = $_POST['price']; $phone = $_POST['phone']; $features = $_POST['features']; $type = $_POST['type']; //$image = $_POST['image']; $image = "1"; if ($name != "") { $sql = "insert into biz_4_sale values ('', '$ip', '$user', '$time', '$name', '$address', '$city', '$state', '$zip', '$owner', '$price', '$phone', '$features', '$type', '$image', '0')"; mysql_query($sql); $sql = "select * from biz_4_sale where ip = '$ip' and time = '$time'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $id = $row['id']; } PHP: I'm sure there's a better way to do this, but this is just a quick little piece I need working pretty fast. The problem: It's not getting inserted into the database. I believe it was a few days ago when I wrote it, but now that I'm going through to optimize my code and test it all, this piece isn't working. Any idea why? Thanks!!!
Just add or die(mysql_error()) to debug it. mysql_query($sql) or die(mysql_error()); Now, let us know what the error message is.
Append ' or die(mysql_error)' to yourt queries and tell me what error it returns $result = mysql_query($sql) or die(mysql_error); PHP:
Also check that your are inserting exactly that many fields as the row can hold. not a single less or more!
Ah Jesus. User error. Thanks Lordo. I had a single quote screwing things up. I need to switch those out with the hex value. I guess I'll go ahead and do the security bit now too then!
^to avoid those error due to single quotes always use mysql_real_escape_string() function! It will take care of single as well as double quotes.
Oh awesome! I was just going to use str_replace on all my variables... this will take just a bit of typing away. Cool, thanks. +rep