Link to home
Start Free TrialLog in
Avatar of robrodp
robrodpFlag for Mexico

asked on

php msysql problem

I have this php script in my siteground account

https://lapalabramx.com/ip.php

I get

Fatal error: Call to a member function query() on boolean in /home/galaplas/public_html/lapalabramx.com/ip.php on line 21


In hostgator the same script:

http://apuntatemx.com/ip1.ph

Works ok

Code error line is

$result = $conn->query($sql);

I have googled and find nothing. I dont know if it is adiffrence in php or my sql

<?php
$servername = "localhost";
$username = "***";
$password = "***";
$dbname = "galaplast_respuestas";
$actividad="Paco";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} else {
	echo "ConnectionOk";
}
$ip=get_client_ip();
echo $ip;
$ipdec=ip2long($ip);
echo $ipdec;
$sql="select * from blocks where  " . $ipdec ."  BETWEEN ips AND ipe";
echo $sql ."<br>";
$result = $conn->query($sql);
$resultip = $conn->query($sql);
$rowip = $resultip->fetch_assoc();
if( $resultip->num_rows>0) {
$pais="MEXICO";
} else {
	$pais="NOMEX";
}
		
$conn->close();
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robrodp

ASKER

Great. If you know you know