TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2008, 05:18 AM   #1 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 368
Thanks: 44
Aaron is on a distinguished road
Default Query Debugging

MySQL hates me.
query:
HTML Code:
SELECT * FROM `aaron_eglast`.`egle_post` WHERE `slug`=`html` AND `category`=`HTML` LIMIT 1
Error:
Code:
MySQL said:
#1054 - Unknown column 'html' in 'where clause'
Table XML:
<aaron_eglast>
<!-- Table egle_post -->
<egle_post>
<id>1</id>
<author>Aaron</author>
<last_updated>1</last_updated>
<content>*snip*</content>
<title>Html</title>
<slug>html</slug>
<meta_title>Beginner HTML Tutorial Series</meta_title>
<order>1</order>
<category>HTML</category>
<next>na</next>
<previous>na</previous>
</egle_post>
</aaron_eglast>

so... what is going on here?
__________________

I feel better hating IE.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 08-09-2008, 06:07 AM   #2 (permalink)
The Gregarious
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Cana'derr
Posts: 653
Thanks: 24
delayedinsanity is on a distinguished road
Default

You're using backticks. Use single quotes.

Code:
SELECT *
FROM `aaron_eglast`.`egle_post`
WHERE `slug`='html' AND `category`='HTML'
LIMIT 1
delayedinsanity is offline  
Reply With Quote
Old 08-09-2008, 07:18 PM   #3 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 368
Thanks: 44
Aaron is on a distinguished road
Default

Mysql Still hates me:
Code:
	$query = "
		SELECT `slug` , `title`
		FROM `aaron_eglast`.`egle_post`
		WHERE `category` = 'HTML'
		ORDER BY `order` ASC";
	$query = mysql_query($query);
	$q = mysql_fetch_array($query);
			if (mysql_num_rows($q) == 0)
			throw new exception('For some reason, the other tutorials in this category could not be found.
			 They will not be displayed at the side of this page.');
The query returns properly in PHPmyAdmin, yet it throws an error on the page.
__________________

I feel better hating IE.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 08-09-2008, 07:46 PM   #4 (permalink)
The Addict
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 243
Thanks: 5
Kalle is on a distinguished road
Default

Its because the if conditional should be:

PHP Code:
if(!mysql_num_rows($query)) 
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 08-10-2008, 12:47 AM   #5 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 368
Thanks: 44
Aaron is on a distinguished road
Default

This is why you are my idol O.o
__________________

I feel better hating IE.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:58 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0