D Deleted member 103 Guest Dec 8, 2017 #1 Hi, can someone tell me why my script stops working? It worked fine until a few days ago at 1&1. Now I only get the error "Internal Server Error". Code: <?php // Anfang include("cnf/var.php"); // Ende $con = mysql_connect($dbhost,$dbusername,$dbpassword) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $query = file_get_contents("php://input"); $sth = mysql_query($query); if (mysql_errno()) { header("HTTP/1.1 500 Internal Server Error"); echo $query.'\n'; echo mysql_error(); } else { if (isset($_GET["select"])) { $rows = array(); while($r = mysql_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print mysql_insert_id(); } else { print $sth; } } ?>
Hi, can someone tell me why my script stops working? It worked fine until a few days ago at 1&1. Now I only get the error "Internal Server Error". Code: <?php // Anfang include("cnf/var.php"); // Ende $con = mysql_connect($dbhost,$dbusername,$dbpassword) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); $query = file_get_contents("php://input"); $sth = mysql_query($query); if (mysql_errno()) { header("HTTP/1.1 500 Internal Server Error"); echo $query.'\n'; echo mysql_error(); } else { if (isset($_GET["select"])) { $rows = array(); while($r = mysql_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print mysql_insert_id(); } else { print $sth; } } ?>
OliverA Expert Licensed User Longtime User Dec 8, 2017 #2 You're throwing an internal server error message if you have connection issues with MySQL. Is this causing the issue (your DB down?)? Upvote 0
You're throwing an internal server error message if you have connection issues with MySQL. Is this causing the issue (your DB down?)?
D Deleted member 103 Guest Dec 9, 2017 #3 OliverA said: You're throwing an internal server error message if you have connection issues with MySQL. Is this causing the issue (your DB down?)? Click to expand... No, 1&1 just changed the PHP version from 5.5 to 7.2, and now my script stops working. Upvote 0
OliverA said: You're throwing an internal server error message if you have connection issues with MySQL. Is this causing the issue (your DB down?)? Click to expand... No, 1&1 just changed the PHP version from 5.5 to 7.2, and now my script stops working.
DonManfred Expert Licensed User Longtime User Dec 9, 2017 #4 mysql_connect and the others (old connection tools) are not working in PHP5.6+ You need to switch to a MySQLi Class! The Attached Class comes from here. PD: Honestly; the deprecation of the old Mysql-Classes is about (at least) FIVE years old! Check this SO-Answer from 2012. The fault is yours (you did not updated your php routines for years). Attachments phpMySQLi-Class.zip phpMySQLi-Class.zip 19.3 KB · Views: 573 Last edited: Dec 9, 2017 Upvote 0
mysql_connect and the others (old connection tools) are not working in PHP5.6+ You need to switch to a MySQLi Class! The Attached Class comes from here. PD: Honestly; the deprecation of the old Mysql-Classes is about (at least) FIVE years old! Check this SO-Answer from 2012. The fault is yours (you did not updated your php routines for years).
D Deleted member 103 Guest Dec 9, 2017 #5 DonManfred said: mysql_connect and the others (old connection tools) are not working in PHP5.6+ You need to switch to a MySQLi Class! PD: Honestly; the deprecation of the old Mysql-Classes is about 2 years old. The fault is yours (you did not updated your php routines). Click to expand... Thank you Manfred, but it is not too complicated for me. Is there any way to convert my script to PHP 7+ ? Upvote 0
DonManfred said: mysql_connect and the others (old connection tools) are not working in PHP5.6+ You need to switch to a MySQLi Class! PD: Honestly; the deprecation of the old Mysql-Classes is about 2 years old. The fault is yours (you did not updated your php routines). Click to expand... Thank you Manfred, but it is not too complicated for me. Is there any way to convert my script to PHP 7+ ?
D Deleted member 103 Guest Dec 9, 2017 #6 The fault is yours (you did not updated your php routines for years). Click to expand... I know, that's my mistake. I do not know PHP at all. I put the script together years ago with the help of B4x. Upvote 0
The fault is yours (you did not updated your php routines for years). Click to expand... I know, that's my mistake. I do not know PHP at all. I put the script together years ago with the help of B4x.
KMatle Expert Licensed User Longtime User Dec 9, 2017 #7 No big change. Just change it like that Code: $con = mysqli_connect($host,$user,$pw) or die(mysqli_error()); mysqli_select_db($con,$db) or die(mysqli_error()); mysqli_query($con,"SET CHARACTER SET utf8"); mysqli_query($con,"SET NAMES 'utf8'"); Instead Code: mysql_connect it's Code: mysqli_connect Mostly they added an i Very easy... Upvote 0
No big change. Just change it like that Code: $con = mysqli_connect($host,$user,$pw) or die(mysqli_error()); mysqli_select_db($con,$db) or die(mysqli_error()); mysqli_query($con,"SET CHARACTER SET utf8"); mysqli_query($con,"SET NAMES 'utf8'"); Instead Code: mysql_connect it's Code: mysqli_connect Mostly they added an i Very easy...
D Deleted member 103 Guest Dec 9, 2017 #8 KMatle said: No big change. Just change it like that Code: $con = mysqli_connect($host,$user,$pw) or die(mysqli_error()); mysqli_select_db($con,$db) or die(mysqli_error()); mysqli_query($con,"SET CHARACTER SET utf8"); mysqli_query($con,"SET NAMES 'utf8'"); Instead Code: mysql_connect it's Code: mysqli_connect Mostly they added an i Very easy... Click to expand... Unfortunately that is not enough, it comes this error message but no more data. There's something wrong in the code down here. Code: else { if (isset($_GET["select"])) { $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print mysqli_insert_id(); } else { print $sth; } } Upvote 0
KMatle said: No big change. Just change it like that Code: $con = mysqli_connect($host,$user,$pw) or die(mysqli_error()); mysqli_select_db($con,$db) or die(mysqli_error()); mysqli_query($con,"SET CHARACTER SET utf8"); mysqli_query($con,"SET NAMES 'utf8'"); Instead Code: mysql_connect it's Code: mysqli_connect Mostly they added an i Very easy... Click to expand... Unfortunately that is not enough, it comes this error message but no more data. There's something wrong in the code down here. Code: else { if (isset($_GET["select"])) { $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print mysqli_insert_id(); } else { print $sth; } }
D Deleted member 103 Guest Dec 9, 2017 #9 I found it, that's how it works. Code: <?php // Anfang include("cnf/var.php"); // Ende $conn = new mysqli($dbhost,$dbusername,$dbpassword,$dbname); $query = file_get_contents("php://input"); if (mysqli_errno()) { header("HTTP/1.1 500 Internal Server Error"); echo $query.'\n'; echo mysqli_error(); } else { $result = $conn->query($query); if (isset($_GET["select"])) { $rows = array(); while($r = $result->fetch_assoc()) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print $conn->insert_id; } else { print $sth; } } ?> Upvote 0
I found it, that's how it works. Code: <?php // Anfang include("cnf/var.php"); // Ende $conn = new mysqli($dbhost,$dbusername,$dbpassword,$dbname); $query = file_get_contents("php://input"); if (mysqli_errno()) { header("HTTP/1.1 500 Internal Server Error"); echo $query.'\n'; echo mysqli_error(); } else { $result = $conn->query($query); if (isset($_GET["select"])) { $rows = array(); while($r = $result->fetch_assoc()) { $rows[] = $r; } print json_encode($rows); } elseif (isset($_GET["insert"])) { print $conn->insert_id; } else { print $sth; } } ?>