hy i'm using this code, but after submit it sometimes works sometimes dsnt, why?

$max = mysql_query("SELECT MAX(id2) FROM articles",$con);
$max3 = mysql_query("SELECT MAX(id) FROM articles",$con);
$resultsmax = mysql_fetch_array($max);
$resultsmax3 = mysql_fetch_array($max3);
$cur_auto_id =$resultsmax['MAX(id2)'] + 1;
$cur_auto_id2 =$resultsmax3['MAX(id)'] + 1;
.......
$qry= mysql_query("SELECT * FROM category", $con);
while($row=mysql_fetch_array($qry))
{




echo "<button  class='btn btn-info' onclick=window.location='stampa.php?id=".$cur_auto_id2."';>Anteprima di stampa</button>";

i know that mysql its not used anymore...but any chances to find the error ?

Member Avatar for diafol

You want to catch the error, but your're not giving yourself the chance. Why don't you litter the code with error handling? See the php manual for examples of 'or die(mysql_error())'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.