Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3806
| From | tony@mountifield.org (Tony Mountifield) |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: i getting this warning |
| Date | 2011-11-16 11:37 +0000 |
| Organization | Software Insight Ltd., Winchester, UK |
| Message-ID | <ja07am$6cv$1@softins.clara.co.uk> (permalink) |
| References | <616578.124.1321442274513.JavaMail.geo-discussion-forums@prmf13> <ja06lf$3b4$2@news.albasani.net> |
In article <ja06lf$3b4$2@news.albasani.net>,
The Natural Philosopher <tnp@invalid.invalid> wrote:
> sri kanth wrote:
> > mysql_fetch_row(): supplied argument is not a valid MySQL result
> > below my code:
> > <?php
> > $qs=$_REQUEST['id'];
> > mysql_connect("localhost","root","");
> > mysql_select_db("test");
> > $data=mysql_query("select * from tbl_porduct where pid=$qs");
> > $rec=mysql_fetch_row($data);
> > $pname=$rec[1];
> > $price=$rec[3];
> > $sid=session_id();
> > mysql_query("insert into tbl_spro values('$sid','$pname','$price')");
> > ?>
> >
> I am not surprised
>
> $data=mysql_query("select * from tbl_porduct where pid=$qs");
>
> is not going to win friends and influence people
>
> Try
> $data=mysql_query(sprintf("select * from tbl_porduct where pid=%d",$qs));
>
> and check whether 'tbl_porduct' should in fact be 'tbl_product'.
And also test the return value in $data before using it to try and fetch
a row.
Then test $rec to see if it actually returned you a matching row at all.
You should actually test the return status of ALL your mysql_ calls, and
not just blindly assume they will work.
Cheers
Tony
--
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
i getting this warning sri kanth <sritullimilli@gmail.com> - 2011-11-16 03:17 -0800
Re: i getting this warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-16 11:26 +0000
Re: i getting this warning tony@mountifield.org (Tony Mountifield) - 2011-11-16 11:37 +0000
Re: i getting this warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-16 06:56 -0500
Re: i getting this warning Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-16 15:11 +0000
Re: i getting this warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-16 10:41 -0500
Re: i getting this warning Arno Welzel <usenet@arnowelzel.de> - 2011-11-17 14:31 +0100
Re: i getting this warning Arno Welzel <usenet@arnowelzel.de> - 2011-11-17 14:34 +0100
Re: i getting this warning Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-18 08:02 +0000
Re: i getting this warning The Natural Philosopher <tnp@invalid.invalid> - 2011-11-17 13:39 +0000
Re: i getting this warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-17 09:01 -0500
Re: i getting this warning Arno Welzel <usenet@arnowelzel.de> - 2011-11-17 15:15 +0100
Re: i getting this warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-17 09:44 -0500
Re: i getting this warning Arno Welzel <usenet@arnowelzel.de> - 2011-11-21 14:59 +0100
Re: i getting this warning Jerry Stuckle <jstucklex@attglobal.net> - 2011-11-21 09:12 -0500
csiph-web