Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 10th, 2004, 12:59 AM
Authorized User
 
Join Date: Apr 2004
Posts: 87
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


 
Old November 10th, 2004, 06:21 AM
Authorized User
 
Join Date: Oct 2004
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
 
Old November 10th, 2004, 06:28 AM
Authorized User
 
Join Date: Oct 2004
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
 
Old November 11th, 2004, 11:14 AM
Authorized User
 
Join Date: Apr 2004
Posts: 87
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



 
Old November 11th, 2004, 11:54 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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!
 
Old November 12th, 2004, 05:41 AM
Authorized User
 
Join Date: Oct 2004
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
 
Old November 12th, 2004, 04:28 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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!
 
Old November 15th, 2004, 07:13 AM
Authorized User
 
Join Date: Oct 2004
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
 
Old November 16th, 2004, 05:27 AM
Friend of Wrox
 
Join Date: Mar 2004
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 !!

 
Old November 16th, 2004, 02:38 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
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!









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.