PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
i got this error and i really have no idea to solve that problem. here my code:
From the code I would think that the query itself is sporting an error or the connect to the database is not working but I think the object would handle that error.
BTW I don't like the if construct without {} . Bad readability even though you can do it like this.
d11wtq wrote:You would have indentified this issue yourself if you'd used the mysql_error() function in a die() statement like so (this is good practice):
include "mysql.php";
$mydbcon = new db_sql();
$mydbcon->connect();
$sql = "SELECT max(id) FROM order";
$result = mysql_query($sql) or die(mysql_error());
if (isset($result))
{
$maxid = mysql_fetch_row($result);
if ($maxid == false)
$maxid = 1;
else
$maxid = $maxid + 1;
}
else
$maxid = 1;
You might want to add those to your database connection class too
Just wanted to add that this is only good practice whilst developing, when you "go live" it is a bad thing to leave the "die(mysql_error())" in as it will give any user who receives an error invaluable information about your data schema and application.