egturnkey Posted September 1, 2009 Share Posted September 1, 2009 Hello Friends , I've made a simple 2 php files but when i do run it, it gives error as following Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\eshtrak\z.php on line 7 ( i think there an error in WHERE catID='".$_GET['catID']."' AND productID=".$_GET['productID'] ) Here is the php code <?php include_once('config.php'); // connect 2 DB $productSQL = "SELECT * FROM product WHERE catID='".$_GET['catID']."' AND productID=".$_GET['productID']; $productresult = mysql_query($productSQL); $productrow = mysql_fetch_array($productresult); echo "{$productrow['name']}"; ?> and if you need to review the database table is as following CREATE TABLE `product` ( `productID` int(11) NOT NULL auto_increment, `catID` int(11) NOT NULL, `name` varchar(255) NOT NULL default '', `demo` varchar(255) NOT NULL default '', `description` text NOT NULL, `keywords` text NOT NULL, `compatibilities` text NOT NULL, `downloadURL` varchar(255) NOT NULL default '', `status` int(1) NOT NULL default '0', `type` int(1) NOT NULL default '0', `price` float(10,2) NOT NULL, `userID` int(11) NOT NULL default '0', `creation_date` bigint(14) NOT NULL, PRIMARY KEY (`productID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ; also if you want to review the config.php <? $dbuser = "root"; $dbhost = "localhost"; $dbpass = "art"; $dbname = "my"; @mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname); ?> Link to comment https://forums.phpfreaks.com/topic/172707-ive-created-2-php-file-but-getting-mysql_fetch_array-error/ Share on other sites More sharing options...
ignace Posted September 1, 2009 Share Posted September 1, 2009 $productresult = mysql_query($productSQL) or trigger_error('Error: ' . mysql_error()); $productrow = mysql_fetch_array($productresult); Link to comment https://forums.phpfreaks.com/topic/172707-ive-created-2-php-file-but-getting-mysql_fetch_array-error/#findComment-910341 Share on other sites More sharing options...
egturnkey Posted September 1, 2009 Author Share Posted September 1, 2009 thanks , but still getting the same error :'( Link to comment https://forums.phpfreaks.com/topic/172707-ive-created-2-php-file-but-getting-mysql_fetch_array-error/#findComment-910361 Share on other sites More sharing options...
ignace Posted September 1, 2009 Share Posted September 1, 2009 if ($productresult = mysql_query($productSQL)) { $productrow = mysql_fetch_array($productresult); } Link to comment https://forums.phpfreaks.com/topic/172707-ive-created-2-php-file-but-getting-mysql_fetch_array-error/#findComment-910366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.