why can I add numbers to my database and not letters?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
widdi
Forum Newbie
Posts: 6
Joined: Sun Sep 11, 2005 1:36 pm

why can I add numbers to my database and not letters?

Post by widdi »

Hi,
http://www.little-planet.net/add.php


I can add numbers - but letters gives, Error - unknown column


any ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
widdi
Forum Newbie
Posts: 6
Joined: Sun Sep 11, 2005 1:36 pm

could you please explain more?

Post 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>";
?>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post 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
Post Reply