Re: Having a DUH Moment with mysql_fetch_array
| From: | Frank M. Kromann | Date: | Tue, 10 May 2005 04:42:06 +0000 |
| Subject: | Re: Having a DUH Moment with mysql_fetch_array | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-39401@lists.php.net to get a copy of this message | ||
Hi Jim,
echo cannot display the content of an array or object. try print_r() or
var_dump()
- Frank
> Ok,
>
>
>
> I'm a PHP newbie and I'm having a problem. All I want to do is parse
> some information out of a database and send someone and email stating
> that their posting has been approved.
>
>
>
> I've verified that my SQL is indeed returning the correct value for
> $key, but when I go to fetch the array for the row so that I can
extract
> the pertinent tidbits of information from that row, I get nada. My
> troubleshooting echo statements give me the following out put. I've
> included the actual snippet of code below.
>
>
>
> 54
> SELECT * FROM jobs WHERE pk_job = '54'
> Resource id #4
> Array
>
> 0
>
>
>
>
>
> //use the date to find the record we're looking for approved but not
yet
> posted
>
> $findkey = "SELECT pk_job from jobs WHERE (display = 'Yes') AND
> (approval_stamp = '$matchnow') AND (posted IS NULL)";
>
> list($getkey) = mysql_fetch_row(mysql_query ($findkey));
>
> $key = ($getkey);
>
> echo $key; //note this is returning the correct and expected value
>
> echo "<br>";
>
> // now that we have the key lets get the row
>
> $query = "SELECT * FROM jobs WHERE pk_job = '$key'";
>
> echo $query; //note this is apparently behaving correctly and gives me
a
> correct result when executed from the command line
>
> echo "<br>";
>
> $result = mysql_query($query);
>
> echo $result;
>
> echo "<br>";
>
> //make array
>
> $row = mysql_fetch_array ($result);
>
> echo $row;
>
>
>
> I'm pretty sure that this is a "DUH!" moment, but I'm not sure quite
> what it is that I've done. I copied the code from another thing that I
> wrote a while back that's working fine and only changed SQL statements
> to reflect their new purpose in life.
>
>
>
> TIA,
>
>
>
> Jimi
>
>
>
>
>
> If computers get too powerful, we can organize them into a committee --
> that will do them in. -- Bradley's Bromide
>
>
>
>