Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-2006, 10:52 AM
Chan Chan is offline
Programming Professional
 
Join Date: Jun 2006
Posts: 204
Rep Power: 9
Chan is on a distinguished road
Default How do I make a Mysql Database Connection

I'm not sure that I am doing this correctly so can someone post some code how they connect to a MySQL database?

I've got
PHP Code:
MySQL_Connect();
$query "Select * FROM test";
MySql_Query($query); 
but nothing returns.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-17-2006, 11:00 AM
Void's Avatar   
Void Void is offline
Programming Expert
 
Join Date: Jun 2006
Posts: 410
Rep Power: 11
Void is on a distinguished road
Default

You have the mysql_connect() empty. It should have more values. You should also select your database.

PHP Code:
$username "myUser";
$password "myPassword";
$server "localhost";

// Connect to MySQL
mysql_connect($server,$username,$password
     or die (
"Unable to connect to MySQL server.");

// Select the Database
$db mysql_select_db("myDB"
     or die (
"Unable to select database");

// Run your query
$query "SELECT * FROM test";
$results mysql_query($query);

// Get your results
$myrow mysql_fetch_row($results); // You can also use a while loop for multiple results 
__________________
Void
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying mysql data into jtextfield.Pls help iz.ziffa Java Help 1 05-31-2007 10:58 AM
Ban IPs with MySQL database Jaan PHP Tutorials 0 01-15-2007 02:13 PM
How to make Dumplings ahsan16 The Lounge 2 01-11-2007 10:55 PM
Simple MySQL Database Search Jaan PHP Tutorials 1 01-01-2007 10:15 AM
Mysql remote connection Crane Database & Database Programming 2 09-02-2006 11:53 AM


All times are GMT -5. The time now is 01:19 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
sam ........ 20.00000
gaylo565 ........ 18.00000
|pH| ........ 15.00000
WingedPanther ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads