Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,845 members, 7,817,498 topics. Date: Saturday, 04 May 2024 at 01:15 PM

Help Connecting Php With Mysql - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Help Connecting Php With Mysql (997 Views)

Please Help Me Out With Mysql Distinct / Problem With Mysql, Phpmyadmin. Pls Help / Building Dynamic Websites With MySQL And PHP (2) (3) (4)

(1) (Reply)

Help Connecting Php With Mysql by timbalogs: 5:49pm On Apr 28, 2007
I run mysql and php on windows xp(using IIS), I run simple scripts on the php engine and it responds, but connecting to the mysql database is a headache.
When i run scripts like this inside my html script:
<html>
<body>
<?php
$dbcnx = @mysql_connect('localhost', 'user', 'psswd') or die('Unable to connect');
$pick_db = @mysql_select_db('newdb') or die('unable to choose db');
?>
</body>
</html>

what i get is a blank browser screen, and when i check the source code, the opening <body> tag is where the code ends.
Pls any help as how i can sucessfully connect to the database?
Re: Help Connecting Php With Mysql by my2cents(m): 5:07pm On May 02, 2007
If i understand your post, it is not a surprise you are printing blanks. All you have done is connect to your DB and to a table. There is no interaction (as in no select *, or whatever SQL action you want to perform) whatsoever, based on your code here, b/w you and the DB.

Try adding some kind of action and I bet you will get results.

I hope this helps.
Re: Help Connecting Php With Mysql by unixman: 10:15am On May 07, 2007
Hey why are you running PHP with ISS? You are better off with Apache. For your development environment, you can use Windows but if you have got another machine, you can use Linux or any other UNIX variants. I mean you can code and design your web interface Windows while you run your scripts on Linux on another box.

Configuring PHP, MySQL and Apache individually can be challenging for a newbie but there are helpful one-install products that will help. My favourite is XAMPP available at http://www.apachefriends.org/en/xampp.html. This is the link to download the Windows installer one - http://www.apachefriends.org/download.php?xampp-win32-1.6.1-installer.exe. I recommend this one. Please remember to disable or change the port for ISS. You might also have to take care of your previous MySQL installation. XAMMP will install Apache 2, PHP 5, MySQL 5 among others for you and configure them to work together.

Finally, here is a simple script to connect to your database.

<?

$db_name = "mysql"; // name of your database here
$db_username = "root"; // username for database here
$db_password = ""; // password for database here


$mysql_link = mysql_connect("localhost", "$db_username", "$db_password"wink or die( "Unable to connect to database server"wink;
@mysql_select_db( "$db_name"wink or die( "Unable to select database"wink;

?>

(1) (Reply)

Create Website In 30 Minutes Or Less Ebook Videos / Any Ruby On Rails Developer Around This Parts? / Check This Out

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.