savagenoob Posted December 29, 2008 Share Posted December 29, 2008 Does anyone see anything wrong with this query? When I echo $query it shows no errors but does not update the table. No Apache errors either. $ID = mysql_escape_string($_POST['ID']); $PolicyNumber = mysql_escape_string($_POST['PolicyNumber']); $First_Name = mysql_escape_string($_POST['First_Name']); $Middle_Name = mysql_escape_string($_POST['Middle_Name']); $Last_Name = mysql_escape_string($_POST['Last_Name']); $phone = mysql_escape_string($_POST['Phone']); $fax = mysql_escape_string($_POST['Fax']); $email = mysql_escape_string($_POST['Email']); $physst = mysql_escape_string($_POST['Street']); $physcity = mysql_escape_string($_POST['City']); $physstate = mysql_escape_string($_POST['State']); $physzip = mysql_escape_string($_POST['Zip']); $mailstreet = mysql_escape_string($_POST['MailingStreet']); $mailcity = mysql_escape_string($_POST['MailingCity']); $mailstate = mysql_escape_string($_POST['MailingState']); $mailzip = mysql_escape_string($_POST['MailingZip']); $employer = mysql_escape_string($_POST['Employer']); $occupation = mysql_escape_string($_POST['Occupation']); $empstreet = mysql_escape_string($_POST['EmpStreet']); $empcity = mysql_escape_string($_POST['EmpCity']); $empstate = mysql_escape_string($_POST['EmpState']); $empzip = mysql_escape_string($_POST['EmpZip']); $married = mysql_escape_string($_POST['married']); $gender = mysql_escape_string($_POST['Gender']); $datebirth = mysql_escape_string($_POST['DateBirth']); $policystatus = mysql_escape_string($_POST['status']); $agent = mysql_escape_string($_POST['agent']); $query = "UPDATE clients SET PolicyNumber='$PolicyNumber', First_Name='$First_Name', Last_Name='$Last_Name', Phone='$phone', Fax='$fax', Email='$email, Phys_Street='$physst', Phys_City='$physcity', Phys_State='$physstate', Phys_Zip='$physzip', Mail_Street='$mailstreet', Mail_State='$mailstate', Mail_Zip='$mailzip', Employer='$employer', Occupation='$occupation', Emp_Street='$empstreet', Emp_State='$empstate', Emp_Zip='$empzip', Married='$married', Sex='$gender', Date_Birth='$datebirth', Status='$policystatus', Agent='$agent' WHERE ID= '$ID'"; $result = mysql_query($query) or trigger_error(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/ Share on other sites More sharing options...
Gamic Posted December 29, 2008 Share Posted December 29, 2008 What does selecting * from the table do with the same where condition? Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/#findComment-725309 Share on other sites More sharing options...
Maq Posted December 29, 2008 Share Posted December 29, 2008 Are you sure there is an ID with an ID of $ID? Everything else looks OK... Is this the whole script? Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/#findComment-725328 Share on other sites More sharing options...
savagenoob Posted December 29, 2008 Author Share Posted December 29, 2008 OK, tried another error display function and now it is coming up with this. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Antelope', Phys_State='CA', Phys_Zip='95843', Mail_Street='', Mail_State='CA', M' at line 1 using this query... UPDATE clients SET PolicyNumber='A9898989', First_Name='Bob', Last_Name='Fake', Phone='222-222-2222', Fax='', Email='fake@yahoo.com, Phys_Street='', Phys_City='Antelope', Phys_State='CA', Phys_Zip='95843', Mail_Street='', Mail_State='CA', Mail_Zip='', Employer='', Occupation='Sales', Emp_Street='', Emp_State='CA', Emp_Zip='', Married='Married', Sex='M', Date_Birth='01/11/1900', Status='', Agent='' WHERE ID= '5' This same setup was working fine with only PolicyNumber, First_Name, Last_Name... Then I set up the whole table to update, now its doing this. I tried running the query manually and its saying the same thing. I think it has something to do with the single quotes or empty fields although the fields in my table are not setup "Not Null". I double checked. Im goin crazy here. I am sure there is a client with that ID. I have an edit link on a client, then it passes the client ID with GET. Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/#findComment-725470 Share on other sites More sharing options...
fenway Posted December 29, 2008 Share Posted December 29, 2008 You didn't close the single quote for the email field. Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/#findComment-725719 Share on other sites More sharing options...
savagenoob Posted December 30, 2008 Author Share Posted December 30, 2008 I fixed, something to do with null fields in the update form and unsigned integers... whatever... its working Thanks guys... til next noob post. Quote Link to comment https://forums.phpfreaks.com/topic/138688-solved-query-not-working/#findComment-725895 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.