MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 7th, 2005, 04:16 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
MySql error (#1064)

Hey, just wondering if anyone can help me out, I'm getting a syntax error, this is my code..

PHP Code:
<?php
$sql 
"SELECT * FROM 'image' ORDER BY image_date DESC";
$result mysql_query ($sql) OR die("MySQL Error #".mysql_errno().": ".mysql_error()); 
if (
mysql_num_rows($result)>0) {
while (
$row mysql_fetch_array($resultMYSQL_ASSOC)) {
$i++;
$str .= $i.". ";
$str .= "<a href=\"index.php?iid=".$row["image_id"]."\">"
$row["image_name"]."</a> ";
$str .= "[".$row["image_date"]."] ";
$str .= "[".$row["image_size"]."] ";
$str .= "[<a href=\"index.php?act=rem&iid=".$row["image_id"]
"\">Remove</a>]<br>";
}
print 
$str;
}
?>


this is the error..

MySQL Error #1064: 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 ''image' ORDER BY image_date DESC' at line 1

Reply With Quote
  #2  
Old June 7th, 2005, 07:18 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
Change your ' to ` (single-quotes to backticks), or just remove them.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn"


Reply With Quote
  #3  
Old June 7th, 2005, 07:54 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Quote:
Originally Posted by Madpawn
Change your ' to ` (single-quotes to backticks), or just remove them.

Thanks, I'll try that..

Reply With Quote
  #4  
Old June 7th, 2005, 10:22 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Quote:
Originally Posted by Madpawn
Change your ' to ` (single-quotes to backticks), or just remove them.

Ok when I changed it to `image` I got this error..

MySQL Error #1146: Table 'theradar_phpAds.image' doesn't exist

same when I don't have anything around the table name..

Reply With Quote
  #5  
Old June 7th, 2005, 10:36 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
Make sure you're in the right database and you have the proper table name (for example, make sure it's not supposed to be 'images' or something like that).

Reply With Quote
  #6  
Old June 7th, 2005, 11:02 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Quote:
Originally Posted by Madpawn
Make sure you're in the right database and you have the proper table name (for example, make sure it's not supposed to be 'images' or something like that).


This is the mysql I used to create the table..

PHP Code:
 CREATE TABLE image (
image_id int(10unsigned NOT NULL auto_increment,
image_type varchar(50NOT NULL default '',
image longblob NOT NULL,
image_size bigint(20NOT NULL default '0',
image_name varchar(255NOT NULL default '',
image_date datetime NOT NULL default '0000-00-00 00:00:00',
UNIQUE KEY image_id (image_id)
); 

Reply With Quote
  #7  
Old June 7th, 2005, 11:22 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
The error means you don't have a table called 'image' in the database 'theradar_phpAds'. Your CREATE statement's ok, so it must be in a different database.

Reply With Quote
  #8  
Old June 8th, 2005, 12:25 AM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Strange, the 'theradar_phpAds is another database??

I'm using this:

PHP Code:
require_once( "connections/theRadarDB.php" ); 


to connect to the database, and this is that code:

PHP Code:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_theRadarDB "localhost";
$database_theRadarDB "theradar_dbase";
$username_theRadarDB "theradar";
$password_theRadarDB "password";
$theRadarDB mysql_pconnect($hostname_theRadarDB$username_theRadarDB$password_theRadarDB) or die(mysql_error());
mysql_select_db($database_theRadarDB) or die("Could not select database");
?>

have I done anything wrong there? Do I need to select the database in the main code? Sorry to be a pain.. Thanks for your help too by the way

Reply With Quote
  #9  
Old June 8th, 2005, 09:24 AM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
Is that the only mysql_select_db call you've got? If you've got another one between that and your query, it'll overwrite your original. My guess is you have some ad rendering code (probably through an include()) that connects to a different database.

Reply With Quote
  #10  
Old June 8th, 2005, 04:06 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Quote:
Originally Posted by Madpawn
Is that the only mysql_select_db call you've got? If you've got another one between that and your query, it'll overwrite your original. My guess is you have some ad rendering code (probably through an include()) that connects to a different database.

Yep, the only one I'm using, I'm also using phpAds, so do you think that's getting in the way? I'll move my db connection string to where my image table is supposed to go, hopefully that will fix it..

Reply With Quote
  #11  
Old June 8th, 2005, 08:48 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Ok, so it's the phpAds which is causing the error, currently it's using this script to call in the Ad, is there anything I can do to make it stop screwing around with my other dbase??

PHP Code:
<?php
    
if (@include(getenv('DOCUMENT_ROOT').'/phpAds/phpadsnew.inc.php')) {
        if (!isset(
$phpAds_context)) $phpAds_context = array();
        
$phpAds_raw view_raw ('zone:1'0'''''0'$phpAds_context);
        echo 
$phpAds_raw['html'];
    }
?>

Reply With Quote
  #12  
Old June 8th, 2005, 10:27 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
Just run a mysql_select_db() call before your query (though depending on how your ads stuff is set up, you may have to reset it back to radar_phpAds afterwards -- but I doubt it).

Reply With Quote
  #13  
Old June 8th, 2005, 10:46 PM
Souliebaby Souliebaby is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 62 Souliebaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 24 m 49 sec
Reputation Power: 4
Quote:
Originally Posted by Madpawn
Just run a mysql_select_db() call before your query (though depending on how your ads stuff is set up, you may have to reset it back to radar_phpAds afterwards -- but I doubt it).

Ahh nice.. thanks for your help! I've managed to get it working now..

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > MySql error (#1064)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |