[PHP-DB] inserting data into database!

2004-05-14 Thread Ronald Allen
Two questions?
First why am I getting  undefined variable tmp , yet it works
Second how would I insert data into this table?
?
$db_table = 'log';
$conn = mysql_connect($db_host,$db_user,$db_pass);

if ($conn == true) {
  mysql_select_db($db_name,$conn);
  $result = mysql_query(SELECT * from $db_table,$conn);
while($row = mysql_fetch_object($result)) {
$tmp .= ID   : $row-ID   br\n;
$tmp .= Base : $row-Base br\n;
$tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
$tmp .= Event_Type : $row-Event_Type br\n;
$tmp .= Description : $row-Description br\n;
$tmp .= Initials : $row-Initials brhr\n;
}
} else {
echo 'could not connect to database : '. mysql_error();
}
print $tmp;
?

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



Re: [PHP-DB] inserting data into database!

2004-05-14 Thread Daniel Clark
$tmp isn't defined yet, so can't append to it's self.
(no .= )

$tmp = ID   : $row-ID   br\n;


 Two questions?
 First why am I getting  undefined variable tmp , yet it works
 Second how would I insert data into this table?
 ?
 $db_table = 'log';
 $conn = mysql_connect($db_host,$db_user,$db_pass);

 if ($conn == true) {
   mysql_select_db($db_name,$conn);
   $result = mysql_query(SELECT * from $db_table,$conn);
 while($row = mysql_fetch_object($result)) {
 $tmp .= ID   : $row-ID   br\n;
 $tmp .= Base : $row-Base br\n;
 $tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
 $tmp .= Event_Type : $row-Event_Type br\n;
 $tmp .= Description : $row-Description br\n;
 $tmp .= Initials : $row-Initials brhr\n;
 }
 } else {
 echo 'could not connect to database : '. mysql_error();
 }
 print $tmp;
 ?

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