Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 04-15-2010, 08:14 AM string format error
Extreme Talker

Posts: 173
Trades: 0
I have the following string that I am tryingt execute, however I get an error that prevents the code from running correctly.

PHP Code:
$str_row=$str_row.'<td><a href="display_md4c8.php?project='.$row['project'].'&status=Plan.order">'.$row1['planned'].'</a></td>'
Quote:
SELECT * FROM tbl_md4c WHERE project=3418499 AND status=Plan.order ORDER BY project ASC DB Error, could not query the databaseMySQL Error: Unknown column 'Plan.order' in 'where clause'
If I run the query directly in the db, this is the error that I get
Quote:
#1054 - Unknown column 'Plan.order' in 'where clause'
If I put quotes around the Plan.order, then it works
Quote:
SELECT *
FROM tbl_md4c WHERE project =3418499 AND STATUS = "Plan.order" ORDER BY project ASC
If I have phpMyAdmin create the php code for the query, it generates
Quote:
$sql = "SELECT * FROM tbl_md4c WHERE project=3418499 AND status=\"Plan.order\" ORDER BY project ASC";
where it is inserting \" around the Plan.order

However if I try to add the \" into my original string like so
Quote:
$str_row=$str_row.'<td><a href="display_md4c8.php?project='.$row['project'].'&status=\"Plan.order\"">'.$row1['planned'].'</a></td>';
this is the resulting error message.

Quote:
SELECT * FROM tbl_md4c WHERE project=3418499 AND status=\\ ORDER BY project ASC DB Error, could not query the databaseMySQL 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 '\\ ORDER BY project ASC' at line 1
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-15-2010, 07:54 PM Re: string format error
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
First, you should not be putting SQL directly from a URL. This is a great opportunity for what is known as SQL injection and can threaten your database.

Second, you should go to where the query is in your code and add the quotes.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 04-15-2010, 09:20 PM Re: string format error
Extreme Talker

Posts: 173
Trades: 0
I am not inserting sql statement into a URL. I am trying to pass two values to a second page. Project number and Status.

Plan.order is data that exists in a table under the column status. It could be the (.) that is causing the problem.

This is the resulting SQL statement that in created on the second sheet however, it is getting stuck on the Plan.order or so it seems.

SELECT * FROM tbl_md4c WHERE project=3418499 AND status=Plan\\.order ORDER BY project ASC DB Error, could not query the database MySQL 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 '\\.order ORDER BY project ASC' at line 1

I tried to insert single quote as you suggested but no luck. My string and resulting error below.

if (strlen(strstr($_SESSION['interface'],"H"))>0) $str_row=$str_row.'<td><a href="display_md4c8.php?project='.$row['project'].'&status='Plan.order'">'.$row1['planned'].'</a></td>';

Parse error: parse error in C:\Program Files\EasyPHP 3.0\www\My Websites\Fat Cat\display_project_list3.php on line 98
dgkindy is offline
Reply With Quote
View Public Profile
 
Old 04-15-2010, 10:03 PM Re: string format error
Extreme Talker

Posts: 173
Trades: 0
Okay, I got it, the problem was on the other end. When I passed the variable Plan.order, I needed to add quotes to the sql on the new form.
dgkindy is offline
Reply With Quote
View Public Profile
 
Old 04-19-2010, 07:05 PM Re: string format error
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep
ORDER is a reserved word in SQL
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to string format error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34491 seconds with 12 queries