PHP MYSQL query results in blank page.

I created table Jokes using mysql database. Placed the jokes.php file in my /html file.
when I run in webrowser http://192.168.1.101/html/jokeslist.php
I get get a yellow background. I have tested with simple php scripts to test and they work.
However incorporating mysql nothing happens.  
Is there some configuration that is incorrect for mysql or php, how can I troubleshoot.

Here is the script.  

 <head>
<title> Our List of Jokes </title>
</head>
<body bgcolor="yellow">
<?php

  // Connect to the database server
  $dbcnx = @mysql_connect('192.168.1.101', 'root', 'xxxxxxx');
  if (!$dbcnx) {
    die( '<p>Unable to connect to the ' .
         'database server at this time.</p>' );
  }

  // Select the jokes database
  if (! @mysql_select_db('mysql.Jokes') ) {
    die( '<p>Unable to locate the joke ' .
         'database at this time.</p>' );
  }

?>
<p> Here are all the jokes in our database: </p>
<blockquote>

<?php

  // Request the text of all the jokes
  $result = @mysql_query('SELECT JokeText FROM  mysql.Jokes');
  if (!$result) {
    die('<p>Error performing query: ' . mysql_error() . '</p>');
  }

  // Display the text of each joke in a paragraph
  while ( $row = mysql_fetch_array($result) ) {
    echo('<p>' . $row['JokeText'] . '</p>');
  }

?>

</blockquote>
</body>
</html>
dplinnaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

psadacCommented:
first, it's a very bad idea to store your tables in mysql database, use CREATE DATABASE mybase; and move your tables to this database.

second i think the problem is :

if (! @mysql_select_db('mysql.Jokes') ) {

which should be :

if (! @mysql_select_db('mysql') ) {

and :

$result = @mysql_query('SELECT JokeText FROM  mysql.Jokes');

should be :

$result = @mysql_query('SELECT JokeText FROM Jokes');
0
dplinnaneAuthor Commented:
I have modified code as suggested and created database test.  I still see the same result. I have tried modifying the if statements to true and false but I get no feedback "Unable to connect to the server or Cant locate database joke...."  
However when I run the same script with my webhost as opposed to my local linux box I at least get an eror message Unable to connect to the database server at this time.
This tells me there something wrong with my PHP or MYSQL setup on linux.

I am running Redhat 8 on my linux box and I cannot find file libphp4.so .

I found this information from another website.

***********************************************************Red Hat 8.0's included PHP install doesn't work with MySQL to begin with, but there are RPM modules available which can automatically configure it to work with MySQL.
***********************************************************

I will try the above first and see what happens. If you have any further input I would appreciate it.

Thanks.

<html>
<head>
<title> Our List of Jokes </title>
</head>
<body bgcolor="yellow">
<?php

  // Connect to the database server
  $dbcnx = @mysql_connect('192.168.1.101', 'root', 'lascverf');
  if (!$dbcnx) {
    die( '<p>Unable to connect to the ' .
         'database server at this time.</p>' );
  }

  // Select the jokes database
  if (! @mysql_select_db('test') ) {
    die( '<p>Unable to locate the joke ' .
         'database at this time.</p>' );
  }

?>
<p> Here are all the jokes in our database: </p>
<blockquote>

<?php

  // Request the text of all the jokes
  $result = @mysql_query('SELECT JokeText FROM Jokes');
  if (!$result) {
    die('<p>Error performing query: ' . mysql_error() . '</p>');
  }

  // Display the text of each joke in a paragraph
  while ( $row = mysql_fetch_array($result) ) {
    echo('<p>' . $row['JokeText'] . '</p>');
  }

?>

</blockquote>
</body>
</html>
0
psadacCommented:
i've forgotten important things, add :
error_reporting(E_ALL);
at the beginning of your script, at least during development phase.

could you verify that :
rpm -qa|grep php-mysql
returns something, if not you need to install php-mysql-XXXX.rpm
(sorry i don't use redhat so i don't know the version).

and finally one question : your webserver and database server run on the same host ?
if so use localhost instead of 192.168.1.101.

good luck :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.