PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 30th, 2007, 08:35 PM
benfitts benfitts is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 benfitts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 22 sec
Reputation Power: 0
SELECT error: No such field - BUT query works in PHPmyadmin

So this is confusing the heck out of me and I could really use some help.

I have a MYSQL query that works when I open phpmyadmin and run the query. However when I run the query in my php page it generates the following:

"DB Error: no such field"

Code:
echo "SELECT * FROM Videos WHERE ShortTitle like \"$video\"<BR>";
		$result =& $conn->query ("SELECT * FROM Videos WHERE ShortTitle like \"$video\"");
		   if (DB::isError ($result))
			 die ("SELECT failed: " . $result->getMessage () . "\n");
		}


So my sql would be something like this:

Code:
SELECT * FROM Videos WHERE ShortTitle like "settingup-using-crazyegg"


Normally that works. I have about 20 records in this table that work fine, however this sql statement is no longer working from within PHP. From within SQL it works fine. I can put this SQL statement in, and run it and it works.

Thanks in advance for your help!

Reply With Quote
  #2  
Old May 1st, 2007, 04:11 AM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 153 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 29 m 35 sec
Reputation Power: 2
This will tell you more about the problem:
die ("SELECT failed: " . $result->getMessage() . ', ' . $result->getDebugInfo() . "\n");

Reply With Quote
  #3  
Old May 2nd, 2007, 11:39 AM
benfitts benfitts is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 benfitts User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 22 sec
Reputation Power: 0
That line of code is not working.

All I get still is: SELECT failed: DB Error: no such field

There is no additional data being output and no additional data in my php error log.

Reply With Quote
  #4  
Old May 4th, 2007, 01:20 PM
makkura makkura is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 8 makkura User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 57 m 2 sec
Reputation Power: 0
It may be a bit newbish to suggest it but since it works in phpmyadmin and not in code... have you selected the correct database after connecting to the mysql server?

IE:mysql_select_db($dbname);

Also, I'm not familiar with way you're calling queries and such
but I would write it:

Code:
$query = "SELECT * FROM Videos WHERE ShortTitle LIKE '$video';
$result = mysql_query($query) or die("ERROR: " . mysql_error());

Note: May be '$video%' (I don't use LIKE much :s)
Seeing that your result is being checked, your error (DB Error: no such field) may refer to the result having no fields (the \" not escaping out properly?). Referring to the query itself, since it's referencing 'field' it might be worth checking the case on 'ShortTitle' as it may be giving the error as there is no such field ShortTitle to compare from.

I haven't had a lot of MySQL experience yet but I hope this helps some.

Makkura

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > SELECT error: No such field - BUT query works in PHPmyadmin


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT