FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

mysql syntax error I can't find why

 


Mgccl
Quote:
$id = 1;
$prefix = nuke;
$query = 'SELECT '.
'p.elo, p.team, p.win, p.lose, p.draw, p.exp, p.page_id, p.total_enemy_elo, p.total_enemy_exp, p.country_id, p.team_id, p.rank_elo, p.rank_exp, p.rank_elo_change, p.rank_exp_change, p.rank_team_elo, p.rank_team_exp, p.rank_team_elo_change, p.rank_team_exp_change, p.rank_country_elo, p.rank_country_exp, p.rank_country_elo_change, p.rank_country_country_exp_change, p.rate_power, p.rate_reputation, '.
'u.username, '.
'c.flag, c.name, '.
't.prefix, t.suffix, '.
'FROM '.$prefix.'_ladder_prof p, '.
$prefix.'_ladder_country c, '.
$prefix.'_ladder_team t '.
'ON p.country_id = c.id AND p.team_id = t.id'.
'WHERE id = '.$id.' '.
'LIMIT 1';

I have tryied everything and too me it looks fine... BUT... I just can't find what's wrong with it.....


and.. I see most people use " instead of ' for Mysql querys... which one is better?
SpellcasterDX
Don't you have to put CREATE TABLE_blah_XX or Insert into TABLE_blah_XX? Confused
hexkid
Mgccl wrote:
$query = 'SELECT '.
// ... columns
'FROM '.$prefix.'_ladder_prof p, '.
$prefix.'_ladder_country c, '.
$prefix.'_ladder_team t '.
'ON p.country_id = c.id AND p.team_id = t.id'.
'WHERE id = '.$id.' '.
'LIMIT 1';


I have tryied everything and too me it looks fine... BUT... I just can't find what's wrong with it.....

You're not using the correct JOIN syntax.
I don't like JOINs, so I can't help you with it. I usually only use WHERE and let the server have all the work Smile

Code:
SELECT columns FROM table1, table2, table3, ...
WHERE table1.x=table2.y and table2.x=table3.y ...

I think the above query can be specified with JOINs as
Code:
SELECT columns FROM table1 JOIN table2 ON table1.x=table2.y JOIN table3 ON table2.x=table3.y ...


Mgccl wrote:
and.. I see most people use " instead of ' for Mysql querys... which one is better?

The better is the one you like best!
I usually use single quotes for everything except SQL statements Smile

compare
Code:
$sql = "select * from tbl where id=$id";
$sql = 'select * from tbl where id=' . $id;
Related topics

PHP DB Error: syntax error
Parse error: syntax error, unexpected '{' in /home/frih/publ
a site where i can learn mysql syntax
Parse error: syntax error, unexpected T_NEW
E-Cards with PHP & MySQL

Some times, the error is so hard to find and so funny
MySQL - Session error?
MySQL statement error (got me going)
phpBB Error, seems to be a MYSQL DB error...
Suppressing mysql error

MySQL socket error
insert data to mySQL database problem
Delete data from MySQL database problem!!
mySQL issue
Activation Script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.