PHP is not execute the query from mysql in Linux

Hi ,

I have ran the php script from Linux box. It is running, But I can able to see any html content. There is no mysql data on that page. I have checked .

1) Mysql and data bases are connected successfully.

Please help and guild me If I missed any think during the configuration.

Thanks,
Mani

without seeing your code, we cannot tell anything :frowning:

Refer here for the basic example of mysql with php

PHP/MySQL Tutorial - Part 4

The same code is working properly in Solaris server.

just execute the below code and check whether you can able to connet to the db properly or not

 
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?> 

repalce localhost,username and password

Yes, I can able to connect . I got the message the same connected successfully.

---------- Post updated at 01:01 AM ---------- Previous update was at 12:57 AM ----------

Hi, I have checked like this also

<?php
$link = mysql_connect('localhost', 'tst', 'start123');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully ';
echo ' fine fine';
#mysql_close($link);
$db = "tst";
mysql_select_db('tst', $link) or die('Could not select database.');
return $link;
?>

Please help me

Then check your select statement and try to process the resultset one by one. And make sure it retrieves the rows for the given query

Could you please give me that code for that select statement. Because i am a new to php.
If possible help me .

There is no mysql data on that page

How you are saying that, no mysql data ?

Check your script, it will have the select statement to retrieve the data from mysql DB

Yes, The same scripts show some data in solaris server. I have not changed any think.

---------- Post updated at 01:20 AM ---------- Previous update was at 01:17 AM ----------

Please help in this code.

<?php
$con = mysql_connect("localhost","tst","start123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("tst", $con);

$result = mysql_query("select Server,Service from MDServersToServices limit 5");

while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}

mysql_close($con);
?>

Note: I have to print on browser. Please help on this

Is it webpage code ? and you are trying to run on command line ?

If it is coded for the webpage, it will get some information from the user and the form contains the data and it will be passed to your php code. Based upon the passed values, it will retrieve or do some operation on db

this is a webpage code. what kind of the operation on db ?

---------- Post updated at 01:32 AM ---------- Previous update was at 01:24 AM ----------

Hi, I have used the below code

<?php
$con = mysql_connect("localhost","tst","start123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("tst", $con);

$result = mysql_query("select Server,Service from MDServersToServices limit 5");

echo "<table border='1'>
<tr>
<th>Server</th>
<th>Service</th>
</tr>";

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Server'] . "</td>";
echo "<td>" . $row['Service'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysql_close($con);
?>

Output is only
Server service

Note: There is no data retrieved from that table.

I hope that you can clear now

put your files under the WWW folder or htdocs in the apache installation folder.

And invoke the file in browser. (using server-name:port...blah..blah.. )

if you didnt get any output, then worth to check the apache logs

---------- Post updated at 12:05 PM ---------- Previous update was at 12:03 PM ----------

mysql_select_db("tst", $con) or die( "Unable to select database");

I have checked the above code. But I did not get any error msg .

---------- Post updated at 01:47 AM ---------- Previous update was at 01:39 AM ----------

Can you please tell how to check on apache log .

Please help on this

Try to print the rows

 
$num=mysql_numrows($result);
echo $num;