Thread: XML to MySQL
View Single Post
  #3   Spotlight this post!  
Unread 17-01-2003, 10:39
steveg's Avatar
steveg steveg is offline
Livin' the Dream
AKA: Stephen Guerrera
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Boston, MA
Posts: 70
steveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to behold
Send a message via AIM to steveg
I would definitely recommend using PHP to interface with MySQL. They actually integrate quite nicely. If you own the web server but don't have PHP installed, there are no worries... it's free and even runs on Windows! to connect to a MySQL database and retrieve information from it (I guess it's a little more confusing than I thought for someone just starting out), all you have to do is something like:
PHP Code:
<?php 
// initial defines
$dbhost 'db.host.name';
$dbusername 'username';
$dbuserpassword 'pass';
$default_dbname 'default'
$default_sort_order 'DESC';
$default_order_by 'num';
$MYSQL_ERRNO '';
$MYSQL_ERROR '';

// connect function

function db_connect() {
   global 
$dbhost$dbusername$dbuserpassword$PHP_SELF$default_dbname;
   global 
$MYSQL_ERRNO$MYSQL_ERROR;
   
$link_id mysql_connect($dbhost$dbusername$dbuserpassword);
   if(!
$link_id) {
      
$MYSQL_ERRNO 0;
      
$MYSQL_ERROR "Connection failed to the host $dbhost.";
      return 
0;
   }

//   ...
//   error handling functions here (omitted for length)
//   ...


// the actual function to connect to the database

function database_connectivity() {
  global 
$defaul_dbname$default_tablename$PHP_SELF$view;
  global 
$default_sort_order$default_order_by$posts_per_page
  global 
$sort_order$order_by$cur_page;
  
$link_id db_connect($default_dbname);
  if(!
link_iderror_message(sql_error());
  
$order_by_str "ORDER BY '$default_order_by'";
  
$sort_order_str "DESC";
 
$query "SELECT * FROM `$default_tablename
  
$order_by_str $sort_order_str;
  while(
$query_data = mysql_fetch_array($result)) {
    
$num = $query_data["num"];
    
$date = $query_data["date"];
    
$text = $query_data["text"];
    ...
    }

    echo (" 
... ");
}

database_connectivity()
?>
If you have any questions regarding the language, the code, or life, the universe and everything, feel free to contact me.