SitePoint Sponsor

User Tag List

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

    Exclamation mysql functions not working. Followed all installation instructions given in book

    Hi!

    I'm facing a problem here.

    I bought 'Build your own database driven website using PHP & MySQL' yesterday.

    I installed Apache, PHP & MySQL on Ubuntu, following the instructions given in the book.

    However, when I include functions such as mysql_connect() or other mysql related functions in PHP files, they don't work!

    Even the following snippet of code didn't work out -

    PHP Code:
    <?php
    $con 
    mysqli_connect("localhost","root",<my password>);
    if (!
    $con)
      {
      echo 
    "Try again";
      }
    echo 
    $con;

    // some code
    ?>
    It didn't give any output! There was a blank page!

    Otherwise, PHP files are running accurately(which means even Apache is working fine).

    MySQL is also running fine when I access it in the terminal.

    However, I'm unable too run mysql functions.

    I think I squandered my money on the book.

    Please help me out!!!!!

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Place the following at the top of your script, it should help you pinpoint the problem.
    PHP Code:
    error_reporting(-1);
    ini_set('display_errors'true); 
    Quote Originally Posted by sanchit View Post
    I think I squandered my money on the book.
    You would have only squandered you money if you were not learning anything, as you don't know how to get this working...
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure you run your text editor that you wrote the code in as administrator.

  4. #4
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation

    Quote Originally Posted by AnthonySterling View Post
    Place the following at the top of your script, it should help you pinpoint the problem.
    PHP Code:
    error_reporting(-1);
    ini_set('display_errors'true); 

    You would have only squandered you money if you were not learning anything, as you don't know how to get this working...
    Thanx for your reply!!

    I got the following error -

    Code:
    Fatal error: Call to undefined function mysqli_connect() in /var/www/try.php on line 4
    Looks like PHP hasn't configured MySQL.
    Moreover, phpMyAdmin says 'MySQL extension is missing' whereas MySQL is running. To ensure that I had followed the book correctly, I reinstalled everything.

    Please help me out!

    Maybe if I'm able to get the scripts running, my investment in the book won't seem to be squandering

    Please help!

  5. #5
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I'm not familiar with the books installation procedure, but have you tried...
    Code:
    sudo apt-get install php5-mysql
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  6. #6
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dibley View Post
    Make sure you run your text editor that you wrote the code in as administrator.
    I have been doing that. Thanks anyway!

  7. #7
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    I'm not familiar with the books installation procedure, but have you tried...
    Code:
    sudo apt-get install php5-mysql
    Thanx! Got the following error -

    Code:
    Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /var/www/try.php on line 4 Could not connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
    Plzzz help!

  8. #8
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    I deleted the mysql directory & reinstalled mysql using
    Code:
    sudo apt-get install mysql-server
    Things seem to be fine now. Thanks for your help!


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
  •