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? 4 1241
Bryan wrote:
re_cities
What is the schema for this table like? Any columns that are "NOT NULL"?
Any that need to be unique? Any other constraints?
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
"Bryan" <BT**********@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.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.
Bryan wrote:
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')");
print "error ='" . mysql_error() . "'<br />\n";
C.
Colin McKinnon wrote:
Bryan wrote:
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')");
print "error ='" . mysql_error() . "'<br />\n";
C.
Try storing the query in a variable and echoing/printing it, then you
should be able to see what the query really looks like. Try running the
resulting query through your SQL client of choice, hopefully it will
give you some meaningful feedback. And on a security note you seem to
be putting a lot of trust in those $_GET variables. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michel |
last post by:
Hi,
I like to build a small simple dinamic website: Point-of-sale
(detail-shop), So entering stock, logging all sales, print out
invoices and download the logs to be imported into Excel.
I...
|
by: NotGiven |
last post by:
I have used dreamweaver to do a lot of php "programming" but now I need to
write a real php function.
I have a hosted mysql database that I need to export to MS Access. I can't
use myODBC to do...
|
by: Munzilla |
last post by:
Ok, I have an ASP page that I use to add several pieces of information
to a database and also display that information in an edit mode. The
problem is, when I use the page for edit, not all of the...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: Richard Marsden |
last post by:
I'm having a lot of trouble writing large chunks of binary data (tests
are in the range of 16-512K, but we need support for large longblobs) to
MySQL using ODBC. Database is local on a W2K system,...
|
by: Chris Springer |
last post by:
I'd like to get some feedback on the issue of storing data out to disk and
where to store it. I've never been in a production environment in
programming so you'll have to bear with me...
My...
|
by: Extremest |
last post by:
I have a loop that is set to run as long as the arraylist is > 0.
at the beginning of this loop I grab the first object and then
remove it. I then go into another loop that checks to see if there...
|
by: Extremest |
last post by:
Here is the code I have so far. It connects to a db and grabs headers.
It then sorts them into groups and then puts all the complete ones
into another table. Problem I am having is that for some...
|
by: gunimpi |
last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431
********************************************************
VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help
wanted...
|
by: DarkGiank |
last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |