Jump to content

philipjordan9999

New Members
  • Posts

    3
  • Joined

  • Last visited

philipjordan9999's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Nah, it was my stupidity. A simple sudo apt-get install php5-mysql did the job. Thanks.
  2. Hi, I work in an educational establishment with a relatively small in-house IT department, and have offered to knock up a 'knowledge base' to allow them to track tickets, log solutions etc. It's not why I was hired, I'm not getting paid to do it, and frankly, if it never got done, no one's going to come down and hassle me. So look on it as an education for me, I get to learn something new, and get some nice big Linux servers to play with. However, I'm not going to get far, if I can't at least get the code to work. So with a copy of the famous O'Reilly book, I get to the bit where the results of a query are printed to the webpage. I've changed the code slightly to reflect my organisation's site, and of course have edited what I copy and paste here, but only to conceal certain bits that I don't want on the web. <?php // read in the database credentials include('credentials.php'); // print the banner echo ("<html><head><title>The Organisation's Knowledge Base</title></head>"); echo ("<link href=\"css/main_stylesheet.css\" rel=\"stylesheet\">"); echo ("<a href=\"http://www.our-website.com\"><img src=\"images\/logo.png\"></a>"); echo ("<hr>") ; echo ("<h3>"); echo ("<p align=\"right\">Welcome to The Organisation's Knowledge Base"); echo ("<p align=\"left\">"); // connect to the database $link = mysql_connect('$db_host', '$db_username', '$db_password') or die("Connection Failed : " . mysql_error()); // select the 'knowledge' database $db_select=mysql_select_db($db_database); if (!$db_select) { die ("Could not select < /br>". mysql_error) ; } // run the query // first, define the variable for the query $myQuery = "SELECT user_id,s_name,f_name,is_admin FROM users ORDER BY user_id" ; // now run the query... $myResult = mysql_query($myQuery); if (!$myResult) { die ("Could not run query... < /br>" . mysql_error()) ; } // loop it out while ($result_row = mysql_fetch_row($myResult)) { echo $result_row[2] . '<br />' ; } // close the link mysql_close($link); // close the HTML echo ("</html>"); ?> The credentials file which is included, looks like this... <?php $db_host='localhost'; $db_database='knowledge'; $db_username='dba'; $db_password='whatthepasswordis'; ?> The SQL query functions flawlessly when run from within the mysql client, and four records are displayed. However, run from within a browser, it just does nothing. Not even an error message. The white background contrasts beautifully with our logo, and then the 'Welcome' message. And then.. nothing. None of the above was what I thought beyond me, even if I have only been doing this for a week or so in my spare time. A fresh pair of eyes would be most welcome here. Thank you in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.