I've searched everywhere on the net and can't find anything close to an answer for my problem

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.

<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>

Open in new window

phase3studiosAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nemws1Connect With a Mentor Database AdministratorCommented:
Sorry... I now see your "code to follow" for the SQL error.  Please post and we'll take a look at it. :)

(Just to clarify as well.. you were not closing your opening <Option> tag.  If you look at your original code again and count less than signs versus greater than signs per line, this will become very clear.)
0
 
nemws1Database AdministratorCommented:
Well, I see no SQL here, so you'll have to post whatever query you are trying to run as well.  Maybe have your script dump it out as HTML to your page before it runs the query (even as an HTML comment) so we can see the data.  I'm guessing you're missing a quote or double-quote.

As for your options, you are missing the greater than sign after you print out whether or not that option should be selected.  )This is pretty clear if you look at the generated HTML):

<form>
<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>

Open in new window

0
 
phase3studiosAuthor Commented:
Thanks, you're right about the option tag close.  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.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
nemws1Database AdministratorCommented:
Right before this line:
mysql_query($sql)  or die(mysql_error());

Open in new window


put this:

print "<PRE>";
print $sql;
print "</PRE>";

Open in new window


Try your form again and then post the first part (should be the first 5-6 lines) of the SQL command that gets printed that is failing.

I can't quite tell from the code what the problem is.
0
 
phase3studiosAuthor Commented:
Thank you!  I did that and here is what came back:
SELECT COUNT(*) as Cnt  FROM workorder WHERE SONumber = '0720131 -  16 '
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 '‘Jenny', ContactName = ‘wwgggwrg', JobName = ‘wergwergwerg', Job_Addres' at line 7
0
 
nemws1Database AdministratorCommented:
Well, the 'print $sql' is in the wrong spot.

I need it to print out whatever statement (I'm guessing its the UPDATE statement) is causing the above error.

Whatever gets printed out should contain "Jenny" and "wwgggwrg" etc.... (the same things as what the error is printing out)
0
 
phase3studiosAuthor Commented:
would it help if I posted the form address?  Thank you so much for being nice!
0
 
phase3studiosAuthor Commented:
let me move it and get back to you.  Thanks
0
 
phase3studiosAuthor Commented:
I am sorry, but moving the 'print $sql' higher only gives this:

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 '‘Select One', ContactName = ‘', JobName = ‘', Job_Address = ‘', Cont' at line 7

is there something I am doing wrong?
0
 
nemws1Database AdministratorCommented:
Well, yes, because its not printing what I want to see. ;-)  I wouldn't call that "wrong" though.

Maybe you need to move it down.  Between these two lines, which is after your UPDATE command.

      WHERE SONumber = '$SONumber'";

   mysql_query($sql)  or die(mysql_error());

Open in new window

0
 
phase3studiosAuthor Commented:
I did that exactly and here is what came back:

SELECT COUNT(*) as Cnt  FROM workorder WHERE SONumber = '1234567'
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 '‘Select One', ContactName = ‘', JobName = ‘', Job_Address = ‘', Cont' at line 9
0
 
nemws1Database AdministratorCommented:
Something wonky is going on.  It's obvious that that SELECT statement doesn't have 'ContactName' in it, so its printing the wrong query.

Can you e-mail me your PHP script (remove username/password/etc.)?  nemws1<the symbol for an e-mail address>gmail.com
0
 
phase3studiosAuthor Commented:
Absolutely!
0
 
phase3studiosAuthor Commented:
I would like to thank nemws1!  You have helped tremendously!   I couldn't have done it, otherwise! Blessings to you!
0
 
nemws1Database AdministratorCommented:
You're welcome. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.