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

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

 



Hi,

Friday, February 10, 2006, 8:16:41 PM, you wrote:
DT> Hi,

DT> I'd like to say in advance that I am sorry about the silly and very newbie
DT> question I'm asking.

DT> I am having a problem with a shop system. I can't add values into the MySQL
DT> DB via a PHP statement. The values are being transferred from one page to
DT> another (know that from the echo statement), but the SQL statement isn't
DT> working.

DT> The statement is as follows:

DT> $conn = mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to
DT> database');
DT> $t = $_GET['newdvdtitle'];
DT> $y = $_GET['newdvdyear'];
DT> $c = $_GET['newdvdcost'];
DT> $p = $_GET['newdvdpurchased'];
DT> @mysql_select_db("$DBName") or die("Unable to select database $DBName");
DT> $sqladd = "INSERT INTO 'dvd' ('id', 'title', 'year','cost','purchased')
DT> VALUES (  NULL , '$t', '$y', '$c' , '$p' )";
DT> echo $sqladd;
DT> $result = mysql_query($sqladd);


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


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

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


DT> Thanks in advance,

DT> Douglas

Don't put the table name in quotes, use the back tick `dvd`

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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