Re: <Newbie Question> Can't insert values into MySQL DB via PHP

From: Date: Fri, 10 Feb 2006 10:30:52 +0000
Subject: Re: <Newbie Question> Can't insert values into MySQL DB via PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-230192@lists.php.net to get a copy of this message
Duggles Temple wrote:
Hi, I'd like to say in advance that I am sorry about the silly and very newbie question I'm asking. I am having a problem with a shop system. I can't add values into the MySQL DB via a PHP statement. The values are being transferred from one page to another (know that from the echo statement), but the SQL statement isn't working.
What error do you get?
The statement is as follows: $conn = mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to database'); $t = $_GET['newdvdtitle']; $y = $_GET['newdvdyear']; $c = $_GET['newdvdcost']; $p = $_GET['newdvdpurchased']; @mysql_select_db("$DBName") or die("Unable to select database $DBName"); $sqladd = "INSERT INTO 'dvd' ('id', 'title', 'year','cost','purchased') VALUES ( NULL , '$t', '$y', '$c' , '$p' )"; echo $sqladd; $result = mysql_query($sqladd);
Insert Into dvd (title, year,cost,purchased) When the id is auto_increment you dont have to add it to the query. Barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

« previous php.general (#230192) next »