Re: i getting this warning [message #176016 is a reply to message #176015] |
Wed, 16 November 2011 11:37 |
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
|
|
|