Page 1 of 1
why can I add numbers to my database and not letters?
Posted: Tue Sep 13, 2005 3:13 am
by widdi
Hi,
http://www.little-planet.net/add.php
I can add numbers - but letters gives, Error - unknown column
any ideas?
Posted: Tue Sep 13, 2005 7:57 am
by feyd
your query string does not quote the value, you must quote it so the database can understand it. Otherwise it sees it as a column reference, which will fire such an error.
could you please explain more?
Posted: Tue Sep 13, 2005 9:16 am
by widdi
I would be gratful if you could show me??
is it the html form or the db-loader.php as follows?
it is only some fields that do this?!!
Code: Select all
<?php
include_once("conf.php");
echo "<html><head><link href=\"/style/hans.css\" rel=\"stylesheet\" type=\"text/css\">";
echo "</head><body>";
echo "Lat: " . $new_lat . "<br>";
echo "Lon: " . $new_lon . "<br>";
echo "Text: " . $new_desc . "<br>";
echo "URL: " . $new_url . "<br>";
echo "Marker: " . $new_marker . "<br>";
echo "Name: " . $new_sub_name . "<br>";
echo "Website: " . $new_sub_web . "<br>";
echo "Place: " . $new_sub_place . "<br>";
echo "Country: " . $new_sub_country . "<br>";
echo "Will now be added to the database...";
$new_desc = addslashes($new_desc);
$link = mysql_connect($dbserver, $username, $password) or die("Could not connect: " . mysql_error());
mysql_select_db("cole_test",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
$sql = "INSERT INTO subfinder ";
$sql = $sql . "VALUES ('','".$new_lat."','".$new_lon."','".$new_desc."','".$new_url."','".$new_marker ."'," . $new_sub_name . "," . $new_sub_web . "," . $new_sub_place . "," . $new_sub_country . ")";
$result = mysql_query($sql ,$link);
if (!$result)
{
echo "<p>Due to an error (" . mysql_error() . ")<br>, your entry could not be loaded into the database. Please return to <a href=\"subfinder.php\">Subfinder</a>.";
} else
{
echo "<p>Your entry has been loaded into the database. Please return to <a href=\"index.php\">Little-planet</a>.";
}
echo "</body></html>";
?>
Posted: Tue Sep 13, 2005 9:45 am
by josh
$sql = $sql . "VALUES ('','".$new_lat."','".$new_lon."','".$new_desc."','".$new_url."','".$new_marker ."'," . $new_sub_name . "," . $new_sub_web . "," . $new_sub_place . "," . $new_sub_country . ")";
it needs quotes