|
Posted by Johnny on 09/23/06 19:55
"Bryan" <BTRichardson@gmail.com> wrote in message
news:1158977744.845188.65700@b28g2000cwb.googlegroups.com...
> Hello all,
>
> Can anyone tell me why the following code isn't working?
>
> $dbh = mysql_connect($host,$user,$pass) or die("Couldn't connect...");
> $selected = mysql_select_db($db,$dbh);
> $name = $_GET['name'];
> $state = $_GET['state'];
> $desc = $_GET['desc'];
> $lat = $_GET['lat'];
> $lng = $_GET['lng'];
> $result = mysql_query("INSERT INTO re_cities (name, state, description,
> lat, lng) VALUES ('$name','$state','$desc','$lat','$lng')");
>
> The script doesn't die when I attempt to connect so I'm assuming that
> isn't the problem. I'm pretty sure I also get a result because the
> following code echoes "City Add Successful".
>
> if ($result) {
> echo "City Add Successful";
> } else {
> echo "City Add Unsuccessful";
> }
>
> However, the data doesn't show up in the database. Any suggestions?
>
works for me.
Try doing a
var_dump($_GET);
exit;
above your code and see if everything is there.
What may be happening is that $_GET may be empty and you end up putting nul
into the db or nothing at all if not using an autoincrement id in that
table.
Navigation:
[Reply to this message]
|