Re: help me



I discovered that if i enter the id manually then it works, I do have
this field setup as auto inc and as PK and as not null, shouldn't this
field automatically assign its self a value of the next auto inc number
without mee having to input the id raw in the php code?

I would appreciate some help here as this has been an aim of mine for
some time to get mysql qworking and I am so so close.

TIA

Chris

PS - sorry if it appears as top posting, they look nicer on google
groups that way

thanks again

Chris


Christo wrote:
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!!

.



Relevant Pages

  • Re: Executing PHP files on remote web server
    ... We have a commercial web host servicing our external clients, but we don't want to move the entire app and database to the web host because a lot of the data is sensitive. ... By loading the non-sensitive data into the web host's MySQL tables, our external clients can see their reports on the web. ... our web host put a firewall on the MySQL database so we can't insert data into the remote tables directly from the PHP pages running on our own web server. ...
    (comp.lang.php)
  • Database Comparison?
    ... after using it that php is built more than anything to easily sit on ... talking to a mysql database and spitting out html to ... use these things better I've made a rudimentary gui designer and some ...
    (comp.lang.php)
  • Re: How to use SQL "LIMIT" keyword against an MDB file
    ... that it will work with an MSAccess MDB file. ... PHP Programmer Guy. ... Except you've just "solved" his issue with a database redesign. ... from MySQL to Access in the first place. ...
    (comp.lang.php)
  • Re: help me
    ... field automatically assign its self a value of the next auto inc number ... 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 ...
    (comp.lang.php)
  • Re: Help: Dreamweaver Database Conncetion Problem (PHP/MySQL)
    ... You probably can't connect to MySQL from outside the server, ... > on remote machines. ... you can't use Dreamweaver (or any other remote database tool) for ... I can upload my PHP site but the problem is that I ...
    (alt.php)