SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Cannot connect to mySQL ???

    hi there,
    I installed phpv5.0.3 and mySQLv4.1 in my system. There is an already configured IIS Server too. I made a php file with the name "test.php" and copied it into the "www" root folder of Inetpub. The following is a php code I wrote :

    PHP Code:
    <html>
    <body>
    <?php
    $db 
    mysql_connect("$localhost""$root","$sqlserver") or die("Invalid server or user.");
    mysql_select_db("student",$db);
    $sql "INSERT INTO info VALUES ('dilip',20);";
    $result mysql_query($sql);
    ?>
    <body>
    <html>
    In the iexplore address bar, I typed http://localhost/test.php

    The file is rightly recognized as a php file and is executing too. But, I get the following error message :

    Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\test.php on line 4

    mySQL is installed and confiured to localhost with username : root and password : sqlserver.

    Please help me !!!
    Last edited by plomon; Feb 8, 2005 at 22:06.

  2. #2
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no mysql default support into php5

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, what should I do now ??? Please help !!

  4. #4
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <html> 
    <body> 
    <?php 
    $db 
    = @mysql_connect("localhost""root","sqlserver") or die("Invalid server or user."); 
    mysql_select_db("student",$db); 
    $sql "INSERT INTO info VALUES ('dilip',20)"
    $result mysql_query($sql) or
    die(
    "cannot inser into Database"); 
    ?> 
    <body> 
    <html>
    tried it out
    -::Ujjwal::-
    Visit My Site

  5. #5
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    2 Ujjwal

    yeap, he'll not see error, but will it work?

    2 plomon
    I dont know what you should do in win, but I heard you should put any .dll... Ask google it is frequent error

  6. #6
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by St.
    2 Ujjwal

    yeap, he'll not see error, but will it work?
    yes Sir, it works in apache server as well as iis.
    He has also wrong in sql query .He has given 2 ";" instead of right one.
    I think it works lets see what the guy's answer.
    -::Ujjwal::-
    Visit My Site

  7. #7
    SitePoint Guru ujjwal's Avatar
    Join Date
    Oct 2004
    Location
    kolkata
    Posts
    821
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can check it out.
    also u can check u'r sql query there is 2 ;.
    PHP Code:
    <?php 
    $dbhost 
    "localhost"
    $dbusername "root"
    $dbpassword "sqlserver"
    $dbname "student"


    $connect = @mysql_connect $dbhost,$dbusername,$dbpassword ) or
    die (
    "Could not connect ".mysql_error());
    mysql_select_db($dbname,$connect) or
    die(
    "Could not select database".mysql_error());

    ?>
    -::Ujjwal::-
    Visit My Site

  8. #8
    Non-Member St.'s Avatar
    Join Date
    Nov 2004
    Location
    Cloud #9
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and what is it?
    Fatal error: Call to undefined function mysql_connect()


Bookmarks

Posting Permissions

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