Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] php class issue


[SOLVED] php class issue

Reply
  #1 (permalink)  
Old 03-17-08, 08:34 PM
vistaboy vistaboy is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] php class issue

okay i am getting the error

Could not perform query (SELECT name, value FROM config WHERE name=(skey) LIMIT 0,1), MySQL Said: Unknown column 'skey' in 'where clause'

my code in my db class is

Code:
function get_config($config_name)
	{

		$configs = $this->query("SELECT name, value FROM config WHERE name=(". $config_name .") LIMIT 0,1");
		$configrow = $this->fetch($configs,0);
		return $configrow['value'];

	}

and were i am using the class in anther class

$this->db->get_config(skey)


i have also tryed

Code:
	{

		$configs = $this->query("SELECT name, value FROM config WHERE name='". $config_name ."' LIMIT 0,1");
		$configrow = $this->fetch($configs,0);
		return $configrow['value'];

	}
but that gives me this error

Could not perform query (), MySQL Said: Query was empty
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-17-08, 09:09 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
try
PHP Code:

$configs $this->query("SELECT `name`, `value` FROM `config` WHERE `name`= '"$config_name ."' LIMIT 0,1"); 

If that doesnt work, make sure that the field names are correct, ie the case sensitivity of them
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-17-08, 09:21 PM
vistaboy vistaboy is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
okay that did not work it just gives me the error "Could not perform query (), MySQL Said: Query was empty"

and yes all the tables are names are right and all but i did find this out

Code:
function get_config($config_name)
    {

        $configs = $this->query("SELECT name, value FROM config WHERE name=$config_name LIMIT 0,1");
        $configrow = $this->fetch($configs,0);
        return $configrow['value'];

    }
that gives me this error
Could not perform query (SELECT name, value FROM config WHERE name=skey LIMIT 0,1), MySQL Said: Unknown column 'skey' in 'where clause'


so that mite help you help me fix this.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-17-08, 09:23 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by vistaboy View Post
okay that did not work it just gives me the error "Could not perform query (), MySQL Said: Query was empty"

and yes all the tables are names are right and all but i did find this out

Code:
function get_config($config_name)
    {

        $configs = $this->query("SELECT name, value FROM config WHERE name=$config_name LIMIT 0,1");
        $configrow = $this->fetch($configs,0);
        return $configrow['value'];

    }
that gives me this error
Could not perform query (SELECT name, value FROM config WHERE name=skey LIMIT 0,1), MySQL Said: Unknown column 'skey' in 'where clause'


so that mite help you help me fix this.
You havent actually changed the line
look above. its still the same as the one in your first post
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-17-08, 09:26 PM
vistaboy vistaboy is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
okay if you re-read my post it says "okay that did not work it just gives me the error "Could not perform query (), MySQL Said: Query was empty" "

and that other bit of code was anther test i did that gave me a diff error to the one i have been getting of Could not perform query (), MySQL Said: Query was empty.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-17-08, 09:34 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Thats because you have 0,1 as your limit. anything with 0 returns an empty result
Taken from MYSQL REF:
Quote:
LIMIT 0 quickly returns an empty set. This can be useful for checking the validity of a query. When using one of the MySQL APIs, it can also be employed for obtaining the types of the result columns. (This trick does not work in the MySQL Monitor (the mysql program), which merely displays Empty set in such cases; you should instead use SHOW COLUMNS or DESCRIBE for this purpose.)
f
PHP Code:

unction get_config($config_name)
    {

        
$configs $this->query("SELECT `name`, `value` FROM `config` WHERE `name`= '"$config_name ."' LIMIT 1");
        
$configrow $this->fetch($configs,0);
        return 
$configrow['value'];

    } 
should work though
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName

Last edited by Jay6390; 03-17-08 at 09:46 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-18-08, 12:24 AM
vistaboy vistaboy is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
okay this is a very hard one to fix my the look as that did not fix it :'( will it be okay if i PM you my full code and you can make the fix's so you can test it all and see for you self it will make it easier???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-18-08, 12:27 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
You can post the file here unless it has any sensitive data in it
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 03-18-08, 12:33 AM
vistaboy vistaboy is offline
Newbie Coder
 
Join Date: Mar 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Jay6390 View Post
You can post the file here unless it has any sensitive data in it
hmm i will not want to show the full code here, so..... but if i upload them as a html so you can read it and i post a link to it can you find whats wrong and help me?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 03-18-08, 12:35 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah I guess so
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP MySQL Scripting Issue Rattlecage Demon PHP 3 12-13-05 11:37 AM
php mail apache and postfix issue tgar2004 PHP 3 11-04-05 02:32 AM
Need Help In PHP Programming for a single code suggestion !! CyberRomeo PHP 1 11-27-04 11:38 AM
PHP class security maldiv_f PHP 1 09-22-04 09:17 AM
How to convert php generated pages to SE friendly HTML or PHP(SE friendly) -CLASS 101 crippled PHP 1 11-16-03 07:37 AM


All times are GMT -5. The time now is 10:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.