plecostomus
asked on
PHP Error
I am not sure what is wrong with the code below, but when ever I attempt to execute it I get the following error:
According to the PHP manual, I have mysql_fetch_assoc() written correctly. Not sure why this error is being thrown.
PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in mysql.main.php on line 17
According to the PHP manual, I have mysql_fetch_assoc() written correctly. Not sure why this error is being thrown.
<?php
// require the configurations file
require(dirname(__FILE__) . "/configurations/config.inc.php");
// open connection to mysql - source and destination
$mysql_source_link_id = mysql_connect($argv[1], mysql_user, mysql_user_password);
$mysql_destination_link_id = mysql_connect(destination_mysql_host, mysql_user, mysql_user_password);
// open the databases for both - source and destination mysql instances
$mysql_database_source = mysql_select_db($argv[2], $mysql_source_link_id);
$mysql_database_destination = mysql_select_db(destination_database_name, $mysql_destination_link_id);
// execute the select statement on the source
$query_select = mysql_query($sql_select, $mysql_source_link_id);
for ($i=0; $i < ($row = mysql_fetch_assoc($query_select)); $i++) {
echo $row["world_id"] . "\n";
echo $row["room_id"] . "\n";
echo $row["player_id"] . "\n";
echo $row["timestamp"] . "\n";
echo $row["is_blocked"] . "\n";
echo $row["message"] . "\n";
}
mysql_free_result($query_select);
// close connection to mysql - source and destination
mysql_close($mysql_destination_link_id);
mysql_close($mysql_source_link_id);
?>
I don't see '$sql_select' defined anywhere in that code. Your 'mysql_query()' won't work without it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.