$_POST
Moderator: General Moderators
$_POST
what am I doing wrong? failed to insert data into the DB...! been working on this all day! can't get it to work!
<?php
$a1=$_POST[first_name];
$a2=$_POST[last_name];
$a3=$_POST[work_phone];
$a4=$_POST[cell_phone];
$a5=$_POST[company];
$a6=$_POST[address];
$a7=$_POST[address_2];
$a8=$_POST[city];
$a9=$_POST[state];
$a10=$_POST[zip];
$a11=$_POST[email];
$a12=$_POST[payment_type];
$a13=$_POST[sem_id];
$a14=$_POST[sem_title];
$a15=$_POST[sem_month];
$a16=$_POST[sem_day];
$a17=$_POST[sem_year];
$a18=$_POST[sem_time_hr];
$a19=$_POST[sem_time_min];
$a20=$_POST[sem_time_day];
$db = mysqli_connect( "localhost" , "amp", "123456" , "amp" )
or die ("not able to connect.");
$query = "INSERT INTO attendees (
first_name,
last_name,
work_phone,
cell_phone,
company,
address_1,
address_2,
city,
state,
zip,
email,
sem_id,
sem_title,
sem_month,
sem_day,
sem_year,
sem_time_hr,
sem_time_min,
sem_time_day,
payment_type
)
VALUES (
'$a1',
'$a2',
'$a3',
'$a4',
'$a5',
'$a6',
'$a7',
'$a8',
'$a9',
'$a10',
'$a11',
'$a12',
'$a13',
'$a14',
'$a15',
'$a16',
'$a17',
'$a18',
'$a19',
'$a20'
)";
mysql_query($query) or die("Error adding data!");
?>
<?php
$a1=$_POST[first_name];
$a2=$_POST[last_name];
$a3=$_POST[work_phone];
$a4=$_POST[cell_phone];
$a5=$_POST[company];
$a6=$_POST[address];
$a7=$_POST[address_2];
$a8=$_POST[city];
$a9=$_POST[state];
$a10=$_POST[zip];
$a11=$_POST[email];
$a12=$_POST[payment_type];
$a13=$_POST[sem_id];
$a14=$_POST[sem_title];
$a15=$_POST[sem_month];
$a16=$_POST[sem_day];
$a17=$_POST[sem_year];
$a18=$_POST[sem_time_hr];
$a19=$_POST[sem_time_min];
$a20=$_POST[sem_time_day];
$db = mysqli_connect( "localhost" , "amp", "123456" , "amp" )
or die ("not able to connect.");
$query = "INSERT INTO attendees (
first_name,
last_name,
work_phone,
cell_phone,
company,
address_1,
address_2,
city,
state,
zip,
email,
sem_id,
sem_title,
sem_month,
sem_day,
sem_year,
sem_time_hr,
sem_time_min,
sem_time_day,
payment_type
)
VALUES (
'$a1',
'$a2',
'$a3',
'$a4',
'$a5',
'$a6',
'$a7',
'$a8',
'$a9',
'$a10',
'$a11',
'$a12',
'$a13',
'$a14',
'$a15',
'$a16',
'$a17',
'$a18',
'$a19',
'$a20'
)";
mysql_query($query) or die("Error adding data!");
?>
Re: $_POST
Use
to see what's wrong.
Code: Select all
mysql_query($query) or die(mysql_error());There are 10 types of people in this world, those who understand binary and those who don't
Re: $_POST
??radium35 wrote:?
There are 10 types of people in this world, those who understand binary and those who don't
Re: $_POST
ok thanks! now it give's me Access denied for user 'apache'@'localhost' (using password: NO)
Re: $_POST
Maybe you should use the mysql_connect() function 
I.e. you should use functions from mysqli_* family or mysql_* family, but do not mix'em.
I.e. you should use functions from mysqli_* family or mysql_* family, but do not mix'em.
There are 10 types of people in this world, those who understand binary and those who don't
Re: $_POST
yes i just did that and now says database not selected
Re: $_POST
Then probably you have to select one before your query 
http://bg.php.net/manual/en/function.my ... ect-db.php
http://bg.php.net/manual/en/function.my ... ect-db.php
There are 10 types of people in this world, those who understand binary and those who don't
Re: $_POST
@Syntac
No copy-paste examples, please.
Helping radium35 in my way guarantees he has seen the manual at leas once!
No copy-paste examples, please.
Helping radium35 in my way guarantees he has seen the manual at leas once!
There are 10 types of people in this world, those who understand binary and those who don't
Re: $_POST
yay! thanks guys! 
Re: $_POST
That's exactly why I deleted my post.VladSun wrote:@Syntac
No copy-paste examples, please.
Helping radium35 in my way guarantees he has seen the manual at leas once!
Re: $_POST
Sorry 
And thanks
And thanks
There are 10 types of people in this world, those who understand binary and those who don't