Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 05:35 pm EST

Geeklog Forums

MYSQL DB connect test script


Anonymous

Anonymous

If you are having trouble connecting to your db, it may be easier to use a simpler connection script first to see if you have your db setup correctly, before installing GL.

Try saving the code betwen the ====== as mysqlconnect.php and call it in your browser. It will give a basic connection or tell you it can't.

===============================

Text Formatted Code

<?php
    $link = mysql_connect("localhost", "PUT_USERNAME_HERE", "PUT_PASSWORD_HERE")
        or die ("Could not connect");
    print ("Connected successfully");
    mysql_select_db ("PUT-DB-NAME-HERE")
        or die ("Could not select database");
   
    $query = "SELECT * FROM PUT-TABLE-NAME-HERE";
    $result = mysql_query ($query)
        or die ("Query failed");

        // printing HTML result

        print "<table>\n";
        while ($line = mysql_fetch_array($result)) {
            print "\t<tr>\n";
            while(list($col_name, $col_value) = each($line)) {
                print "\t\t<td>$col_value</td>\n";
            }
            print "\t</tr>\n";
        }
        print "</table>\n";
   
    mysql_close($link);
?>
 

===============================

GF

 Quote

geeklog@whatic.c

Anonymous
haha - still not simple enough, afraid all these docs don't explain what is obvious to you but not at all clear to me... - so what does it mean to get: Connected successfullyQuery failed
 Quote

Anonymous

Anonymous
Do you have any tables in your DB to query? If not your query will definately fail. If you connected ok to an empty database try using phpmyadmin (an excellant easy to use database management tool available from sourceforge.net) to populate it with some tables and data. You can do this by going to the SQL option in phpmyadmin and browse to an .sql file of your choice (a file containg table configuration and data to insert into your DCool and load it into your db. Then try running the test connect script again. Don't do this to your working Geeklogs DB (you might corrupt it), just create a test DB and populate it with any .SQL file that has tables and data (could be Geeklogs sql file). Once things are working ok you can drop the data,tables or DB if you like to be tidy. If that all works ok you now know the correct settings to use in your GL Config.php file, e.g., ======================== $_DB_dbms = 'mysql'; // Currently only MySQL is support, do not change $_DB_host = 'localhost'; $_DB_name = 'geeklog'; // Yes, your DB must exists before running installer! $_DB_user = 'yourusername'; $_DB_pass = 'yourpassword'; $_DB_table_prefix = 'gl_'; // e.g. 'gl_' ======================== GF
 Quote

All times are EST. The time is now 05:35 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content