Jump to content

[SOLVED] Help?!? What could be wrong with this code. Probably something simple


prcollin

Recommended Posts

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)

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().

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

 

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.