Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 27-05-2008, 04:09 PM
Novice Webmaster
 
Join Date: Jul 2007
Location: Kuala Lumpur
Posts: 12
Rep Power: 0
JDream is on a distinguished road
Question Connect To Database

Hello all,

Now before I proceed, please allow me to state my case: I'm very new to PHP, but not so new til I do not know what it is. I do read up on every single documentation/PHP website/manual I can get my hands on, and it's good.

But now I cannot solve one problem only so far, and it is the "mysql_connect" problem. Rest assured I have tried many, many times before I decided to post up my question here.

I am the only "so-called" web designer in my company, so there is no one else to help me. I read the docs, PDF files etc but I cannot even understand the connect part in the first place, which leaves this forum as my last resort to get advice from the real pros.

I have already successfully installed Apache, MySQL Server 5.0, and the basic PHP scripts run fine, so everything should be alright.

It's just that seriously, I cannot understand why when I type :-

<?php
mysql_connect("localhost", "root", "root1") or die(mysql_error());
echo ("Connected to database");
?>

it just doesn't show nor does it give any error. MySQL is running, and the database created runs fine. So I am now wondering what else went wrong?

Is it :-

1. Create database in MySQL using the SQL scripts, then
2. Write the php code to connect to the database?

or did I left out some steps? Please do help a genuine lost PHP newbie. Thanks and regards.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 27-05-2008, 04:27 PM
Seanie's Avatar
Senior Webmaster
 
Join Date: Mar 2008
Location: pd
Posts: 224
Rep Power: 11
Seanie has a spectacular aura about Seanie has a spectacular aura about
You shouldn't need to set up a database (I mean like 'create database' in MySQL) or tables to connect to a running server. Are you sure your PHP is being executed by your web server? Is your script part of a larger page? Do you get the rest of the page? I'm not sure about how 'lazily' PHP executes code. You don't assign or use the return value from mysql_connect, and some languages don't evaluate functions whose return values aren't used. Maybe instead of die(), try error_log("hello! I'm not working"), and check in your web server's error log for evidence the code executed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 27-05-2008, 05:48 PM
Novice Webmaster
 
Join Date: Jul 2007
Location: Kuala Lumpur
Posts: 12
Rep Power: 0
JDream is on a distinguished road
Thank you

Hi Seanie,

Thank you for your prompt reply. I am still figuring out how to do it, and I will try out your methods. I'm using my local machine as the test server as my company has set all theirs to run only ASP.NET

So far, I've referred to a number of documentations and they just set up the Apache + MySQL server, and jump straight to creating the database and tables itself.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-06-2008, 07:08 PM
Novice Webmaster
 
Join Date: Mar 2008
Location: Sabah
Posts: 47
Rep Power: 0
Monie is on a distinguished road
How about your MySQL ODBC driver? Did you installed them?
__________________
So much to learn.. So little time!
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 Rate This Thread
Rate This Thread:

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
Aductions Is Arriving Malaysia, Connect Advertisers and Publishers Aductions Revenue and Monetization 0 04-04-2008 12:26 PM
how to connect to mysql5.0 from php4? help me plzz SolidLucky Website Programming 4 18-01-2007 09:30 AM
can't connect to mysql server on localhost nurulmajdi Website Programming 6 16-02-2004 03:57 PM
Linux mandrake can connect to streamyx?? tkh135 Mamak Stall 13 27-07-2003 12:34 PM
OOP dan Database kidino Website Programming 0 07-10-2002 06:25 PM



All times are GMT +8. The time now is 07:24 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59