Re: insert data -




Petr Vileta wrote:
"VitaminB" <hetmar@xxxxxx> píse v diskusním príspevku
news:1162232099.474267.67990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

.



Relevant Pages

  • Re: need to create and make download link for csv
    ... through php. ... php page for generating and sending csv file direct to browser. ... # link for csv where mysql query contain eg. "... ... Petr Vileta, Czech republic ...
    (comp.lang.php)
  • Re: insert data -
    ... I try to insert data from a form into a mysql database, ... Petr Vileta, Czech republic ... (My server rejects all messages from Yahoo and Hotmail. ...
    (comp.lang.php)
  • Re: Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource
    ... Petr Vileta wrote: ... In my real code I must use a few different functions for displaing mysql_fetch_arrayresult and $query variable I must create before any html output because I use sessions. ... you left out what's probably the most important piece - the line number of the failing code. ...
    (comp.lang.php)
  • Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource
    ... I'm new here and excuse me if this question was be here earlier. ... In my real code I must use a few different functions for displaing mysql_fetch_arrayresult and $query variable I must create before any html output because I use sessions. ... Petr Vileta, Czech republic ...
    (comp.lang.php)
  • Why is this script so slow?
    ... mysql database that has about 250 records in it. ... When I use another script to extract the same data and display the ... I can only conclude it is the script. ...
    (alt.php)