Jump to content

[SOLVED] verifying data against one table and writing data to a new table


lookee

Recommended Posts

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.

 

Link to comment
Share on other sites

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 :-)

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.