I have a db connection and want to test inserting a variable value into a db field. It's not inserting anything but cannot see why...can anyone spot the problem please?
Updated - here's all the php code:
//DB Conn
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('mydb',$link);
?>
... then
//Save.php
<?php
include('dbconn.php');
$result = mysql_query($query, $link);
$mytestvalue = 'hello';
$query="insert into mytable (id, name) values ('null','".$mytestvalue ."')";
?>
Any ideas?
NULL, it's literally the word null...$query="insert into mytable (id, name) values (NULL,'".$mytestvalue ."')";. However if ID is a auto_increment primary key then there is no need to even pass inNULLyou can just leave ID out of the insert query for the same effect.mysql_query($query, $link);and you put it in (and in the wrong place), now the answer looks irrelevant.