0

can you help me with this code please,

<link rel="shortcut icon" href="<?php echo URL_GLOBAL; ?>graficos/logoIcon.jpg" />

<?php
$listaAJ = mysql_query("SELECT * FROM ajuste LIMIT 0,1");
$rowAJ = mysql_fetch_array($listaAJ);
?>
<title><?php echo $rowAJ['titulo']; ?><?php if($activaSeo=="si"){ echo " - ".$incTitle;}?></title>

Error: Error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /incluir/seo.php on line 5

How can I solve my error?

Thanks.

jmginer
  • 353
  • 1
  • 2
  • 7

2 Answers2

2

Your query cannot execute. I suggest you pop in some error-reporting, to get the full SQL-error message:

$listaAJ = mysql_query("SELECT * FROM ajuste LIMIT 0,1") or die(mysql_error());

The mysql_* functions are also deprecated. You shall use either mysqli_* or, preferable, PDO.

Eric
  • 17,987
  • 2
  • 32
  • 39
0

You can have:

$listaAJ = mysql_query("SELECT * FROM ajuste LIMIT 0,1");
if (!$listaAJ) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

With the if block you can check if some records were actually returned. If it scales through that block, you can go on to use the result(s).

Use mysqli_query or PDO::query instead. The mysql_* functions is deprecated!

IROEGBU
  • 917
  • 19
  • 33