Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 9th, 2004, 11:59 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help me Please

Does any one tell me How to Connect PHP with MySql database please


Reply With Quote
  #2 (permalink)  
Old November 10th, 2004, 05:21 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

In the words of the virgin mary, RTFM ;)

http://www.php.net/mysql

Once you know the basics, its very simple. Connecting is a matter of using the command mysql_connect(), and mysql_query() to run a query.

Many shoes,

James/SiliconFuRy
Reply With Quote
  #3 (permalink)  
Old November 10th, 2004, 05:28 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

To get you started, try this(predefining the variables of course):

mysql_connect($hostname, $user, $pass) or die("Cannot connect to server!\n");
mysql_select_db($dbname) or die("Table unavailable!\n");

$sql = "Show tables";

$result = mysql_query($sql);

$result is now an identifier to the result list that the query returned.

mysql_fetch_array($result) will return the first row in the result, so implement this in a loop to go
through the result table row at a time and do whatever functions you need.

Many shows,

James/SiliconFuRy
Reply With Quote
  #4 (permalink)  
Old November 11th, 2004, 10:14 AM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes I try to use
mysql_connect($hostname, $user, $pass) or die("Cannot connect to server!\n");
function bu I get the following error
Undefind mysql_connect function
I'm using XP pro



Reply With Quote
  #5 (permalink)  
Old November 11th, 2004, 10:54 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

READ THE MANUAL.

If you had read the manual, it says that the MySQL library is no longer included with PHP 5.

Read the manual for instructions to install it.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote
  #6 (permalink)  
Old November 12th, 2004, 04:41 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

Is this some nazisom/communism/capitilism/shoeism by PHP not to include php by default? Or is it just a security thing?

Many shoes,

James/SiliconFuRy
Reply With Quote
  #7 (permalink)  
Old November 12th, 2004, 03:28 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

I assume you mean to not include MySQL by default....

I agree with you, it's kind of stupid. I searched on it and it gave me this:
http://us2.php.net/manual/en/faq.dat...ses.mysql.php5

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote
  #8 (permalink)  
Old November 15th, 2004, 06:13 AM
Authorized User
 
Join Date: Oct 2004
Location: Edinburgh, Scotland, United Kingdom.
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

Excuse my shoes, going by the time of posting it must have been nearing the Midday Feeding Frenzy...

Many shoes

JAmez
Reply With Quote
  #9 (permalink)  
Old November 16th, 2004, 04:27 AM
Friend of Wrox
 
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul
Default

Why2use PHP-MySQL on WinXPPRO !!

Better try install PHP 5 on Win2000 or 2003
Be ready to read documentation, download something from php.net and fix mysql by hit -n- trial

I'm better with PHP 4.3.4 :)

Why2use extra PHP 5 lieu 4.x.y !!

Reply With Quote
  #10 (permalink)  
Old November 16th, 2004, 01:38 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

Tell me, how does this post help anyone? Or are you just saying you don't care for XP? PHP runs almost the same cross-platform.

-Snib
Where will you be in 100 years?
Try new FreshView 0.2!
Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 02:15 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.