lookee Posted November 3, 2008 Share Posted November 3, 2008 How do I verify data obtained via an HTML form with one db table, and if everything matches, write data to a new table? Currently, I'm able to either validate form data in one table OR write data to ANOTHER TABLE, but when I merge all the code, I get a Warning: mysql_query() [function.mysql-query]: Access denied for user 'earlier'@'localhost' (using password: NO) in /home/earlier/public_html/now/request.php on line 93 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/earlier/public_html/now/request.php on line 93 Could not query the database: Access denied for user 'earlier'@'localhost' (using password: NO) My code: ------------ <?php session_start(); // Assign the Query $sql="SELECT * FROM shoe WHERE username='$username'"; //Execute the Query $result=mysql_query($sql); <-------------LINE 93 in Error Message if (!$result){ die ("Could not query the database: <br />". mysql_error()); //Saves Type Request to a MYSQL Database //Insert a row of information into the table "shoepay" / mysql_query("INSERT INTO shoepay VALUES('request_number','$username','$first_name','$last_name','$email','$user_id','$shoe_size','$paid_shoes','date') ") or die(mysql_error()); Header("Location: successful_payment.php"); } mysql_close(); include 'close_db.php'; ?> ---------------------------- It seems I'm opening one query but not finishing it then starting another, and I'm mixing up my "mysql_query" so that login information is getting crossed. Or something. Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/131211-solved-verifying-data-against-one-table-and-writing-data-to-a-new-table/ Share on other sites More sharing options...
waterssaz Posted November 3, 2008 Share Posted November 3, 2008 Hi, where have you set your database connection properties?. You have not passed any as the second arguement to the mysql_query(). So by default it will look for the last connection properties set in a mysql_connect(), but if it can't find any or you didn't set them anywhere then it will usef default empty parameters. In other words it will try to connect to a database using an invalid login and password. This looks like the error that you are experiencing. Hope this makes sense and helps :-) Quote Link to comment https://forums.phpfreaks.com/topic/131211-solved-verifying-data-against-one-table-and-writing-data-to-a-new-table/#findComment-681273 Share on other sites More sharing options...
lookee Posted November 3, 2008 Author Share Posted November 3, 2008 I have them in an include. Both tables are within the same database, so I figured the same connection information should work. Quote Link to comment https://forums.phpfreaks.com/topic/131211-solved-verifying-data-against-one-table-and-writing-data-to-a-new-table/#findComment-681285 Share on other sites More sharing options...
fenway Posted November 3, 2008 Share Posted November 3, 2008 Well, it's not. Quote Link to comment https://forums.phpfreaks.com/topic/131211-solved-verifying-data-against-one-table-and-writing-data-to-a-new-table/#findComment-681462 Share on other sites More sharing options...
waterssaz Posted November 4, 2008 Share Posted November 4, 2008 I have them in an include. Both tables are within the same database, so I figured the same connection information should work. Is the code above an exact copy of what you are trying to use, because forgive my ignorance but I can't see where your include file is that would make the above code work. Quote Link to comment https://forums.phpfreaks.com/topic/131211-solved-verifying-data-against-one-table-and-writing-data-to-a-new-table/#findComment-681886 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.