Welcome to WebmasterWorld Guest from 54.167.110.211

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Basic, Just cant see it.

     
5:08 pm on Apr 16, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Mar 4, 2004
posts:553
votes: 0


is there a problem with this

<?php
error_reporting(E_ALL);
include 'dbconnect.php';

$result = mysql_query("SELECT * FROM character where uid = '1'", $link) or die ("query 1: " . mysql_error());
$row = mysql_fetch_array($result);
?>

Im getting this error

query 1: 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 'character where uid = '1'' at line 1

thanks

Dylan

5:46 pm on Apr 16, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Feb 10, 2006
posts:627
votes: 0


How did you define uid field Ė as string or number? I am guessing as a number, hence I donít think you need single quotes around itís value. So it should be something like:

$result = mysql_query("SELECT * FROM character WHERE uid=1", $link) or die ("query 1: " . mysql_error());

I am relative newb to PHP and MySQL so take this with grain of saltÖ.

HTH

5:56 pm on Apr 16, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 18, 2005
posts:70
votes: 0


Take this with a pinch of salt too, but I believe that 'character' is a reserved word in MySQL. Running a similar query here gives the same error, as opposed to the 'db.table does not exist'.

Check the MySQL manual for reserved words.

5:59 pm on Apr 16, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 18, 2005
posts:70
votes: 0


Found the reference:

The words in the following table are explicitly reserved in MySQL 5.0. At some point, you might update to a higher version, so it's a good idea to have a look at future reserved words, too. You can find these in the manuals that cover higher versions of MySQL. Most of the words in the table are forbidden by standard SQL as column or table names (for example, GROUP). A few are reserved because MySQL needs them and (currently) uses a yacc parser. A reserved word can be used as an identifier if you quote it.

Among the words is indeed 'character'.

[dev.mysql.com...]

6:29 pm on Apr 16, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member dreamcatcher is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 30, 2003
posts:3719
votes: 0


Try using back ticks:

"SELECT * FROM `character`...

dc

7:01 pm on Apr 16, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Mar 4, 2004
posts:553
votes: 0


got it, just changed the table name, thanks all
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members