Can anyone see why this chunk of code doesn't work.
No parsing errors, the record just doesn't appear in the table
*-*
<?php
include('functions.php');
if (strlen(trim($_POST['name'])) == 0)
{
Print 'Name required';
return;
}
if (strlen(trim($_POST['mobile'])) == 0)
{
Print 'Mobile number required';
return;
}
if (strlen(trim($_POST['van'])) == 0)
{
Print 'Van details required';
return;
}
// open connection
$cMysql = conectmysql();
// check connection
if (mysql_errno())
{
die("Can't connect to SQL server");
return;
}
// select database
$res = mysql_select_db('Pcouriers', $cMysql);
// format variables
$name = strtoupper(trim($_POST['name']));
$address = strtoupper(trim($_POST['address']));
$mobtel = trim($_POST['mobile']);
$van = strtoupper(trim($_POST['van']));
// build query
$query = "INSERT INTO `drivers` (name, mobtel, vantype, address) VALUES ($name, $mobtel, $van, $address)";
// insert data
$res = mysql_query($query, $cMysql);
mysql_close($cMysql);
// nothing
print $res;
return;
?>
*-*
No parsing errors, the record just doesn't appear in the table
*-*
<?php
include('functions.php');
if (strlen(trim($_POST['name'])) == 0)
{
Print 'Name required';
return;
}
if (strlen(trim($_POST['mobile'])) == 0)
{
Print 'Mobile number required';
return;
}
if (strlen(trim($_POST['van'])) == 0)
{
Print 'Van details required';
return;
}
// open connection
$cMysql = conectmysql();
// check connection
if (mysql_errno())
{
die("Can't connect to SQL server");
return;
}
// select database
$res = mysql_select_db('Pcouriers', $cMysql);
// format variables
$name = strtoupper(trim($_POST['name']));
$address = strtoupper(trim($_POST['address']));
$mobtel = trim($_POST['mobile']);
$van = strtoupper(trim($_POST['van']));
// build query
$query = "INSERT INTO `drivers` (name, mobtel, vantype, address) VALUES ($name, $mobtel, $van, $address)";
// insert data
$res = mysql_query($query, $cMysql);
mysql_close($cMysql);
// nothing
print $res;
return;
?>
*-*