Jump to content


Photo

SQL syntax error line 1


  • Please log in to reply
2 replies to this topic

#1 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 April 2006 - 07:24 PM

Newbie question

when the SQL error says line on does that mean line of the whole HTML/PHP script or just the first line of the actuall php script in the HTML script

thanks

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 01 April 2006 - 08:13 PM

It means the first line of the SQL query

If you put the query all on one line then the error, if there is one, wil always be on line 1.

SELECT a.cola, b.colb, b.colc FROM table1 a INNER JOIN table2 b ON a.cola = b.cola WHERE b.colc = '$x' AND b.colx = 42

or you could split it over several lines

SELECT a.cola, b.colb, b.colc 
FROM table1 a 
        INNER JOIN table2 b ON a.cola = b.cola 
WHERE b.colc = '$x' 
        AND b.colx = 42

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 01 April 2006 - 10:10 PM

[!--quoteo(post=360686:date=Apr 1 2006, 03:13 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Apr 1 2006, 03:13 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
It means the first line of the SQL query

If you put the query all on one line then the error, if there is one, wil always be on line 1.

SELECT a.cola, b.colb, b.colc FROM table1 a INNER JOIN table2 b ON a.cola = b.cola WHERE b.colc = '$x' AND b.colx = 42

or you could split it over several lines

SELECT a.cola, b.colb, b.colc 
FROM table1 a 
        INNER JOIN table2 b ON a.cola = b.cola 
WHERE b.colc = '$x' 
        AND b.colx = 42
[/quote]


thanks atleast i have a starting point to find the problem




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users