Re: Solution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My mistake. You are correct.

Karl


On Apr 13, 2010, at 2:16 PM, Jim Lucas wrote:

Karl DeSaulniers wrote:
Hey Gary, instead try something like this maybe?


$dbc=mysqli_connect('localhost','root','','test') or die('Error
connecting to MySQL server');

$query_name="INSERT INTO name(fname='$fname', lname='$lname')";
$query_address="INSERT INTO address (street='$street', town='$town',
state='$state', zip='$zip')";

Their are a few syntax variations available, but the one that they used is not a valid format. The following are the insert statements written in a valid format.

$query_name = "INSERT INTO name (
     fname,    lname
   ) VALUES (
   '$fname', '$lname'
   )";

$query_address = "INSERT INTO address (
     street,    town,    state,    zip
   ) VALUES {
   '$street', '$town', '$state', '$zip'
   )";

Try this, it should work.


$result1=mysqli_query($dbc, $query_name) or die('Error querying database
for name.');

$result2=mysqli_query($dbc, $query_address) or die('Error querying
database for address.');

echo "Success!<br />";

?>

HTH,

Karl


On Apr 12, 2010, at 5:16 PM, Peter Lind wrote:

$dbc=mysqli_connect('localhost','root','','test')or die('Error
connecting to
MySQL server');

$query="INSERT INTO name(fname, lname)"."VALUES('$fname','$lname')";

$result=mysqli_query($dbc, $query)
or die('Error querying database.');

mysqli_close($dbc);
?>

<?php

$dbc=mysqli_connect('localhost','root','','test')or die('Error
connecting to
MySQL server');
$query="INSERT INTO address (street, town, state,
zip)"."VALUES('$street','$town','$state','$zip')";

$result=mysqli_query($dbc, $query)
or die('Error querying database.');

mysqli_close($dbc);

?>

Karl DeSaulniers
Design Drumm
http://designdrumm.com




--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux