very fast question (mysql query/php getting result)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

very fast question (mysql query/php getting result)

Post by spamyboy »

Code: Select all

$result = mysql_query("
                            SET @counter = 0;
                            SELECT `static_id`,
                            IF (`static_position`=@counter, @counter:=@counter+1, @counter:=@counter+1) as `static_new_position`
                            FROM `gcms_static` ORDER BY `static_new_position`, `static_id`") or die(mysql_error());

Code: Select all

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 `static_id`, IF (`static_position`=@counter, @counter:=' at line 1
Obviously I use some wrong method to make such query.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: very fast question (mysql query/php getting result)

Post by VladSun »

You can't use multiple queries in mysql_query().
mysql_query() sends an unique query (multiple queries are not supported) ...
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Re: very fast question (mysql query/php getting result)

Post by spamyboy »

VladSun wrote:You can't use multiple queries in mysql_query().
mysql_query() sends an unique query (multiple queries are not supported) ...
Thank you.
Post Reply