Visa ett inlägg
Oläst 2012-01-26, 17:19 #1
iostreams avatar
iostream iostream är inte uppkopplad
Medlem
 
Reg.datum: Feb 2008
Inlägg: 92
iostream iostream är inte uppkopplad
Medlem
iostreams avatar
 
Reg.datum: Feb 2008
Inlägg: 92
Det egentliga problemet är den icke-existerande felhanteringen:

PHP-kod:
mysql_fetch_assoc(mysql_query("SELECT ...")); 
Citat:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Detta betyder helt enkelt att mysql_query() returnerade något annat än en resource, vilken skickades in till mysql_fetch_assoc, som bara förväntar en resource.

Citat:
array mysql_fetch_assoc ( resource $result )
Citat:
For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.
Ponera istället följande kod som exempel:
PHP-kod:
$sql "SELECT ...";
$query mysql_query($sql);
if (
$query === FALSE) {
    
error_log('MySQL Error: 'mysql_error());
    
header('HTTP/1.1 503 Service Temporarily Unavailable');
    echo 
'<h1>Ops, error!</h1>';
    return;
}

$res mysql_fetch_assoc($query); 
iostream är inte uppkopplad   Svara med citatSvara med citat