Jump to content

[SOLVED] Help inserting data into MySQL


ncorrieri

Recommended Posts

hey all - im trying to go back and repair some old code, and i dont know what im doing :)

 

This should be able to connect to database fine, however, it is not inserting.

 

Posting data to this page. What do you think is wrong with this page?

 

 

-------------

<?
require_once("config.php");


$data = $_POST;
$data['dob'] = "$data[dobYYYY]-$data[dobMM]-$data[dobDD]";
$t = "registration";
$q = "INSERT INTO $t (`id`,`prefix`,`suffix`,`fname`,`lname`,`gender`,`dob`,
	`address1`,`address2`,`city`,`state`,`email`,`areacode`,
	`regtime`,`ipaddress`,`offer`,`affiliate`,`subaffiliate`)
	VALUE (	null,[prefix],[suffix],[fname],[lname],[gender],[dob],
	[address1],[address2],[city],[state],[email],
	[areacode],NOW(),[ipaddress],[offer],[affiliate],[subaffiliate])";
foreach ($data as $key => $value)
{
	$value = "'".mysql_real_escape_string($value)."'";
	$q = str_replace("[$key]",$value,$q );	
}				

mysql_query($q);
?>

Link to comment
https://forums.phpfreaks.com/topic/39344-solved-help-inserting-data-into-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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