On 13 April 2010 10:40, Jacob Kruger <jacobk@xxxxxxxxxxxxxx> wrote: > Thanks. > > Will try it out - think the .count is just related to $arr being sort of an array of records - and think I got it out of the PHP tutorial from w3schools.com, and it's worked on other pages. > > Anyway, the following does now seem to work fine: > > $qry = mysql_query($sql); > if (mysql_num_rows($qry) > 0) > { > echo "<ul>"; > while($row = mysql_fetch_array($qry)) > { > echo "<li>" . $row['LinkName'] . " - " . $row['LinkDescription'] . " - "; > echo "<a href='" . $row['LinkURL'] . "' target='_blank'>" . $row['LinkURL'] . "</a></li>"; > } > echo "</ul>"; > } > > Thanks again > > Stay well > > Jacob Kruger > Blind Biker > Skype: BlindZA > '...fate had broken his body, but not his spirit...' > > ----- Original Message ----- > From: Ferenc Kovacs > To: Jacob Kruger > Sent: Tuesday, April 13, 2010 10:46 AM > Subject: Re: Trouble running a select query against a database, when I know the connection is working, and the data is there > > > > > > On Tue, Apr 13, 2010 at 10:36 AM, Jacob Kruger <jacobk@xxxxxxxxxxxxxx> wrote: > > I am trying to simply just loop through a set of records to spit out <li /> tags for the data therein, and on the same page, it's successfully running another query against the same connection - which I have also tried turning off just in case it was a problem with running two queries against the same connection (really don't think so), but it just tells me there are no records being returned, although I have tried simplifying the sql statement, pulling records from another table, etc. etc., and I really don't know what am doing wrong with this really simple bit of scripting: > > $qry = mysql_query("select CatName from tblCats where Id = " . $_REQUEST['id']); > $arr = mysql_fetch_array($qry); > echo "<h2>" . $arr['CatName'] . "</h2>"; > //that part works fine > $sql = "select Id, CatID, LinkName, LinkDescription, LinkURL from tblLinks where CatID = " . $_REQUEST['id'] . ";"; > //the SQL statement seems to come out fine as well if I echo it out to the browser > $qry = mysql_query($sql); > $arr = mysql_fetch_array($qry); > if ($arr.count > 0) > > > where did you get that $arr.count thingie? > you can count the result rows with mysql_num_rows > http://www.php.net/manual/en/function.mysql-num-rows.php > > Tyrael > > > > > > __________ Information from ESET NOD32 Antivirus, version of virus signature database 5023 (20100412) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > > > __________ Information from ESET NOD32 Antivirus, version of virus signature database 5024 (20100413) __________ > > The message was checked by ESET NOD32 Antivirus. > > http://www.eset.com > > Nope. Breakdown of $arr.count 1 - $arr 2 - . 3 - count 1 - $arr This is a variable which, in this instance, is a mysql result resource. Not usefully expressable as a string under normal conditions. 2 - . This is the append/concatentate operator. 3 - count In this state, this will try and find the value of the constant called 'count'. If it doesn't find one, it will assume the text of 'count'. So, this becomes something like ... "Resource id #5count" And when you test that "> 0", you get false. e.g. php -r "var_dump(fopen('./AUTOEXEC.BAT', 'rt').count);" outputs ... Notice: Use of undefined constant count - assumed 'count' in Command line code on line 1 string(19) "Resource id #5count" and ... php -r "var_dump(fopen('./AUTOEXEC.BAT', 'rt').count > 0);" outputs ... Notice: Use of undefined constant count - assumed 'count' in Command line code on line 1 bool(false) My error_reporting level is set to -1. If yours is set to E_ALL, then the E_NOTICES won't be seen on any version less than PHP6/trunk. So, first set the error reporting to -1 (to really show ALL messages) and re-run your code. You'll see the error. Regards, Richard. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php