Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
problem :connecting to database
Results 1 to 10 of 10

Thread: problem :connecting to database

Hybrid View

  1. #1

    problem :connecting to database

    hey everyone!!!!
    well i have got a problem with connecting to a mysql database using php. I used this package "mysql-noinstall-5.1.44-win32.zip" and extracted it to c:\mysql and added c:\mysql\bin to the PATH variable and used the following command in command prompt to start mysql:
    c:\mysql\bin\mysqld --standalone
    well mysql did start and everything went well accessing mysql in command prompt. Well under the database "mysql" in the table "user" i created a new user "php" with a password="****" and hostname = "localhost" but when i try to access this database with a following php routine:

    //test.php
    <?php
    $username = "php";
    $password = "****";
    $hostname = "localhost";
    echo $hostname;
    $connection = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
    echo "Connected to MySQL";
    ?>

    and when i accesses it with my browser using localtost/test.php, all i get is "localhost" displayed on screen, "Connected to mysql" never gets displayed not i get any error..
    note: i am using windows 7(32-bit-ultimate)and mysql 5.1.44.
    any help will be appreciated....thxxx

  2. #2
    Administrator Advisor peter's Avatar
    Join Date
    Apr 2004
    Posts
    882
    What error do you get in your mysql or webserver logs? That will give you an idea of what is going wrong.

    If you don't get the "Connected to MySQL" message it's because the $connection line is incorrect somehow.

    With Linux, you need to install a PHP-MySQL package in order for PHP to work correctly with MySQL. I'm not sure whether you need to do the same thing for Windows.

    My sites:
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    -
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  3. #3
    ok now i set display_error "ON" in php.ini file and now its displaying this error for my mysql_connect() command:

    Fatal error: Call to undefined function mysql_connect() in C:\webroot\test.php on line 7
    any ideas??
    Last edited by aimseeker; 03-01-2010 at 02:43 PM.

  4. #4
    Administrator Advisor peter's Avatar
    Join Date
    Apr 2004
    Posts
    882
    It's probably because you don't have the library with the mysql_connect() function. See if there is an additional PHP/MySQL package you need to install, or maybe you have to include a reference to the library near the top of your script.

    Have you looked at other PHP mysql examples on the web?

    My sites:
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    -
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  5. #5
    dude can u refer me to some manual or somethign coz am not completely getting u!!!
    and yeh i did used a script from some website and even that didnt work :-(

    thxxx

  6. #6
    ok to be more specific i found these settings about mysql in php.ini:
    [MySQL]
    ; Allow or prevent persistent links.
    mysql.allow_persistent = On

    ; Maximum number of persistent links. -1 means no limit.
    mysql.max_persistent = -1

    ; Maximum number of links (persistent + non-persistent). -1 means no limit.
    mysql.max_links = -1

    ; Default port number for mysql_connect(). If unset, mysql_connect() will use
    ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
    ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
    ; at MYSQL_PORT.
    mysql.default_port =

    ; Default socket name for local MySQL connects. If empty, uses the built-in
    ; MySQL defaults.
    mysql.default_socket =

    ; Default host for mysql_connect() (doesn't apply in safe mode).
    mysql.default_host =

    ; Default user for mysql_connect() (doesn't apply in safe mode).
    mysql.default_user =

    ; Default password for mysql_connect() (doesn't apply in safe mode).
    ; Note that this is generally a *bad* idea to store passwords in this file.
    ; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
    ; and reveal this password! And of course, any users with read access to this
    ; file will be able to reveal the password as well.
    mysql.default_password =

    ; Maximum time (in seconds) for connect timeout. -1 means no limit
    mysql.connect_timeout = 60

    ; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
    ; SQL-Errors will be displayed.
    mysql.trace_mode = Off

    ; Windows Extensions
    ; Note that ODBC support is built in, so no dll is needed for it.
    ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
    ; extension folders as well as the separate PECL DLL download (PHP 5).
    ; Be sure to appropriately set the extension_dir directive.

    ;extension=php_mysql.dll
    can u help me adjust these values??
    thxxxx

  7. #7
    Administrator Advisor peter's Avatar
    Join Date
    Apr 2004
    Posts
    882
    I don't think it's a configuration problem. For example in Fedora 12, http://mirror.stanford.edu/fedora/li...6/os/Packages/ you have to install the php-mysql-5.3.0-6.fc12.i686.rpm package in addition to the php-5.3.0-6.fc12.i686.rpm package to get PHP to work with MySQL. The additional libraries I was talking about are located in php-mysql-5.3.0-6.fc12.i686.rpm.

    My sites:
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    -
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  8. #8

    Problem solved!!!

    ok this post solved my problem!!!
    1.Search your server for libmysql.dll. Delete any instance of libmysql.dll that is not in the C:\PHP directory. This limits the possibility of older MySQL client API's being used with PHP.

    2.Search your server for php_mysql.dll. Delete any instance of php_mysql.dll that is not in the C:\PHP directory. This limits the possibility of older MySQL client API's being used with PHP.

    3.Open your C:\%WIN%\php.ini file in a text editor (Notepad will work).

    Search for the line that looks like --> ;extension=php_mysql.dll

    Change this line to --> extension=php_mysql.dll

    Uncomment: extension_dir="c:\php\ext"

    Save the modified php.ini file.

    4. Copy php.ini to C:\%WIN%\System32

    5. Copy C:\PHP\libmysql.dll and C:\PHP\ext\php_mysql.dll to the C:\%WIN%\system32 folder.
    thxx everyone!!!

  9. #9
    Administrator Advisor peter's Avatar
    Join Date
    Apr 2004
    Posts
    882
    Good to know it was a library issue, the DLL seems to be the equivalent to the SQL library for PHP.

    My sites:
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
    -
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  10. #10
    Newbie
    Join Date
    Aug 2012
    Location
    http://www.buywholesaledvd.com/
    Posts
    3
    you need to install a PHP-MySQL package in order for PHP to work correctly with MySQL. I'm not sure whether you need to do the same thing for Windows.

Similar Threads

  1. Database Sharing Problem
    By jcroft01 in forum Windows - General Topics
    Replies: 0
    Last Post: 01-07-2006, 08:48 PM
  2. problem connecting to win2003 server
    By maenemy in forum Windows - General Topics
    Replies: 1
    Last Post: 09-23-2005, 01:40 PM
  3. Problem in connecting to FTP Server.
    By mohank in forum Linux - General Topics
    Replies: 2
    Last Post: 03-20-2005, 07:20 AM
  4. problem in connecting to postgreSQL 7.3.2
    By rameshvl in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 04-22-2003, 12:13 PM
  5. Problem with OpenOffice1.0 (database)
    By papanohair in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 07-16-2002, 04:57 AM

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
  •