PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in

<?php session_start(); ?> <?php require_once('Connections/config.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($connection, $theValue) : mysqli_escape_string($connection, $theValue); switch ($theType) {

6th May 2018, 9:21 PM
Kelly Arnold
Kelly Arnold - avatar
3 Answers
+ 4
Diagnostic / troubleshooting questions: Is the mysqli... test not supposed to run? Use an "else" construct to keep it from running if PHP_VERSION is >= 6 ...Or is it the null value? Is require_once succeeding? What's in your server logs related to that file (many things could be wrong here, from security access controls to a case-sensitive OS)? If the file is including okay, are the variables present / properly initialized?
7th May 2018, 1:38 AM
Kirk Schafer
Kirk Schafer - avatar
+ 1
The error is on this line $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($connection, $theValue) : mysqli_escape_string($connection, $theValue);
7th May 2018, 10:06 AM
Kelly Arnold
Kelly Arnold - avatar
0
<?php session_start(); ?> <?php require_once('Connections/config.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($connection_vote, $theValue) : mysqli_escape_string($connection_vote, $theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_rstrack = "-1"; if (isset($_SESSION['trackid'])) { $colname_rstrack = $_SESSION['trackid']; } mysqli_select_db($connection, $spider);
7th May 2018, 11:02 AM
Kelly Arnold
Kelly Arnold - avatar