Jump to content

[SOLVED] Can't understand why it won't work!


seabro

Recommended Posts

The following script was working on another server but stopped working when I moved to new server. 

 

The script returns Test 1 but not Test 2.  It is dying at the line beginning $connect...  I even commented out the Die() but that didn't help. 

 

Why won't it get past $connect?

 

Assistance appreciated.

 

<h1>Select Report Date</h1>

<?php

echo "test 1";

$connect = mysql_pconnect("localhost","user","pass"); //  or Die("connect failed");

echo "test 2";

echo $connect;

$selectdb = mysql_select_db("asterisk") or Die("select failed");

echo $selectdb;

$query  = "SELECT DISTINCT date_format(calldate,'%Y-%m-%d') as new_date from cdr ORDER BY new_date DESC LIMIT 50 ";

echo $query;

$connect;

$selectdb;

mysql_query($query) or die ("query x failed");

$res = mysql_query($query,$connect) or die("failed");

echo $res;

print"<table align='center' border='1' cellspacing='0' cellpadding='5'>";

print "<tr>";

 

print "<td align='center'>";

print "Date";

print "</td>";

 

print "</tr>";

 

while($qry = mysql_fetch_array($res)) {

 

$calldate=$qry["new_date"];

 

print "<tr>";

print "<td align='center'>";

print "<a href='incoming2.php?date=";

print "$calldate'>";

print "$calldate";

print "</a>";

print "</td>";

 

};

?>

Link to comment
Share on other sites

I did this and there is still no error at all.  The only thing on my page is the text between the H1 tags and test 1.

 

The script is stopping at $connect=.........

 

For the record I have tried a echo phpinfo() and that works and I have logged into the mysql database from the command line using the dbasename, username and password from the script.

 

I have also change the localhost to 127.0.0.1 but get same result.

 

I am baffled.. any more ideas?

Link to comment
Share on other sites

I tried from command line..

 

Does the following help troubleshoot or is it to be expected when execute from command line?

 

[root@localhost ~]# php /var/www/html/stats/incoming.php

Content-type: text/html

X-Powered-By: PHP/4.3.9

 

<H1>Report Date</H1>

PHP Fatal error:  Call to undefined function:  mysql_pconnect() in /var/www/html/stats/incoming.php on line 3

[root@localhost ~]#

 

Link to comment
Share on other sites

FIXED!

 

Thanks for all your help.

 

After I saw the error on the command line (that I wasn't seeing on my web page). I did some searching and one of the troubleshooting measures was

 

Check if the php-mysql package is installed by opening a terminal window (bash), and typing, rpm -qa | grep php. If you don't see it, make a note of the exact version of PHP that is installed.

 

I did this and I did not see php-mysql

 

So I did yum install php-mysql, restarted apache and it all worked.

 

sorry if I wasted anyones time I am a relative newbie.

 

 

(I thought having PHP and MySQL installed was enough but there is obviously this php-mysql that glues them together).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.