Hi, This is a first post, i'm a web designer more on the visual front end side of things, my PHP/MySQL knowledge is pretty basic, usually leave that to my web dev colleague but he's out of action for the foreseeable.
Here's a my question...
I have a form which captures a web address, I would like this web address stored in MySQL, have the following code for PHP...
<?php
$con = mysql_connect("localhost","XXXXX","XXXXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("websitevoice_", $con);
$url=mysql_real_escape_string($_POST['url']);
$ref=mysql_real_escape_string($_POST['ref_id']);
$sql="INSERT INTO web_addresses (link_url,ref_id) VALUES ('$url','$ref')";
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($con);
?>
Here's the SQL dump...
CREATE TABLE `web_addresses` (
`link_id` bigint(20) NOT NULL auto_increment,
`link_url` varchar(255) NOT NULL default '',
`ref_id` varchar(20) NOT NULL default '',
PRIMARY KEY (`link_id`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `web_addresses`
--
INSERT INTO `web_addresses` (`link_id`, `link_url`, `ref_id`) VALUES (1, 'www.google.com', '123'),
(8, '', ''),
(9, '', ''),
(10, '', ''),
(11, '', ''),
(12, '', '');
The form processes, so it's connecting to the db and as you can see from the dump it's creating the new entries against a unique link_id but the values aren't coming through.
Probably making some kind of school boy error, any help would be much appreciated.