prcollin Posted July 24, 2008 Share Posted July 24, 2008 Mind you the user name and password are correct. All files are in the same directory and file names are all correct. Code <?php include "clientconnect.php"; include "newclient.html"; mysql_select_db("greencut_customercenter", $con); $client_fname = mysql_real_escape_string($_POST['client_fname']); $sql = "insert into table (clients) values ('$client_fname')"; $client_lname = mysql_real_escape_string($_POST['client_lname']); $sql = "insert into table (clients) values ('$client_lname')"; $client_address = mysql_real_escape_string($_POST['client_address']); $sql = "insert into table (clients) values ('$client_address')"; $client_city = mysql_real_escape_string($_POST['client_city']); $sql = "insert into table (clients) values ('$client_city')"; $client_state = mysql_real_escape_string($_POST['client_state']); $sql = "insert into table (clients) values ('$client_state')"; $client_zipcode = mysql_real_escape_string($_POST['client_zipcode']); $sql = "insert into table (clients) values ('$client_zipcode')"; $client_phone = mysql_real_escape_string($_POST['client_phone']); $sql = "insert into table (clients) values ('$client_phone')"; $client_cphone = mysql_real_escape_string($_POST['client_cphone']); $sql = "insert into table (clients) values ('$client_cphone')"; $client_email = mysql_real_escape_string($_POST['client_email']); $sql = "insert into table (clients) values ('$client_email')"; $client_website = mysql_real_escape_string($_POST['client_website']); $sql = "insert into table (clients) values ('$client_website')"; $client_notes = mysql_real_escape_string($_POST['client_notes']); $sql = "insert into table (clients) values ('$client_notes')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added";mysql_close($con) ?> error Warning: mysql_select_db(): 2 is not a valid MySQL-Link resource in /home/greencut/public_html/forms/newclientform/newclient.php on line 7 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 10 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 10 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 13 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 13 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 16 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 16 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 19 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 19 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 22 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 22 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 25 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 25 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 28 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 28 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 32 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 32 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 35 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 35 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 38 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 38 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'greencut'@'localhost' (using password: NO) in /home/greencut/public_html/forms/newclientform/newclient.php on line 41 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/greencut/public_html/forms/newclientform/newclient.php on line 41 Warning: mysql_query(): 2 is not a valid MySQL-Link resource in /home/greencut/public_html/forms/newclientform/newclient.php on line 45 Error: Access denied for user 'greencut'@'localhost' (using password: NO) Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/ Share on other sites More sharing options...
JonnyThunder Posted July 24, 2008 Share Posted July 24, 2008 Looks like you're connecting to SQL without a password - and it's not happy about it. Would need to see how you're connecting. Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/#findComment-598694 Share on other sites More sharing options...
akitchin Posted July 24, 2008 Share Posted July 24, 2008 first of all, don't double post. i'll let it go this time, but in future, your threads will be deleted without warning. second, you're clearly failing before you even get to the queries. check that you're actually assigning the link resource to $con, and not just the result of some operation. an easy way to debug, and a great tool to use before you post here, is: exit('<pre>'.print_r(get_defined_vars(), TRUE)); this will print all current defined variables and their values, printed in an easy-to-read fashion thanks to the pre-formatted HTML tag. check what that spits back at you - put it right above the mysql_select_db(). Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/#findComment-598697 Share on other sites More sharing options...
prcollin Posted July 24, 2008 Author Share Posted July 24, 2008 ok now i get Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table (clients) values ('')' at line 1 Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/#findComment-598758 Share on other sites More sharing options...
akitchin Posted July 24, 2008 Share Posted July 24, 2008 do you have a table actually named "table"? i'm pretty sure that's a reserved string in MySQL. Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/#findComment-598762 Share on other sites More sharing options...
prcollin Posted July 24, 2008 Author Share Posted July 24, 2008 have you tried what i went on to suggest? that will help you, and frankly, i won't respond until you've done it. a link resource is a variable that contains a reference to the database connection you tried to open. $con should contain that link resource, because that's what mysql_select_db() is expecting as its second parameter (variable). if it doesn't, mysql_select_db() will trip up. yeah i did i found out my error thanks for help and it is a solved issue now Link to comment https://forums.phpfreaks.com/topic/116421-solved-help-what-could-be-wrong-with-this-code-probably-something-simple/#findComment-598763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.