Jump to content

mysql_real_escape_string() giving error


ethan6

Recommended Posts

When I try to run this code:

<?
session_start();

$username = "user";
$password = "pass";
$hostname = "localhost";
$database = "database";
$con = mysql_connect($hostname, $username, $password)
or die("Unable to connect to database.");
mysql_select_db($database, $con) 
or die("Could not select itroni5_cart");

$answer_a = mysql_real_escape_string($_POST['wysiwyg'],$con);
$answer = nl2br($answer_a);

$query="INSERT INTO answers (idquestion, username, answer) VALUES ('".$_POST['idquestion']."','".$_SESSION['username']."', '".$answer."')";
$result=mysql_query($query) or die(mysql_error());

header("Location: answers.php");
?>

 

I get this error:

 

 

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'user'@'localhost' (using password: NO) in /home/itroni5/public_html/testwysiwyg.php on line 4

 

Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/itroni5/public_html/testwysiwyg.php on line 4

 

 

any ideas? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/193623-mysql_real_escape_string-giving-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.