Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:48:29+00:00 2026-05-23T01:48:29+00:00

Here is my following tutorial code from Learning PHP MYSQL and Javascript by OReilly.

  • 0

Here is my following tutorial code from “Learning PHP MYSQL and Javascript” by OReilly.

<?php 
//require_once = 'login.php';

$db_database = 'publications';
$db_hostname = 'localhost:8888';
$db_username = 'root';
$db_password = 'root';


$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if(!$db_server) die("Unable to connect to MYSQL: ". mysql_error());

mysql_select_db($db_database)
    or die("Unable to connect to database: " . mysql_error());

$query = "SELECT * FROM classics";
$result = $mysql_query($query);

if(!$result) die ("Could not query: " . mysql_error());
$rows = mysql_num_rows($result);

for($j = 0; $j < $rows; ++$j)
{
    echo 'Author: ' . mysql_result($result, $j, 'author') . '</br>';
    echo 'Title: ' . mysql_result($result, $j, 'title'). '</br>';
    echo 'ISBN: '.mysql_result($result, $j, 'isbn').'</br>';
}

?>

However, I’m getting an error when trying to connect. The browser says it’s a 500 error (which really isn’t that helpful). When I take out the lines $db_username = 'root'; $db_password = 'root'; I get another error saying: “Unable to connect to database: Access denied for user ”@’localhost’ to database ‘publications'”.

Can anyone help diagnose the problem?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:48:30+00:00Added an answer on May 23, 2026 at 1:48 am

    Change this

    $result = $mysql_query($query);
    

    to this

    $result = mysql_query($query);
    

    Function name is mysql_query not $mysql_query, $ is used in variable names.

    Also, instead of trying to “see” your code immediately in a browser window you could use a PHP command line instead. If your file is called foo.php you coudl do:

    >> php foo.php
    PHP Notice:  Undefined variable: mysql_query in /var/www/foo.php on line 17
    PHP Fatal error:  Function name must be a string in /var/www/foo.php on line 17
    

    As you see, the error message is pretty clear. Because of using $mysql_query it thinks that mysql_query is a variable, but such a variable is not defined somewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following code from here to read an Excel file using
I am trying to implement remote validation by following tutorial from Here but it
I was following the tutorial here: http://net.tutsplus.com/tutorials/php/how-to-authenticate-your-users-with-facebook-connect/ But I can't get past the first
I am a total Groovy newbie. I saw the following code here . def
I have seen the following code: [DefaultValue(100)] [Description(Some descriptive field here)] public int MyProperty{...}
I get the following compilation error: error: expected `;' before 'it' Here's my code:
I'm trying to do the python tutorial here http://code.google.com/appengine/docs/python/gettingstarted/helloworld.html (I have python 2.5 installed)
Following the discussions here on SO I already read several times the remark that
Here's the situation: I'm developing a simple application with the following structure: FormMain (startup
following the wealth of information found here how can we get an external .config

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.