Forum Moderators: coopster

Message Too Old, No Replies

Mysql insert problem with php

what am i doing wrong

         

leo_bezemer

12:25 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



Hi guys,

I'm a bit new to php and i've been staring at this thing an entire morning now, and i can't seem to find my errors.
I know this might not be the best(cleanest or fastest) way to put things entered in a form into a msql dbase, but it should work.

A mate of mine pointed me in the right direction. but now i'm stuck, can someone here please lend a hand.

I know it might be a long read, but please help.

thanx
Leo

------------------------------------------------------------
<?
$dbh=mysql_connect ("localhost", "****", "****") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("hollandc_italy");

@mysql_select_db("hollandc_italy") or die;

$sqlquery=("INSERT INTO Contacts (hotel_name, connect, cost_per_miute, itf, commission_hotel, commission_agent, contactid, number_of_rooms, manager, hotel_name, hotel_address, hotel_phone_nr, city, country, manger_telephone, faxnumber, emailname, website, account_nr, password, responsible_agent, notes_on_hotel, bank_name, bank_swift_code, bank_account_nr, bank_location, ani, hotel_man_email);

$VALUES=
('$hotel_name','$connect','$cost_per_miute', '$itf', '$commission_hotel', '$commission_agent', '$contactid', '$number_of_room'$manager', '$hotel_name', '$hotel_address', '$hotel_phone', '$city', '$country', '$manager_phone', '$faxnumber', '$emailname', '$website', '$account_nr', '$password', '$responsible_agent', '$notes_on_hotel', '$bank_name', '$bank_swift_code', '$bank_account_nr', '$bank_location', '$ani', '$hotel_man_email');

$results=mysql_query("$sqlquery") or die;

?>
-----------------------------------------------------------

[edited by: jatar_k at 8:20 pm (utc) on Dec. 5, 2003]
[edit reason] fixed sidescroll [/edit]

Paul in South Africa

12:43 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



1. Remove the opening bracket from the line beginning $sqlquery
ie $sqlquery=("INSERT should read $sqlquery="INSERT
2. Remove the ; from the end of that line.
3. $VALUES= should read VALUES=
4. Add " to the end of '$ani','$hotel_man_email')
ie '$ani','$hotel_man_email')";

You are are also selecting the database twice. mysql_select_db ("hollandc_italy"); at the end of your first line of code and @mysql_select_db("hollandc_italy") or die; on the next line. Delete the first one.

leo_bezemer

1:21 pm on Dec 5, 2003 (gmt 0)

10+ Year Member



Wow that was fast.

Thnx.

(it's not quite working yet but atleast i don't get anymore error messages.)

coopster

1:59 pm on Dec 5, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, leo_bezemer!

You are also missing a comma and single quotation mark in your values list after the $number_of_room field:


VALUES =
('$hotel_name',
'$connect',
'$cost_per_miute',
'$itf',
'$commission_hotel',
'$commission_agent',
'$contactid',
'$number_of_room', // Added comma here
'$manager', // Added opening single quotation here
'$hotel_name',
'$hotel_address',
'$hotel_phone',
'$city',
'$country',
'$manager_phone',
'$faxnumber',
'$emailname',
'$website',
'$account_nr',
'$password',
'$responsible_agent',
'$notes_on_hotel',
'$bank_name',
'$bank_swift_code',
'$bank_account_nr',
'$bank_location',
'$ani',
'$hotel_man_email');

P.S. $cost_per_miute <-- is spelled wrong ;)