Re: mysql if statement to php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 14 April 2003 09:46, JeRRy wrote:
> Hi,
>
> I tried you 'as' example and got this:
>
> Warning: mysql_fetch_array(): supplied argument is not
> a valid MySQL result resource in message.php
>
> My code is this:
>
> $qr = mysql_query("SELECT IF( emailerror = ('y' ),
> 'error yes', 'do nothing' ) AS answer FROM tipping
> WHERE sid =
> '$sid'");
> $result = mysql_query($qr);
> $row = mysql_fetch_array($result);
> echo $row['answer'];

Why are you using mysql_query() twice?

$qr = "SELECT IF( emailerror = ('y' ),
'error yes', 'do nothing' ) AS answer FROM tipping
WHERE sid = '$sid'";
$result = mysql_query($qr) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['answer'];

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
Quit worrying about your health.  It'll go away.
		-- Robert Orben
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux