Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 php connect mysql~

views
     
TSlucashii
post Jan 28 2006, 08:53 AM, updated 20y ago

Getting Started
**
Junior Member
288 posts

Joined: Nov 2004
From: msia/uk


I am new toward php and i have just install wamp trying out the online tutorial~I came across this script which i just cant get it to work...with this script it shud add the tables and fields which could be access in myphpadmin right?Thanks to pros here in advance~

<?
$user="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>

TSlucashii
post Jan 29 2006, 12:45 AM

Getting Started
**
Junior Member
288 posts

Joined: Nov 2004
From: msia/uk


thanks for the reply but i still cant seem to get the code to work.

I created this php code and save it as create.php...so i run this code on my explorer and this table that contains the field shud be accessible in myphpadmin?or do i need to do it manually in myphpadmin and then access it from php?

how do i change the password?cuz i am still using the default setting of the install mysql~

se7en: the code u gave me...where shud i put it?

i am still new to this php so any advice would be appreciated~Thanks~
TSlucashii
post Jan 30 2006, 08:32 AM

Getting Started
**
Junior Member
288 posts

Joined: Nov 2004
From: msia/uk


haha my bad cuz i am really a beginner and i havent really read through the whole myphpadmin configuration,its working ok now~thanks all the pros~

 

Change to:
| Lo-Fi Version
0.0149sec    1.66    6 queries    GZIP Disabled
Time is now: 23rd December 2025 - 08:31 AM