markymark Posted September 28, 2010 Share Posted September 28, 2010 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\New\cartnisya.php on line 15 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\New\cartnisya.php on line 74 CODE $db = mysql_connect("localhost", "root",""); mysql_select_db("vinnex",$db); mysql_query("Delete From temptransaction",$db); //mysql_query("Delete From temporderdetails",$db); $Username = $_POST['Username']; $Password = $_POST['Password']; $result = mysql_query("Select TransNo From transaction", $db); $myrow = mysql_fetch_array($result); if ($myrow=='') { $TransNo='1000'; $q = mysql_query("Select Username, Lastname, Firstname From customer where Username=$Username, Lastname=$Lastname, Firstname=$Firstname "); $myrow1 = mysql_fetch_array($q); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $name = $Firstname. " ".$Lastname; $sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1) or die(mysql_error()); } else { $sql = mysql_query("Select max(TransNo) maxTransNo From transaction", $db); $myrow1 = mysql_fetch_array($sql); $orderno = $myrow1['maxTransNo']+1; $sql = mysql_query("Select Username, Lastname, Firstname From customer where Username=$Username, Lastname=$Lastname, Firstname=$Firstname"); $myrow1 = mysql_fetch_array($sql); $Username = $myrow1['Username']; $Firstname = $myrow1['Firstname']; $Lastname = $myrow1['Lastname']; $Date = date('m/d/y'); $sql1 = " INSERT INTO temptransaction (TransNo, Username, Firstname, Date) VALUES ('$TransNo', '$Username', '$Firstname', '$Date')"; $result = mysql_query($sql1) or die(mysql_error()); } please help masters im just newbie in php. Link to comment https://forums.phpfreaks.com/topic/214585-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/ Share on other sites More sharing options...
Pikachu2000 Posted September 28, 2010 Share Posted September 28, 2010 Your query is failing and returning a boolean FALSE to mysql_fetch_array(). All string data should be in single quotes in the query strings. i.e. WHERE username = '$username' , etcetera. Link to comment https://forums.phpfreaks.com/topic/214585-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1116602 Share on other sites More sharing options...
coupe-r Posted September 28, 2010 Share Posted September 28, 2010 Shouldn't the query also read: Select Username, Lastname, Firstname From customer where Username='".$Username."' AND Lastname='".$Lastname."' AND Firstname='".$Firstname."' You are missing the AND as well as quotes. Link to comment https://forums.phpfreaks.com/topic/214585-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1116623 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.