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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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


The information is sent from another page which has the following values:


<form name="add" method="get" action="addvalue.php">

<?php
echo '<table><tr><td>Insert a DVD</td></tr>';
echo '<tr><td><input type="text" name="newdvdtitle"> DVD name</td></tr>';
echo '<tr><td><input type="text" name="newdvdyear"> DVD year</td></tr>';
echo '<tr><td><input type="text" name="newdvdcost"> DVD cost</td></tr>';
echo '<tr><td><input type="text" name="newdvdpurchased"> DVD date
purchased</td></tr>';
echo '<tr><td><input type="submit" value="Insert new dvd"></td></tr>';
echo '</table>';
?>
</form>


Thanks in advance,

Douglas

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux