Code:
<?php
define( "DATABASE_SERVER", "blah" );
define( "DATABASE_USERNAME", "blah" );
define( "DATABASE_PASSWORD", "blah" );
define( "DATABASE_NAME", "blah" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME, DATABASE_PASSWORD) or die(mysql_error());
mysql_select_db( DATABASE_NAME );
$sql = 'SELECT * FROM `users`';
$result = mysql_query($sql) or die ('Error: '.mysql_error ());
while($row = mysql_fetch_array($result))
{
$hPassword = hash ( sha256, $row['password']);
$query = "INSERT INTO new_users (username, password)
VALUES('".$row['username']."','$hPassword')";
$result = mysql_query($query);
}
?>
I keep getting this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/g/m/a/gmaster1440/html/vote/convertdb.php on line 20
Yes, credentials are correct, yes 'users' table exists.
Please guys, this is due for a big project tomorrow. I'll appreciate any help I can get.