Hello,
My script uses the user 'www-data' (my webserver) when connecting to the MySQL Database, while I tell it not to.
<?php
include ('config.inc.php');
$connection = mysql_connect($host, $user, $password);
mysql_select_db($database, $connection);
$shorturls = mysql_query('SELECT shorturl FROM `' . $prefix . 'urls`');
$shorturl = rand(100000, 999999);
foreach(mysql_fetch_array($shorturls) as $row)
{
if($row['shorturl']==$shorturl) {
$shorturl = rand(100000, 999999);
}
}
echo $shorturl . '<br>';
echo urldecode($_GET['longurl']) . '<br>';
mysql_query('INSERT INTO `' . $prefix . 'urls` (shorturl, longurl)
VALUES (\'' . $shorturl . '\', \'' . urldecode($_GET['longurl']) . '\')');
echo mysql_error();
mysql_close($connection);
?>
I am sure it can read from the the $database, $host, $user and $password variables (tested). When I open the page i get this MySQL error:
Access denied for user 'www-data'@'localhost' (using password: NO)
I recently re-installed PHP and Apache, might have to do with it. This always used to work.
And please don't tell me mysql_*() stuff is deprecated, I know.
-Sydcul
SOLVED: Haha, forgot to Google this. Got some DB permission errors.