php - Warning function mysql_query() and mysql_fetch_array() using TCPDF -
i'm trying print data mysql these error :
warning: mysql_query() expects parameter 1 string, resource given in .. warning: mysql_fetch_array() expects parameter 1 resource, null given in .. tcpdf error: data has been output, can't send pdf file
i have learn these following links still warning:
- warning: mysql_fetch_array() expects parameter 1 resource, boolean given in
- mysqli_fetch_array()/mysqli_fetch_assoc()/mysqli_fetch_row() expects parameter 1 resource or mysqli_result, boolean given
this code:
$con=mysql_connect('localhost','root','','bkd_rev'); $sql = 'select * tbl'; $result = mysql_query($con,$sql); if($result === false) { die(mysql_error()); } while($row = mysql_fetch_array($result)) { $id = $row['id']; $nam = $row['name']; $tbl .= '<tr> <td>'.$id.'</td><td>'.$nam.'</td><td> </tr>'; }
the right syntax mysql_query
opposite of your. documentation
mixed mysql_query ( string $query [, resource $link_identifier = null ] )
so need change to
$result = mysql_query($sql,$con);
since connection link not required if use database connection migh not use it
$result = mysql_query($sql);
you might need select database after connection
bool mysql_select_db ( string $database_name [, resource $link_identifier = null ] )
as side note advise switch either pdo
or mysqli
since mysql_*
api deprecated , no longer mantained
Comments
Post a Comment