$_POST

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

$_POST

Post by radium35 »

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!");







?>
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

Use

Code: Select all

mysql_query($query) or die(mysql_error());
to see what's wrong.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

Re: $_POST

Post by radium35 »

?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

radium35 wrote:?
??
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

Re: $_POST

Post by radium35 »

ok thanks! now it give's me Access denied for user 'apache'@'localhost' (using password: NO)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

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.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

Re: $_POST

Post by radium35 »

yes i just did that and now says database not selected
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

Then probably you have to select one before your query ;)
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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

@Syntac
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
User avatar
radium35
Forum Commoner
Posts: 50
Joined: Mon Nov 10, 2008 5:05 pm
Location: USA
Contact:

Re: $_POST

Post by radium35 »

yay! thanks guys! :drunk:
User avatar
Syntac
Forum Contributor
Posts: 327
Joined: Sun Sep 14, 2008 7:59 pm

Re: $_POST

Post by Syntac »

VladSun wrote:@Syntac
No copy-paste examples, please.
Helping radium35 in my way guarantees he has seen the manual at leas once! ;)
That's exactly why I deleted my post. :)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: $_POST

Post by VladSun »

Sorry :)
And thanks :)
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply