PHP error

My php files doesn't seem to work when I upload it to an online web hosting it a search and register web but it doesn't produce any error and it doesn't do anything related to php but if I put incorrect credentials it does indicate that Access is denied.

Anyone know what the course of this, but if I upload the same website to my other free webhosting it does search.
LVL 2
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAsked:
Who is Participating?
 
Julian HansenCommented:
Does the PHP script work on your local server?
Have you checked the error logs on the server. Usually with hosting packages they turn errors off and redirect PHP errors to a file in the web_root (look for a file error.log or similar)

You say the script does not do anything but then mention that you get an access denied when entering credentials - that means it is doing something.

Can you describe what your script is supposed to do.

Can we see some code or a link
0
 
Olaf DoschkeSoftware DeveloperCommented:
Probably not at all PHP related but a password protected (basic auth) folder?
Apache hosting is there some .htaccess in the folder of the PHP script?
Or is it even just file permissions?
Check with the hoster FAQ.

Bye, Olaf.
0
 
Chris StanyonCommented:
You might want to post a link to the page or a copy of your code. Could be a number of reasons why it's not working
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
Thanks guys. the page is at http://www.findmesa.co.za that doesn't work but the one that is working is at http://www.mlungisi.0fees.us/findme

I've just checked the server log an I noticed that it has this error
PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/findmesa/public_html/cnn.php:2

Open in new window

but on mlungisi.0fees.us/findme I don't have this issue but I use the same script. About entering the credentials, I meant with the correct credentials it seems as if it doesn't even do anything but when I enter wrong it does produce that error of access denied.
0
 
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
Here is the code I'm using
<?php
mysql_connect("localhost","myusername","xxxxxxxxxxx") or die("Could not connect");
//mysql_connect("localhost","myusername","xxxxxxxxxxx") or die("Could not connect");
mysql_select_db("findmesa_sfind") or die("Could not find database!");
$output = '';
// Collect data
if(isset($_POST['searchVal'])){
$searchq = $_POST['searchVal'];
$querrry = mysql_query("SELECT * FROM `findmesa_sfind`.`dta` WHERE tags LIKE '%$searchq%' OR name LIKE '%$searchq%' OR category LIKE '%$searchq%' OR username LIKE '%$searchq%' OR addr2 LIKE '%$searchq%' OR city LIKE '%$searchq%' OR province LIKE '%$searchq' OR country LIKE '%$searchq%' OR company LIKE '%$searchq%' LIMIT 0,10 ") or die(mysql_error());//LIMIT 0,10 order by lp
$count = mysql_num_rows($querrry);

$output = '<div style="color:#000000"><center><h1 class="mbr-section-title display-1"><SMALL>SEARCH RESULT OF <I>' .$searchq. '</I></SMALL></h1></center></div>';
$qaw = 0;
$csx = 0;
if($count == 0){
$output .= '<div><div style="color:#000000">There was no search results!</div></div>';

}else{
while($row = mysql_fetch_array($querrry))  {
	$csx += 1;
$id = $row['id'];
$company = $row['company'];
$desc = $row['desc'];
$tel = $row['tel'];
$cell = $row['cell'];
$email = $row['email'];
$website = $row['url'];
$city = $row['city'];
$country = $row['country'];
$listingpos = $row['lp'];
$status = $row['status'];
$imgData = $row['image'];

if($csx == 1){
	$qaw = $listingpos +1;
	$querrrya = mysql_query("UPDATE `findmesa_sfind`.`dta` SET `lp`='".$qaw."' WHERE `id`='".$id."'") or die("Could not update database");


	}

	$output .= '<div style="color:#000000"><hr /><h1><a href="http://' .$website. '">' .$company. ' ' .$csx.'</a></h1><a href="http://'.$website.'"><img class="imgl borderedbox inspace-5" src="data:image/png;base64,'.base64_encode($imgData).'" alt=""></a><p><div style="color:#000000">' .$desc. '</p> Cell No: ' .$cell. '<br /><a href="mailto:' .$email. '">' .$email. '</a> <br />' .$city.','.$country. '</div></div><p></p>';//<hr />

}


}
}
mysql_close();
echo($output);
?>

Open in new window

0
 
Julian HansenCommented:
The mysql library has been deprecated and removed in later versions of PHP.

What has happened is your host is using a version of PHP that no longer supports the old MySQL

You will need to either change your code to use MySQLi (or PDO)

You could also try ask your host if it is possible to use an earlier version of PHP

Refer to this link for more details
http://php.net/manual/en/migration55.deprecated.php
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
As Julian said, the message...

PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /home/findmesa/public_html/cnn.php:2

Open in new window


Means you're using pre-PHP-7.0 mysql_*() API calls + your runtime environment is running PHP-7.0 or above (as it should).

Just change all your mysql_*() calls to mysqli_*() calls + all should be well.

In most cases mysql_*() calls are directly replaced by mysqli_*() calls. In some rare cases, some mysql_*() code has been completely dropped, so you may have to do a bit of extra coding to get around these few dropped routines.

If you have 100s or 1000s of files to convert from PHP-5.X to PHP-7.x the project...

https://github.com/wimg/PHPCompatibility provides a tool to find all incompatibilities + another tool to mass edit PHP files + auto-magically fix many of these problems.

I've been using these tools with clients for a year now. A massive time saver. Even with a few files, these tools may catch slight problems you miss by eyeballing your code.
0
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.

All Courses

From novice to tech pro — start learning today.