darkfreaks Posted July 14, 2012 Share Posted July 14, 2012 so i read that if mysql_num_rows ==0 that it will return a offset error is there a way to correct this? while still checking if the field does not exist. Quote Link to comment https://forums.phpfreaks.com/topic/265680-mysql_data_seek-help/ Share on other sites More sharing options...
gizmola Posted July 14, 2012 Share Posted July 14, 2012 I'm not sure what you are asking here. mysql_num_rows returns the number of rows in a result set. Quote Link to comment https://forums.phpfreaks.com/topic/265680-mysql_data_seek-help/#findComment-1361538 Share on other sites More sharing options...
darkfreaks Posted July 14, 2012 Author Share Posted July 14, 2012 I'm not sure what you are asking here. mysql_num_rows returns the number of rows in a result set. ysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to a MySQL fetch function, such as mysql_fetch_assoc(), would return that row. row_number starts at 0. The row_number should be a value in the range from 0 to mysql_num_rows() - 1. However if the result set is empty ( mysql_num_rows() == 0), a seek to 0 will fail with a E_WARNING and mysql_data_seek() will return FALSE. however if i enter somepage.php?modelID=0 somepage.php?modelID=NULL somepage.php?modelID= it just returns an empty model page which is fine. but if i enter something which isnt in the database i get an offset error like somepage.php?modelID=1 Quote Link to comment https://forums.phpfreaks.com/topic/265680-mysql_data_seek-help/#findComment-1361540 Share on other sites More sharing options...
gizmola Posted July 14, 2012 Share Posted July 14, 2012 I think it's fairly obvious that if the result set is empty, trying to move the result set pointer, is not something you should attempt. Quote Link to comment https://forums.phpfreaks.com/topic/265680-mysql_data_seek-help/#findComment-1361541 Share on other sites More sharing options...
darkfreaks Posted July 14, 2012 Author Share Posted July 14, 2012 i fixed it just so you know the count function was completely backwards. i coded it in an incremental for loop and i have no issues now Quote Link to comment https://forums.phpfreaks.com/topic/265680-mysql_data_seek-help/#findComment-1361547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.