Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


 
 Re: php/mysql problem
Author:  (203.106.219.---)
Date:   02-25-04 16:42

Hm..I change a bit--it works fine.

INSERT FILE

<?php
// Connect to the database
$dbhost = 'localhost';
$dbusername = 'testuser';
$dbpasswd = 'testpassword';
$database_name = 'simple';

$connection = mysql_connect($dbhost,$dbusername,$dbpasswd)
or die ("Could not connect to server.");
$db = mysql_select_db($database_name, $connection)
or die("Could not select database.");

// Generate SQL code to store data on database.
$insert_sql = "INSERT INTO simple_table (text) VALUES ('test text, 1,2,3')";

// Execute SQL code.
mysql_query( $insert_sql )
or die ( "It Did not Work: ".mysql_error() );

// Tell User we are done.
echo "Data Inserted";
?>

QUERY FILE

<?php
// Connect to the database
$dbhost = 'localhost';
$dbusername = 'testuser';
$dbpasswd = 'testpassword';
$database_name = 'simple';

$connection = mysql_connect($dbhost,$dbusername,$dbpasswd)
or die ("Could not connect to server.");
$db = mysql_select_db($database_name, $connection)
or die("Could not select database.");

// Generate code to retrieve data from database.
$select_sql = "SELECT text FROM simple_table ";

echo $select_sql;

// Retrieve code from database.
$result = mysql_query( $select_sql ) or die ( "It Did not Work: " . mysql_error() );

// Display results to user.
while ( $row = mysql_fetch_object ( $result ) )
{
echo $row->text . "<br>" ;
echo "PHP is working.<br>";
}
?>

 Topics Author  Date
 php/mysql problem  new
Doug 02-24-04 12:09 
 Re: php/mysql problem  new
bastien 02-24-04 12:35 
 Re: php/mysql problem  new
Doug 02-25-04 04:17 
 Re: php/mysql problem  new
Mhadf 02-25-04 08:05 
 Re: php/mysql problemSTILL NOT WORKING  new
Doug 02-25-04 09:30 
 Re: php/mysql problem  new
bastien 02-25-04 05:25 
 Re: php/mysql problem  new
Doug 02-25-04 05:43 
 Re: php/mysql problem  new
eon 02-25-04 16:42 
Go to Top  |  Go to Topic  |  Flat View  |  Search 
  |  
New Topic
 Reply To This Message
 Your Name:
 Your Email:
 Subject:
Email replies to this thread, to the address above.
    

Provided By
Phorum