Go to Post Adding an ounce or two of shields is way easier than filling out the mountains of paperwork for that one impatient person to stick their arm into the robot reaching for who knows what only to have their fingers meet up close and personal with a gearbox. - artdutra04 [more]
Home
Go Back   Chief Delphi > Technical > IT / Communications > Website Design/Showcase
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-01-2003, 07:58
apk apk is offline
Hi Everyone, I'm Back.
AKA: Andrew K.
#0104 (Team Universal)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: West Chester, PA
Posts: 206
apk will become famous soon enough
Send a message via ICQ to apk Send a message via AIM to apk Send a message via MSN to apk Send a message via Yahoo to apk
Question XML to MySQL

I'm looking for help or sample code that I can use to change an XML page to data to be uploaded to a MySQL server. Anything will help.


I forgot to add: in php, and i already have a working server.

I already know a good amount of php.

Last edited by apk : 17-01-2003 at 15:54.
  #2   Spotlight this post!  
Unread 17-01-2003, 09:09
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
php, c++, asp, vb, ... what language do you want it in?
__________________
Brandon Martus
e-mail
  #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.
  #4   Spotlight this post!  
Unread 17-01-2003, 15:00
HFWang's Avatar
HFWang HFWang is offline
Registered User
AKA: DarkWulf
#0115
Team Role: Webmaster
 
Join Date: Jan 2003
Location: Cupertino
Posts: 177
HFWang will become famous soon enough
Send a message via ICQ to HFWang Send a message via AIM to HFWang
PHP Code:
#----------------------------------------#
#               Functions:               #
#              DB Functions              #
#----------------------------------------#

function dbcon() { #Obviously, this connects to the SQL server, using the values from qzconfig.php
 
global $dbhost$dbuser$dbpass$db;
 
$sql_server = @mysql_connect($dbhost,$dbuser,$dbpass)
  or die(
"<b>Fatal Error:</b><br /><b>MYSQL:</b> Unable to connect to mySQL server.");

  
mysql_select_db($db,$sql_server)
   or die(
"<b>Fatal Error:</b><br /><b>MYSQL:</b> Unable to query mySQL server.");
}

function 
dbquery($sql) { #For custom queries
 
global $result$querycount;
     
$result mysql_query($sql) or die("Your SQL query: <br />$sql<br /><br />MySQL said:<br />".mysql_error());
    
$querycount++;

Is what I use to make DB connections and queries. Its a tad shorter than Steve's but you are shorting yourself of the ordering and such. (Which IMO is actually better, because I'd rather be able to control the exact DB Query.... but thats just me)

Call dbcon(); then dbquery('SQL QUERY');

I also have an additional config file to insert the variables, but I don't think you want my password.
  #5   Spotlight this post!  
Unread 17-01-2003, 15:19
Jeremy_Mc's Avatar
Jeremy_Mc Jeremy_Mc is offline
GitHubber
no team
Team Role: Mentor
 
Join Date: Feb 2002
Rookie Year: 2002
Location: Orlando, FL
Posts: 496
Jeremy_Mc will become famous soon enoughJeremy_Mc will become famous soon enough
i know if i didn't know php that well those code snippets would confuse the crap out of me haha...

the second one is a little easier to grasp...look around on a lot of open source sites (pscode.com, sourceforge.net even...) they can provide step by step tutorials on this subject.

*jeremy
__________________
GitHub - Collaborate on code, documentation, etc. - http://github.com
  #6   Spotlight this post!  
Unread 17-01-2003, 15:37
HFWang's Avatar
HFWang HFWang is offline
Registered User
AKA: DarkWulf
#0115
Team Role: Webmaster
 
Join Date: Jan 2003
Location: Cupertino
Posts: 177
HFWang will become famous soon enough
Send a message via ICQ to HFWang Send a message via AIM to HFWang
my assumption was that he knew PHP already. sorry.

go here:
http://www.webmasterbase.com/article/528
for an explanation of using PHP/MySQL. You might want to read the rest of the tutorial... but this is what i found truly pertinent.

If you don't already, try getting PHP My Admin ( http://www.phpmyadmin.net/ )

and, i'm not sure what you are asking. People have provided examples of PHP generating say, HTML from MySQL, but if you are trying to take XML and parse it, it really depends on what you are trying to do...
  #7   Spotlight this post!  
Unread 17-01-2003, 15:48
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
www.w3schools.com

They provide anything you'd wanna know about learning XML. (and other w3.org stuff)
__________________
Brandon Martus
e-mail
  #8   Spotlight this post!  
Unread 17-01-2003, 15:56
apk apk is offline
Hi Everyone, I'm Back.
AKA: Andrew K.
#0104 (Team Universal)
Team Role: Alumni
 
Join Date: Dec 2002
Rookie Year: 2002
Location: West Chester, PA
Posts: 206
apk will become famous soon enough
Send a message via ICQ to apk Send a message via AIM to apk Send a message via MSN to apk Send a message via Yahoo to apk
I know a lot of php. What I am trying to do is take data from a XML page, and insert it into a MySQL db. I am also hoping to do this useing php.
  #9   Spotlight this post!  
Unread 17-01-2003, 17:09
HFWang's Avatar
HFWang HFWang is offline
Registered User
AKA: DarkWulf
#0115
Team Role: Webmaster
 
Join Date: Jan 2003
Location: Cupertino
Posts: 177
HFWang will become famous soon enough
Send a message via ICQ to HFWang Send a message via AIM to HFWang
what kind of data?

can i see the XML page?
  #10   Spotlight this post!  
Unread 17-01-2003, 23:13
Brandon Martus's Avatar Unsung FIRST Hero
Brandon Martus Brandon Martus is offline
busy.
AKA: B. Slash Kamen
no team
 
Join Date: May 2001
Rookie Year: 1998
Location: Nevada, TX USA
Posts: 5,271
Brandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond reputeBrandon Martus has a reputation beyond repute
Send a message via ICQ to Brandon Martus Send a message via AIM to Brandon Martus Send a message via Yahoo to Brandon Martus
Quote:
Originally posted by apk
What I am trying to do is take data from a XML page, and insert it into a MySQL db. I am also hoping to do this useing php.
I assume you know how to insert into mysql and are looking for how to parse the XML.

Check out the two links at the very bottom of this page: http://www.chiefdelphi.com/forums/mi...?s=&action=xml

One is an example on how to parse the XML that runs the 'last 10 threads on my page' thing from chiefdelphi. The other is the manual page for parsing XML with php.

Hope that helps a bit.
__________________
Brandon Martus
e-mail
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Parsing Jack FIRST Scouting Network 1 12-10-2003 13:36
XML And Link Raven_Writer Website Design/Showcase 13 26-09-2003 17:24
xml Jack FIRST Scouting Network 0 01-09-2003 16:23
Message Boards w/o MySQL iBob Website Design/Showcase 7 13-07-2003 02:00
MySQL query question Jack Website Design/Showcase 9 02-02-2003 00:11


All times are GMT -5. The time now is 02:02.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi