Re: mysql_result
| From: | Shahmat Dahlan | Date: | Tue, 20 Mar 2001 15:13:59 +0000 |
| Subject: | Re: mysql_result | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7647@lists.php.net to get a copy of this message | ||
That didn't quite work, I tried using single quote enclose within double
quotes and it works.
$sqlstmt="SELECT * FROM dept WHERE shortname='$shortname'";
Thanks anyway
ben wrote:
> On Tue, 20 Mar 2001, Shahmat Dahlan wrote:
>
> > I'm trying to use mysql_result to extract data from one particular field
> > in a record. So I suppose the most viable solution is to use
> > mysql_result. But when I do this:
> >
> > $sqlstmt="SELECT * FROM dept WHERE shortname=$shortname";
> > $result=mysql_query($sqlstmt);
> > $temp=mysql_result($result,0,"shortname"); <-- This will give me an
> > error
> >
> > Did I do anything wrong here?
> >
> > Thanks in advance.
> > Shahmat
>
> The problem is that the query is wrong. Try
> $sqlstmt="SELECT * FROM dept WHERE shortname=\"$shortname\"";
>
> (you need to send quotes to mysql if the type of shortname in your
> database is text or the like, that's why there's the \"$var\")
>
> --
> Ben
> History is curious stuff You'd think by now we had enough Yet the fact
> remains I fear They make more of it every year.