FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » i getting this warning
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: i getting this warning [message #176016 is a reply to message #176015] Wed, 16 November 2011 11:37 Go to previous messageGo to previous message
tony is currently offline  tony
Messages: 19
Registered: December 2010
Karma:
Junior Member
In article <ja06lf$3b4$2(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)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(at)softins(dot)co(dot)uk - http://www.softins.co.uk
Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: How to get client mac address in PHP ..?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 15:23:21 GMT 2024

Total time taken to generate the page: 0.04900 seconds