Re: mysql if statement to php

From: Date: Mon, 14 Apr 2003 07:37:03 +0000
Subject: Re: mysql if statement to php
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-27075@lists.php.net to get a copy of this message
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 */

« previous php.db (#27075) next »