473,779 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
+ 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>Inse rt 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("IN SERT INTO wholocations('i d', 'lat',
'lon','descript ion', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$ Lon."','".$Name ."' , '".$Owner."' ,'".$City."'
,'".$Street." ' ,'".$ZIP."' ,'".$Country."' )");
echo $result;
mysql_error();
mysql_close($li nk);
?>
</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 2117


On Oct 30, 8:14 pm, "VitaminB" <het...@web.dew rote:
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>Inse rt 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("IN SERT INTO wholocations('i d', 'lat',
'lon','descript ion', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0',
'".$Lat."','".$ Lon."','".$Name ."' , '".$Owner."' ,'".$City."'
,'".$Street." ' ,'".$ZIP."' ,'".$Country."' )");
echo $result;
mysql_error();

mysql_close($li nk);
?>

</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("IN SERT INTO wholocations(íd ', 'lat',
'lon','descript ion', ó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.dew rote:
>mysql_error( );
Right idea, but this statement does nothing. You need to at least print it
out.

--
Andy Hassall :: an**@andyh.co.u k :: 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******** *************@e 3g2000cwe.googl egroups.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("IN SERT INTO wholocations('i d', 'lat',
'lon','descript ion', '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('i d', 'lat',
'lon','descript ion', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($qu ery) 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******** *************@e 3g2000cwe.googl egroups.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("IN SERT INTO wholocations('i d', 'lat',
'lon','descript ion', '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('i d', 'lat',
'lon','descript ion', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($qu ery) 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******** *************@e 3g2000cwe.googl egroups.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("IN SERT INTO wholocations('i d', 'lat',
'lon','descript ion', '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('i d', 'lat',
'lon','descript ion', 'owner', 'city', 'street', 'zip', 'country')
VALUES('0', $Lat, $Lon, $Name, $Owner , $City, $Street, $ZIP,
$Country)";
$result = mysql_query($qu ery) 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
5521
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, UPDATE, DELETE) which are controlled by a web frontend and the table records are manipulated to control the permissions. Example: The Press Release section record would look like this: Username: John Doe Function Name: Press Release
6
7016
by: Mark P | last post by:
Some time ago I posted here about inserting into a set with a hint: http://groups-beta.google.com/group/alt.comp.lang.learn.c-c++/browse_thread/thread/fb75b00f73e979db/018b8d0eadb38dbf?q=%22STL+insert+with+hint%22+%22Mark+P%22&rnum=1&hl=en#018b8d0eadb38dbf I quoted the SGI STL docs describing a.insert(p, t), where p is the hint iterator and t is the inserted object: "Insert with hint is logarithmic in general, but it is amortized...
6
12358
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 10 columns into a table with 12. How can I specify which columns to insert to? I think format files are what I'm supposed to use, but I can't figure them out. I've also tried using a view, as was suggested on one of the many websites I've...
16
17019
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 must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then IF FOUND UPDATE <TABLE> SET .... <Values entered here> ELSE INSERT INTO <TABLE> VALUES <Values...
16
3877
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 table, or perhaps bytes, being updated where the engine just decides, screw it, i'll just make a new one. surfed this group and google, but couldn't find anything. the context: we have some java folk who like to parametize/
4
11835
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 completed. here's the code: System.Data.OleDb.OleDbConnection hist_cnn = new System.Data.OleDb.OleDbConnection(); System.Data.OleDb.OleDbCommand hist_command = new System.Data.OleDb.OleDbCommand();
2
2407
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 that I am not calling the function correctly. The MyInsertMethod function is the function that comes in the Web Matrix Toolbox <%@ Page Language="VB" %>
2
3210
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 : INSERT INTO temp_tab VALUES (1,2,3)
2
3683
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 minimize number of calls to the RDMBS engine) in an SQL PL Stored Procedure? I ask, as the latter would imply embedded DYNAMIC SQL due to potentially varying number of rows to be inserted (assume it's varying), and so, the SQL INSERT would have be...
6
3469
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 using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns, there's another column in the DB table named 'RegDateTime' whose datatype is Date/Time which is...
0
9474
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.