mysql_data_seek(): Offset 1 is invalid error

Hope someone can shed some light on this error.

Basically everything was working fine until a few days ago, when the site went down, and the guy who did the hosting seems to have vanished into thin air.

Unfortunately there wasn’t a copy of the database, so I’ve been involved with trying to get it all back online on some new hosting.

It was going OK - used the code from the admin pages to add records as a guide to recreate the tables and fields etc - but we have an error at the top of each page :

http://www.mph.uk.com/

If anyone can shed any light on what that’s about, and hopefully how to fix it, that would be much appreciated.

Sorry I don’t know what version of SQL is running on the new hosting, as someone else is doing that, but I’ll try to find out.

I know I created the database structure and mailed it over to someone who uploaded it, and that was just done in phpMyAdmin.

Thanks guys - good to know that was where the problem was.

I’ll mention turning off the display of errors to the guy who’s now looking after the hosting.

Also its just a warning, and warnings/errors should really be turned off on a live hosting environment. Ask your host to set the error reporting level to 0.

On most environments this can also be done through a htaccess construction like:

php_value display_errors Off

Although it’s better not to display them on a live environment, you should fix warning messages to make sure your application is working properly and also to avoid huge error logs (unless it’s rotated by size, but still, errors/warnings are there to be fixed and not ignored ;)).

If there were 2 matching records for $raModels before, it would have worked (it would just pulled the second result instead of the first).

data_seek is 0-indexed (meaning that the records start at 0, not 1), so this seems to be the correct fix, although the line is pointless unless you’ve referenced other parts of the $raModels result before (The internal pointer starts at 0 automatically)

Thank you!

I think from that I may have spotted it - just between the </head> and <body> tags was this bit of PHP :

<?php 
mysql_data_seek($rsModels,1); 
?> 

which I just changed to :

<?php 
mysql_data_seek($rsModels,0); 
?> 

And that seems to have got rid of the error at least :

http://www.hpwebdesign.co.uk/mph/index.php

Does that sound about right?

Its all a bit unfortunate, as I did the site ages ago, but it turns out that their hosting was held by a one man show, who has completely vanished, leaving the site lost somewhere.

So I’ve been trying to recreate the database structure, as we didn’t have a copy of it. (lesson learned there!)

So its still a bit of mystery why it was all working before with the 1 there rather than the 0.

Also, it might be turned on in your code with the error_reporting() command.

Warnings may or may not be problems you need to fix. It depends on the application, and how well it was written.

You’re probably trying to find the first record in an entry - which would be row 0, not row 1.

Show us index.php’s relevant code lines (IE: From the point you pull your query, to the point you use it)

I guess maybe its some rare or complicated error that means nothing to anyone then.

Oh well, just my luck! :slight_smile:

that’s a php error, not a mysql error

php is trying to display something that doesn’t exist, probably some query failed to run properly

let’s move this thread to the php forum