Click to See Complete Forum and Search --> : Adding data and searching for data


LearnGreekToday
10-11-2006, 12:32 PM
I have a simple database setup.. I also have a form for adding data to my database but am unable to get the form/script to works here is the processing script:

<?
$DBhost = "localhost";
$DBuser = "user";
$DBpass = "password";
$DBName = "dbname";
$table = "tname";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");

@mysql_select_db("$DBName") or die("Unable to select database $DBName");

$sqlquery = "INSERT INTO $table VALUES('custname','custacct','prim_tect','prim_t_phone',
'prim_t_cell','prim_t_local','back_tech','back_t_phone','back_t_cell','back_t_local','rtr_inet','rtr _id',

'cir_id','cir_local','ext_by','details')";

$results = mysql_query($sqlquery);

mysql_close();

print "<html><body><center>";
print "<p>You have just entered customer information in the database<p>";
?>
After I submit the info, I do see my print statement but their isn't any new information in the database. Does anyone have any ideas on this?

My next question is how do you write the script to get the info from the database using a search form. I have tried this to but was not able to get this working either.

NogDog
10-11-2006, 06:49 PM
Change your mysql_query() line to something like the following so that you can get some debug info:

$results = mysql_query($sqlquery) or die("Query failed: $sqlquery - ".mysql_error());
if(mysql_affected_rows() == 0)
{
user_error("Unknown error: query processed OK but no record added.", E_USER_WARNING);
}

LearnGreekToday
10-12-2006, 07:20 AM
This is The error it gave me:

Query failed: - Query was empty

NogDog
10-12-2006, 09:43 AM
This is The error it gave me:

Query failed: - Query was empty
Odd...Have you spelled the name of the variable with the SQL string exactly the same both where you define it and where you pass it to the mysql_query() function?

LearnGreekToday
10-12-2006, 10:04 AM
I have. Just a fyi.. I am new at both php and mysql.

NogDog
10-12-2006, 10:21 AM
Could you post the latest version of the code here?

LearnGreekToday
10-12-2006, 10:48 AM
Here are parts of the code without all the html

LearnGreekToday
10-12-2006, 10:52 AM
I need to make a website that allows a user to enter information in a database using a simple form(this is written) and then later retrieve that information from my database using another simple search form. Here is a example of what kind of info and the structure of the database

Client enters:
Customer name xxxxxxx
customer acct # xxxxxxx
tech contact xxxxxxx
tech phone xxxxxxx
circuit ID xxxxxxx
Details xxxxxxxx xxxxxxxx
xxxxxxxx xxxxxxxx

later he needs to find info about a customer or circuit id

Search in database: A or B( drop down menu)

Customer Name: (search Field)
Customer Acct# (search field)

What needs to happen is when the user search for either the customers name or acct # he will pull all the information stored for that acct # or name(ex.. tech contact,phone #...)

LearnGreekToday
10-23-2006, 10:35 AM
checking to see if anyone has more information on this problem