Results 1 to 4 of 4

Thread: Connect To Database

  1. #1
    Join Date
    Jul 2007
    Location
    Kuala Lumpur
    Posts
    15
    Rep Power
    0

    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.

  2. #2
    Join Date
    Mar 2008
    Location
    pd
    Posts
    497
    Rep Power
    147
    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.

  3. #3
    Join Date
    Jul 2007
    Location
    Kuala Lumpur
    Posts
    15
    Rep Power
    0

    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.

  4. #4
    Join Date
    Mar 2008
    Location
    Sabah
    Posts
    51
    Rep Power
    138
    How about your MySQL ODBC driver? Did you installed them?
    So much to learn.. So little time!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Google Friend Connect
    By yonghs in forum Online Community Building
    Replies: 7
    Last Post: 10-07-2009, 05:23 PM
  2. How to connect asp programming with access database??
    By kuumasang_n33 in forum Website Programming
    Replies: 2
    Last Post: 30-08-2008, 02:05 PM
  3. how to connect to mysql5.0 from php4? help me plzz
    By SolidLucky in forum Website Programming
    Replies: 4
    Last Post: 18-01-2007, 09:30 AM
  4. can't connect to mysql server on localhost
    By nurulmajdi in forum Website Programming
    Replies: 6
    Last Post: 16-02-2004, 03:57 PM
  5. Linux mandrake can connect to streamyx??
    By tkh135 in forum Mamak Stall
    Replies: 13
    Last Post: 27-07-2003, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

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