Hi
I wrote a php website a few years ago using php4, the host has now upgraded to php5 and im getting a few errors.
The one i cant resolve is...
Notice: Undefined index: river in
on the line... $river = $_REQUEST['river'];
I think river is coming from... <select id="river" name="river" tabindex="15">
The code still works but im getting an error on the screen
Any help would be very much appreiated.
Many Thanks
PHP5 upgrading issue
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: PHP5 upgrading issue
Either turn off notices, or better would be something like:
Code: Select all
$river = isset($_REQUEST['river']) ? $_REQUEST['river'] : '';(#10850)
Re: PHP5 upgrading issue
Thanks Christopher
Im now getting the error...
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5
The lines are...
$getRiverId = mysql_query("SELECT River_id FROM tblRivers WHERE River_name = '$river'");
$id = mysql_result($getRiverId,0,0);
Im getting the error on the second line
Any ideas
Thanks again
Im now getting the error...
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5
The lines are...
$getRiverId = mysql_query("SELECT River_id FROM tblRivers WHERE River_name = '$river'");
$id = mysql_result($getRiverId,0,0);
Im getting the error on the second line
Any ideas
Thanks again
Re: PHP5 upgrading issue
Try to get the id like this:
Might be just a newbie advise but.. Worth a try.. ;P
Code: Select all
$getRiverId = mysql_query("SELECT * FROM tblRivers WHERE River_name = '$river'");
$result = mysql_fetch_array($getRiverId);
$id = $result['River_id'];
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: PHP5 upgrading issue
You are making an assumption with your code that the REQUEST var 'river' is always set. That is why you are now getting errors. The code arborint posted checks to see if it is set and if it is grabs it, otherwise it sets $river to an empty string. When you push that empty string to your query the result set is coming back empty, null or void which is why you are having problems walking your way through it.
I would put the query inside a conditional check for the var you are expecting ('river' in this case) then, if 'river' is set, handle the query, otherwise notify the user that they need to select something for 'river'.
I would put the query inside a conditional check for the var you are expecting ('river' in this case) then, if 'river' is set, handle the query, otherwise notify the user that they need to select something for 'river'.