[PHP] QUery success, but blank results/variables
Hello everyone..tryin to run this qry against a mysql db, but after it runs, it doesn't assign anything to the variables as it should. If i return all rows, and spit out each record in the result in an array, i have the same problem, but have 24 'blank' records instead of 1. Any ideas? Thanks for any input. I tried doing a print mysql_error(); after the query and the result, but it doesn't return anything. Column names, db name, and WHERE clause are all spelled correctly, and the $currenttaskid is populated (as 1)... $detailqry = "SELECT id, parentitemid, itemtypeid, itemstatusid, itemlevelid, shortdescription, createdby_memberid, assignedto_memberid, completedby_memberid, createddate, assigneddate, estcompletiondate, completeddate, projectid, lastuserid, lastdate FROM item WHERE id=$currenttaskid"; $result = mysql_query($detailqry) or die("Failed finding task details"); $taskid = $result["id"]; $taskparentitemid = $result["parentitemid"]; $taskitemtypeid = $result["itemtypeid"]; $taskitemstatusid = $result["itemstatusid"]; $taskitemlevelid = $result["itemlevelid"]; $taskshortdescription = $result["shortdescription"]; $createdbyid = $result["createdby_memberid"]; $assignedtoid = $result["assignedto_memberid"]; $completedbyid = $result["completedby_memberid"]; $taskcreateddate = $result["createddate"]; $taskassigneddate = $result["assigneddate"]; $taskestcompletiondate = $result["estcompletiondate"]; $taskcompleteddate = $result["completeddate"]; $taskprojectid = $result["projectid"]; $tasklastuserid = $result["lastuserid"]; $tasklastdate = $result["lastdate"]; mysql_free_result($result); -IrishBiotch [EMAIL PROTECTED] _ Join the worlds largest e-mail service with MSN Hotmail. http://www.hotmail.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] QUery success, but blank results/variables
Hi, Tuesday, September 10, 2002, 1:41:23 PM, you wrote: PH> Hello everyone..tryin to run this qry against a mysql db, but after it runs, PH> it doesn't assign anything to the variables as it should. If i return all PH> rows, and spit out each record in the result in an array, i have the same PH> problem, but have 24 'blank' records instead of 1. Any ideas? Thanks for any PH> input. I tried doing a print mysql_error(); after the query and the result, PH> but it doesn't return anything. Column names, db name, and WHERE clause are PH> all spelled correctly, and the $currenttaskid is populated (as 1)... PH> $detailqry = "SELECT id, parentitemid, itemtypeid, itemstatusid, PH> itemlevelid, shortdescription, PH> createdby_memberid, assignedto_memberid, completedby_memberid, createddate, PH> assigneddate, PH> estcompletiondate, completeddate, projectid, lastuserid, lastdate FROM item PH> WHERE id=$currenttaskid"; PH> $result = mysql_query($detailqry) or die("Failed finding task details"); PH>$taskid = $result["id"]; PH>$taskparentitemid = $result["parentitemid"]; PH>$taskitemtypeid = $result["itemtypeid"]; PH>$taskitemstatusid = $result["itemstatusid"]; PH>$taskitemlevelid = $result["itemlevelid"]; PH>$taskshortdescription = $result["shortdescription"]; PH>$createdbyid = $result["createdby_memberid"]; PH>$assignedtoid = $result["assignedto_memberid"]; PH>$completedbyid = $result["completedby_memberid"]; PH>$taskcreateddate = $result["createddate"]; PH>$taskassigneddate = $result["assigneddate"]; PH>$taskestcompletiondate = $result["estcompletiondate"]; PH>$taskcompleteddate = $result["completeddate"]; PH>$taskprojectid = $result["projectid"]; PH>$tasklastuserid = $result["lastuserid"]; PH>$tasklastdate = $result["lastdate"]; PH> mysql_free_result($result); PH> -IrishBiotch PH> [EMAIL PROTECTED] PH> _ PH> Join the worlds largest e-mail service with MSN Hotmail. PH> http://www.hotmail.com You need to do this: if($result = mysql_query($detailqry)){ $row = mysq_fetch_array($result); } else{ echo "Error: Failed finding task details ".mysql_error(); } All your fields will be in the array $row. $result is just an identifier not the actual result set. -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] QUery success, but blank results/variables
If you've typed your code in accurately then... > $detailqry = "SELECT id, parentitemid, itemtypeid, itemstatusid, [etc] > $result = mysql_query($detailqry) or die("Failed finding > task details"); somewhere in about here you want to have something like: $sqldata = mysql_fetch_array($result); >$taskid = $result["id"]; [etc] ... and if you are doing a query that will return more than one row then you should also look at some sort of looping mechanism to step through your result set. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php