I'm having serious syntax errors and can't seem to find a friendly answer
I am having two major problems that need to be fixed by tomorrow:
1. "You have an error in your SQL syntax near "Karen' (and a couple of others) at line 7". (Code to follow) 2. The dropdown options don't show up on the webpage (form) although when clicking down arrow and blindly selecting an option and submitting the form, it shows the correct option in the error message. PHP code form to MySql db.: <select size="1" name="SalesPerson"> <option selected>Select One</option> <option value="Karen"<?php if ($row["ColumnName"] == "Karen") echo " SELECTED "; ?>Karen</option> <option value="Nanette"<?php if ($row["ColumnName"] == "Nanette") echo " SELECTED "; ?>Nanette</option> <option value="Jenny"<?php if ($row["ColumnName"] == "Jenny") echo " SELECTED "; ?>Jenny</option> <option value="Mary Ann"<?php if ($row["ColumnName"] == "Mary Ann") echo " SELECTED "; ?>Mary Ann</option> <option value="Don"<?php if ($row["ColumnName"] == "Don") echo " SELECTED "; ?>Don</option> <option value="Ira"<?php if ($row["ColumnName"] == "Ira") echo " SELECTED "; ?>Ira</option> <option value="Stephen"<?php if ($row["ColumnName"] == "Stephen") echo " SELECTED "; ?>Stephen</option> <option value="Ronnie"<?php if ($row["ColumnName"] == "Ronnie") echo " SELECTED "; ?>Ronnie</option></select> end of code. Is there ANYONE who can give me help on this? I'm in desperate need of answers. Thanks in advance. |
This snippet is not the SQL statement that your db engine is rejecting. This snippet populates what shows in the web page.
|
Hi there,
Quote:
Quote:
Quote:
Code:
<select size="1" name="SalesPerson"> Quote:
Concerning the SQL syntax error, you should show the part of your PHP code that deals with the DB; concerning the usability problem, allow us to see it "live". [X] Doc CPU |
Don't be mean. phase3studios is clearly in a panic. We all do things that are far from well thought out when panicking.
|
Hi there,
Quote:
I don't think I'm being mean - I just behave the same as my environment would behave towards me. [X] Doc CPU PS: Sorry about assuming "him" - it could be "her" as well. |
Here is the info (I think) you are requesting:
Below is the query info. I am a real newbie and am trying to get this to work. I've had others to help but still get this message:
"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 'Mary Ann', ContactName = sdgsgsg', JobName = gsgsg', Job_Address = ' at line 7" Query: // Connects to your Database mysql_connect("deleted", "deleted", "deleted") or die(mysql_error()); mysql_select_db("aaaeeeiii") or die(mysql_error()); //Find if the SO Number already exists. $sql = "SELECT COUNT(*) as Cnt "; $sql .= " FROM workorder"; $sql .= " WHERE SONumber = '$SONumber'"; $result = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $Cnt = $row["Cnt"]; } if ($Cnt == 0) { //we don't have SO Number -- create it! $sql = "INSERT INTO workorder (SONumber) VALUES ('$SONumber')"; mysql_query($sql) or die(mysql_error()); } //service order found or created $sql = "UPDATE workorder SET PO = '$PO', ServiceDate = '$ServiceDate', SalesPerson = $SalesPerson', ContactName = $ContactName', JobName = $JobName', Job_Address = $Job_Address', ContactPhone = $ContactPhone', TechName = $TechName', Customer = $Customer', Customer_Address = $Customer_Address', Bill_City = $Bill_City', Customer_State = $Customer_State', Zip = $Zip', CustomerEmail = $CustomerEmail', AP_Phone = $AP_Phone', AP_Fax = $AP_Fax', APEmail = $APEmail', Exempt = $Exempt', Resale = $Resale', Expire_Date = $Expire_Date', WO_Cancelled = $WO_Cancelled', aei_1 = $aei_1', Part_1 = $Part_1', aei_2 = $aei_2', aei_20 = $aei_20', aei_3 = $aei_3', Part_2 = $Part_2', aei_4 = $aei_4', aei_21 = $aei_21', aei_5 = $aei_5', Part_3 = $Part_3', aei_6 = $aei_6', aei_22 = $aei_22', aei_7 = $aei_7', Part_4 = $Part_4', aei_8 = $aei_8', aei_23 = $aei_23', aei_9 = $aei_9', Part_5 = $Part_5', aei_10 = $aei_10', aei_24 = $aei_24', Notes = $Notes', New_Quote = $New_Quote', aei_11 = $aei_11', SLabor1 = $SLabor1', aei_12 = $aei_12', aei_25 = $aei_25', aei_13 = $aei_13', SLabor2 = $SLabor2', aei_14 = $aei_14', aei_26 = $aei_26', aei_15 = $aei_15', SLabor3 = $SLabor3', aei_16 = $aei_16', aei_27 = $aei_27', Other1 = $Other1', aei_28 = $aei_28', Other2 = $Other2', aei_29 = $aei_29', Other3 = $Other3', aei_30 = $aei_30', aei_45 = $aei_45', aei_32 = $aei_32', aei_41 = $aei_41', aei_40 = $aei_40', aei_43 = $aei_43', aei_42 = $aei_42', aei_50 = $aei_50' WHERE SONumber = '$SONumber'"; mysql_query($sql) or die(mysql_error()); ?> Thank you so much for your help. |
I can also add the php form if needed. I didn't expect to get this far over my head.
|
also here is the page (form) http://www.autotransportlink.com/AEI...-Workorder.php (click new)
|
Thanks, but I got help form another forum. It's done, all but a little tidying up. Thanks!
|
Awesome!
|
As you may come to find, should you continue to use this site, the idea is not only to ask questions but to also help others. It is good that you have found an answer, so to help others
that may search and find this question is similar to an issue they are having, please share your new found knowledge that others may benefit. |
Also, please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques. Thanks.
|
All times are GMT -5. The time now is 08:31 PM. |