herghost Posted December 2, 2007 Share Posted December 2, 2007 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 'and c.city=53230 and co.country=2' at line 1 Can someone explain what this means and how i fix it?! Thanks Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/ Share on other sites More sharing options...
pocobueno1388 Posted December 2, 2007 Share Posted December 2, 2007 Post your code Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404505 Share on other sites More sharing options...
herghost Posted December 2, 2007 Author Share Posted December 2, 2007 if ($step=="signup7") { //title echo "<h2>Primary Contact Information</h2>"; echo "This is how your business will be contactable through the site, so customers know where to bring their coupons! You can add addresses for more locations later"; //get user value from session $cur_business = $_SESSION["cur_business"]; //Post Variables $address1= trim($_POST ["address1"]); $address2= trim($_POST ["address2"]); $country = trim($_POST["country"]); $city= trim($_POST ["city"]); $state= trim($_POST ["county"]); $zip= trim($_POST ["postcode"]); $phone1= trim($_POST ["phone1"]); $phone2= trim($_POST ["phone2"]); $fax= trim($_POST ["fax"]); $email= trim($_POST ["email"]); //////////////// //form checking /////////////// if ($_POST) { $error=":</b>"; //Check for primary in DB (dont let people add 2) db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]); $sql = "select * from contacts where business='$cur_business' and pri_contact=1"; $result = db_query ($sql); while ($row=mysql_fetch_object($result)) { $id = $row->business; } mysql_close(); if ($id!="") {$error.="Primary Address Already Entered, <A href=index.php?page=signup8>Proceed to next step </a>";} //make sure address1 was entered if ($address1=="") {$error.="Address Line 1 Not Entered. ";} //make sure city was entered if ($city=="0") {$error.="City Not Selected. ";} //make sure state was entered if ($state=="0") {$error.="County Not Selected. ";} //make sure country was entered if($country=="0") {$error.="Country Not Selected";} //make sure zip was entered if ($zip=="" || strlen($zip)<6) {$error.="Postcode Not Entered ";} //make sure zip were entered if ($phone1=="") {$error.="Phone Number Not Entered. ";} //make sure username is a valid formatted email addres if (checkEmail($email)==0 && $email!="") { $error.="Email is not a real email address.";} //Pull out city and state values db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]); $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state=$state and c.city=$city and co.country=$country"; $result = db_query ($sql); while ($row=mysql_fetch_object($result)) { $state = $row->sabbr; $city = $row->cty_name; $country = $row->cabbr; } mysql_close(); //Print error, or redirect to next step if ($error!=":</b>") { echo "<Br><b> The Following Problems were found $error <br>"; unset($_POST); } else { echo "<Br>Saving contact Info Record Number: "; //Insert db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]); $values = "$cur_business,'$address1','$address2','$city','$state','$zip','$phone1','$phone2','$fax','$email','$country',1"; $cols = "business,address1,address2,city,state,zip,phone1,phone2,fax,email,county,pri_contact"; $id = db_insert ("contacts", $cols, $values); mysql_close(); echo "$id"; redirect ("index.php?page=signup8"); } } ////////////// //form ////////////// if (!$_POST) { echo "<form name=contact method=post action=index.php?page=signup7>"; echo "<input type=text name=address1 value='$address1'> <b> Address Line 1 </b> *<br>"; echo "<input type=text name=address2 value='$address2'> <b> Address Line 2 </b> <br>"; $formname="contact";include("citystate.php"); echo "<Br><input type=text size=11 maxlength=10 name=zip value='$zip'> <b> Postcode </b> * <br>"; echo "<input type=text name=phone1 value='$phone1'> <b> Phone 1 </b> * <br>"; echo "<input type=text name=phone2 value='$phone2'> <b> Phone 2 </b> <br>"; echo "<input type=text name=fax value='$fax'> <b> Fax </b> <br>"; echo "<input type=text name=email value='$email'> <b> Email </b> <br>"; echo "<Br><input type=submit value='Proceed to Login'>"; echo "</form>"; } } Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404509 Share on other sites More sharing options...
trq Posted December 2, 2007 Share Posted December 2, 2007 Try.... $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state='$state' and c.city='$city' and co.country='$country'"; failing that, can you echo your $sql variable? Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404518 Share on other sites More sharing options...
pocobueno1388 Posted December 2, 2007 Share Posted December 2, 2007 Change these lines $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state=$state and c.city=$city and co.country=$country"; $result = db_query ($sql); To $sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state='$state' and c.city='$city' and co.country='$country'"; $result = db_query($sql)or die(mysql_error() .'<p>QUERY: '.$sql); Post any errors you get. Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404520 Share on other sites More sharing options...
herghost Posted December 2, 2007 Author Share Posted December 2, 2007 The postcode check is now failing - thanks for all your help so far Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404523 Share on other sites More sharing options...
herghost Posted December 2, 2007 Author Share Posted December 2, 2007 No matter - error on my part - fixed now thanks :_ Link to comment https://forums.phpfreaks.com/topic/79887-solved-can-some-one-help-with-this-error/#findComment-404535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.