LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I'm having serious syntax errors and can't seem to find a friendly answer (https://www.linuxquestions.org/questions/linux-newbie-8/im-having-serious-syntax-errors-and-cant-seem-to-find-a-friendly-answer-4175468039/)

phase3studios 07-01-2013 01:59 PM

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.

vmccord 07-01-2013 02:15 PM

This snippet is not the SQL statement that your db engine is rejecting. This snippet populates what shows in the web page.

Doc CPU 07-01-2013 02:19 PM

Hi there,

Quote:

Originally Posted by phase3studios (Post 4981876)
I am having two major problems that need to be fixed by tomorrow:

that's indeed a serious problem, especially when you have that little experience.

Quote:

Originally Posted by phase3studios (Post 4981876)
1. "You have an error in your SQL syntax near "Karen' (and a couple of others) at line 7". (Code to follow)

Okay - where's that SQL code? Or at least the PHP code that generates the SQL statement?

Quote:

Originally Posted by phase3studios (Post 4981876)
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.

A live example (read: a link to the offending web page) would be helpful.

Code:

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

This is a mix of PHP and HTML code - or more to the point, HTML with embedded PHP snippets which results in a part of the form- However, I can't see anything there which is related to any of the problems you describe.

Quote:

Originally Posted by phase3studios (Post 4981876)
Is there ANYONE who can give me help on this?

No, sorry, I don't think so. Not with this lack of information you offer.
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

vmccord 07-01-2013 02:23 PM

Don't be mean. phase3studios is clearly in a panic. We all do things that are far from well thought out when panicking.

Doc CPU 07-01-2013 02:55 PM

Hi there,

Quote:

Originally Posted by vmccord (Post 4981896)
Don't be mean. phase3studios is clearly in a panic. We all do things that are far from well thought out when panicking.

that's why I'm trying to push him at least somewhere near where we have a chance to pick him up and begin to help.
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.

phase3studios 07-01-2013 03:29 PM

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.

phase3studios 07-01-2013 03:31 PM

I can also add the php form if needed. I didn't expect to get this far over my head.

phase3studios 07-01-2013 03:34 PM

also here is the page (form) http://www.autotransportlink.com/AEI...-Workorder.php (click new)

phase3studios 07-01-2013 05:48 PM

Thanks, but I got help form another forum. It's done, all but a little tidying up. Thanks!

vmccord 07-02-2013 10:16 AM

Awesome!

grail 07-02-2013 12:07 PM

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.

David the H. 07-03-2013 03:11 PM

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.