PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP 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:
  #1  
Old October 19th, 2011, 12:12 AM
tumbleweed tumbleweed is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 1 tumbleweed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 51 m 20 sec
Reputation Power: 0
Mysql & other databases - Mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

Hey everyone. I am just trying to figure out what is wrong with my program. I am pretty sure it is some simple syntax error but I am just not sure. Here is the code:

this is the error that is outputted:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in ...

mycms.php
PHP Code:
<?php
class priceCMS{

    var 
$host;
    var 
$username;
    var 
$password;
    var 
$table;
    var 
$connect;

    public function 
priceCMS($host,$username,$password,$table)
    {
        
        global 
$db_values;
        
        
$connect mysql_connect($host,$username,$password);
    
        
        if(!
$connect)
        {
        die(
'Could not connect to database:'.mysql_error());
        }

        
mysql_select_db($username,$connect
        or die(
'Could not select database'.mysql_error());
        
        
$db_values=mysql_query("SELECT * FROM ".$table);
    }

public function 
delete_form()
    {
        
        
$db_values=mysql_query("SELECT * FROM ".$table);
        echo 
"
        <table border='1' width='100%'>
        <tr>
        <th width='4%' class='br'> </th>
        <th width='27%' class='br'>Item</th>
        <th width='27%' class='br'>Price</th>
        <th width='27%' class='br'>Category</th>
        <th width='15%' class='br'>Subcategory</th>
        </tr>
        "
;
    
/* ERROR LINE ....*/    
        
while($db_rows mysql_fetch_array($db_values,MYSQL_ASSOC))
        {
            if(
$counter%== 0)
            {
                
$rowcolor="greyrow";
            }
            else
            {
                
$rowcolor="whiterow";
            }
            
$counter++;
            echo 
"<tr id=".$rowcolor." ><td>";
            echo 
"<input type=\"checkbox\" name=\"".$db_rows['id']."\" />";
            echo 
"</td><td>";
            echo 
$db_rows['item']
            . 
"</td><td>"
            
$db_rows['price']
            . 
"</td><td>"
            
$db_rows['category']
            . 
"</td><td>"
            
$db_rows['subcategory'];
            echo 
"</td></tr>";
        }
        
        echo 
"
        </tr>
        </table>
        "
;
    }
}
?>


This is the file that instantiates the object

index.php
PHP Code:
<?php
include_once("mycms.php");

$host "localhost";
$username "user_name";
$password "password";
$table "price_table";

$p = new priceCMS($host,$username,$password,$table);

?>
<head>
</head>

<body>
<?php
$p
->delete_form();
?>

</body>


I am pretty new to mysql and php. I hope you guys can show me where I am making the logic mistakes. thx in advance.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Mysql & other databases - Mysql_fetch_array(): supplied argument is not a valid MySQL result resource in


Developer Shed Advertisers and Affiliates


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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap