473,473 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

insert data -

Hi Guys,

I try to insert data from a form into a mysql database, but it did not
work...
There is no error, but the data did not pass thru the table.
This is the short script:
<html>
<head>
<title>Insert Address</title>
</head>
<body>
<p><strong>Insert Address</strong></p>
<?php
print_r($_POST);
$link = mysql_connect("aaa", "aaa", "aaa")
or die("Could not connect: " . mysql_error());
mysql_selectdb("db182527668",$link) or die ("Can\'t use
dbserver : " . mysql_error());
$Lat = $_POST['Lat'];
$Lon = $_POST['Lon'];
$Name = $_POST['Name'];
$Owner = $_POST['Owner'];
$City = $_POST['City'];
$Street = $_POST['Street'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
$result = mysql_query("INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");
echo $result;
mysql_error();
mysql_close($link);
?>
</body>
</html>
And this is the table:
id int(11) Nein auto_increment
lat decimal(10,6) Nein 0.000000
lon decimal(10,6) Nein 0.000000
description varchar(255) latin1_german2_ci Nein
owner varchar(255) latin1_german2_ci Nein
city varchar(255) latin1_german2_ci Nein
street varchar(255) latin1_german2_ci Nein
zip varchar(20) latin1_german2_ci Nein
country varchar(255) latin1_german2_ci Nein
Thx for your help!!!

Oct 30 '06 #1
6 2102


On Oct 30, 8:14 pm, "VitaminB" <het...@web.dewrote:
Hi Guys,

I try to insert data from a form into a mysql database, but it did not
work...

There is no error, but the data did not pass thru the table.

This is the short script:
<html>
<head>
<title>Insert Address</title>
</head>
<body>
<p><strong>Insert Address</strong></p>

<?php
print_r($_POST);

$link = mysql_connect("aaa", "aaa", "aaa")
or die("Could not connect: " . mysql_error());
mysql_selectdb("db182527668",$link) or die ("Can\'t use
dbserver : " . mysql_error());

$Lat = $_POST['Lat'];
$Lon = $_POST['Lon'];
$Name = $_POST['Name'];
$Owner = $_POST['Owner'];
$City = $_POST['City'];
$Street = $_POST['Street'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];

$result = mysql_query("INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");
echo $result;
mysql_error();

mysql_close($link);
?>

</body>
</html>

And this is the table:

id int(11) Nein auto_increment
lat decimal(10,6) Nein 0.000000
lon decimal(10,6) Nein 0.000000
description varchar(255) latin1_german2_ci Nein
owner varchar(255) latin1_german2_ci Nein
city varchar(255) latin1_german2_ci Nein
street varchar(255) latin1_german2_ci Nein
zip varchar(20) latin1_german2_ci Nein
country varchar(255) latin1_german2_ci Nein

Thx for your help!!!
Check whether your SQL statement is correct, print it and execute in
the database client, like Query Browser. Check the result of the
mysql_error function - now you just do not print the message it
returns.

Sincerely,
Alexander
http://www.alexatnet.com/ - Zend Framework and Ajax blog

Oct 30 '06 #2
VitaminB wrote:
I try to insert data from a form into a mysql database, but it did not
work...
There is no error,
I think you mean: "I didn't print the error," :)
but the data did not pass thru the table.
<snip>
$result = mysql_query("INSERT INTO wholocations(íd', 'lat',
'lon','description', ówner', çity', 'street', 'zip', çountry')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");
If there is an error in your SQL statement, $result will be false and
echo $result;
this echo will be the same as <?php echo false; ?>
You need to test the return value of mysql_query()

if ($result === false) {
echo 'There was an error in the SQL statement. ';
echo 'The error was: ', mysql_error(), "].<br>\n";
}
mysql_error();
<snip>

--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
Oct 30 '06 #3
On 30 Oct 2006 10:14:59 -0800, "VitaminB" <he****@web.dewrote:
>mysql_error();
Right idea, but this statement does nothing. You need to at least print it
out.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Oct 30 '06 #4
"VitaminB" <he****@web.depíse v diskusním príspevku
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hi Guys,

I try to insert data from a form into a mysql database, but it did not
work...
<?php
print_r($_POST);
$link = mysql_connect("aaa", "aaa", "aaa")
or die("Could not connect: " . mysql_error());
mysql_selectdb("db182527668",$link) or die ("Can\'t use
dbserver : " . mysql_error());
$Lat = $_POST['Lat'];
$Lon = $_POST['Lon'];
$Name = $_POST['Name'];
$Owner = $_POST['Owner'];
$City = $_POST['City'];
$Street = $_POST['Street'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
$result = mysql_query("INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");
It is curious syntax :-) Try this:

$query = "INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($query) or die(mysql_error());
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Oct 31 '06 #5

Petr Vileta wrote:
"VitaminB" <he****@web.depíse v diskusním príspevku
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hi Guys,

I try to insert data from a form into a mysql database, but it did not
work...
<?php
print_r($_POST);
$link = mysql_connect("aaa", "aaa", "aaa")
or die("Could not connect: " . mysql_error());
mysql_selectdb("db182527668",$link) or die ("Can\'t use
dbserver : " . mysql_error());
$Lat = $_POST['Lat'];
$Lon = $_POST['Lon'];
$Name = $_POST['Name'];
$Owner = $_POST['Owner'];
$City = $_POST['City'];
$Street = $_POST['Street'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
$result = mysql_query("INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");

It is curious syntax :-) Try this:

$query = "INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($query) or die(mysql_error());
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Also, take a look at php's extract() function

Oct 31 '06 #6
Thx for all these tips. I will try this tomorrow evening. The "currious
syntax" is from another forum (o.
strawberry wrote:
Petr Vileta wrote:
"VitaminB" <he****@web.depíse v diskusním príspevku
news:11*********************@e3g2000cwe.googlegrou ps.com...
Hi Guys,
>
I try to insert data from a form into a mysql database, but it did not
work...
>
>
<?php
print_r($_POST);
>
>
$link = mysql_connect("aaa", "aaa", "aaa")
or die("Could not connect: " . mysql_error());
mysql_selectdb("db182527668",$link) or die ("Can\'t use
dbserver : " . mysql_error());
>
>
$Lat = $_POST['Lat'];
$Lon = $_POST['Lon'];
$Name = $_POST['Name'];
$Owner = $_POST['Owner'];
$City = $_POST['City'];
$Street = $_POST['Street'];
$ZIP = $_POST['ZIP'];
$Country = $_POST['Country'];
>
>
$result = mysql_query("INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$Lon."','".$Name."' , '".$Owner."' ,'".$City."'
,'".$Street."' ,'".$ZIP."' ,'".$Country."')");
It is curious syntax :-) Try this:

$query = "INSERT INTO wholocations('id', 'lat',
'lon','description', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($query) or die(mysql_error());
--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
Also, take a look at php's extract() function
Oct 31 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
6
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: ...
6
by: pk | last post by:
Sorry for the piece-by-piece nature of this post, I moved it from a dormant group to this one and it was 3 separate posts in the other group. Anyway... I'm trying to bulk insert a text file of...
16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
2
by: Polyhedron_12 | last post by:
I am having problems calling functions in general in VB. I keep getting alot of errors. Can anybody help me out with this? I put the error message on the same line that it says it is at. I believe...
2
by: Geoffrey KRETZ | last post by:
Hello, I'm wondering if the following behaviour is the correct one for PostGreSQL (7.4 on UNIX). I've a table temp_tab with 5 fields (f1,f2,f3,...),and I'm a launching the following request :...
2
by: wombat53 | last post by:
Hi Group Are there any DB2 UDB ESE DPF V8.2 users exploiting "buffered inserts" (BIND parm INSERT BUF) *and* "multi-row INSERTS" (many rows associated with the VALUES clause of the INSERT to...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.