shadrxninga Posted January 5, 2011 Share Posted January 5, 2011 I have a problem where I am getting these errors after a form has been submitted from join.html Here are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Here is the insert.php file http://pastebin.com/EVtgidQC And the join.html file - http://pastebin.com/hqDtGLe5 How would I fix those errors - I got the code from http://forum.hey0.net/showthread.php?tid=2509 The form is at scswc.com/join.html if you want to look at it. I really want to get this working so if you need any more info to help fix it just ask thanks! Quote Link to comment https://forums.phpfreaks.com/topic/223426-mysql-errors-in-insertphp/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2011 Share Posted January 5, 2011 You don't have a valid mysql connection at that time you are calling mysql_real_escape_string() (and it is attempting to create a connection using default values, which doesn't work.) You must make a mysql connection before you call that function. Quote Link to comment https://forums.phpfreaks.com/topic/223426-mysql-errors-in-insertphp/#findComment-1154982 Share on other sites More sharing options...
shadrxninga Posted January 5, 2011 Author Share Posted January 5, 2011 So how would i fix that? - This is the first time I have Used php Do I need to Move mysql_real_escape_string() to after the database settings or move the database settings before mysql_real_escape_string() Or do I need to do something else? Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/223426-mysql-errors-in-insertphp/#findComment-1154983 Share on other sites More sharing options...
revraz Posted January 5, 2011 Share Posted January 5, 2011 Either one of those solutions would work. Just give it a try, that's how you learn. Quote Link to comment https://forums.phpfreaks.com/topic/223426-mysql-errors-in-insertphp/#findComment-1155021 Share on other sites More sharing options...
Zurev Posted January 5, 2011 Share Posted January 5, 2011 So how would i fix that? - This is the first time I have Used php Do I need to Move mysql_real_escape_string() to after the database settings or move the database settings before mysql_real_escape_string() Or do I need to do something else? Thanks again. Well you're calling the function check_input at the top, which calls mysql_real_escape_string. Which requires a database connection be open and working. So your function declaration can be up there, however where you check your POST input has to be after your mysql_connect declaration. Quote Link to comment https://forums.phpfreaks.com/topic/223426-mysql-errors-in-insertphp/#findComment-1155044 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.