Peter
Peter

Reputation: 1

Problem with MySQL query to recordset - possibly caused by move from MySQL 4 to MySQL 5

I have a website with a sales and wanted page, which uses a query to return all of the sales & wanted ads into a recordset. It's been working for 4-5years without incident, but suddenly stopped working on Friday. My ISP tell me they have implemented v5 of MySQL, which seems to have caused the problem.

The query is below:

$query = "select * from $table order by uidno desc limit $from,$max_results"; 
 

It's executed via the following command

$recordset = mysql_query($query);
    if($recordset == false)
    {
        echo("Could not retrieve comment. Please try later<br>");
        echo("060211<br>");
        return;

It's no longer able to load the comments into the recordset. Also the statement to populate the table is no longer populating the fields in the table correctly, though a new row is being created. The statement is below:

$inputdata = "INSERT INTO $table(date,name,email,suggestion) values('$today','$inputname','$email','$suggestion')";

And it is executed via:

$outcome = mysql_query($inputdata);

The structure of the table is as follows:

uidno int(11) extra=AUTO_INCREMENT Null=no default = none
date date default 0000-00-00
Name varchar(60)
Email varchar (60) Null=yes Default = NULL
Suggestion blob attrbutes=binary null=no

Please help - I don't understand what changes I need to make to the syntax to make these queries compatible with MYSQL v5.

Update:

I added the echo mysql_error(); and it appears to output the following:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10,10' at line 1

So this indicates an error in the syntax - but I've no idea what the error is.

Upvotes: 0

Views: 313

Answers (2)

Amree
Amree

Reputation: 2890

http://dev.mysql.com/doc/refman/5.0/en/select.html

The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).

Upvotes: 1

Allen
Allen

Reputation: 263

Column, index, stored routine, and event names are not case sensitive on any platform, nor are column aliases

so your lowercase column names in code and upper case column names in mysql structure should not be the problem.

Upvotes: 0

Related Questions