|
Posted by Christo on 11/15/06 00:48
OK.
I have a mysql database and i have it displaying whats currently there
using php, the problem is that I cannot insert into the database
correctly. please check my code below
<?php
$username = "root";
$password = "************"; //edited
$server = "localhost";
$dbname = "dbname";
$title = $_POST["title"];
$news = $_POST["news"];
$id = $_POST["id"];
$date = "2006-15-11 00:15:15";
$dbc = mysql_connect($server, $username, $password) or die ("ERROR");
$select = mysql_select_db($dbname, $dbc) or die("couldn't connect to
dbname");
$sqlquery = "INSERT INTO tnews VALUES('$id','$title','$news','$date')";
//print "<html><body><center>";
//print "<p>You have just entered this record<p>";
//print "Title : $title<br><hr>";
//print "$news<br>$date";
//print "</body></html>";
print $sqlquery;
$results = mysql_query($sqlquery);
mysql_close($dbc);
?>
this submits the info from a form, the code for the form is below:
<form method="post" action="add.php">
Title: <input name="title" type="text" value="">
<input type="hidden" name="id" />
<br>
News: <input name="news" type="text" value="">
<br>
<br>
<input type="submit" name="submit" value="Submit">
</form>
I can see the insert query fine and it appears to be working however
the data isnt being put in the database. I am hosting php on my home
computer and it is being used with apache I am also hosting mysql on my
own computer and am using SQLyog and the GUI toold from mysql to
administer the db, I am a novice so please go easy but can anyone see a
reason why i cant get this data to appear in my database table?
Please please help me!!
Navigation:
[Reply to this message]
|