Jump to content

[SOLVED] Query not working...


savagenoob

Recommended Posts

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());

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.