chaseman Posted December 22, 2010 Share Posted December 22, 2010 This works: $name = mysqli_real_escape_string(mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME), trim($_POST['name'])); This DOESN'T work: $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); With the second version I get the error message "expects parameter 1 to be mysqli". But parameter 1 IS mysqli, as you can see under $dbc. So what's the deal? Link to comment https://forums.phpfreaks.com/topic/222406-mysqli_real_escape_string-not-working-right/ Share on other sites More sharing options...
BlueSkyIS Posted December 22, 2010 Share Posted December 22, 2010 you need to connect to the db first, assigning $dbc BEFORE you use $dbc in mysqli_real_escape_string() Link to comment https://forums.phpfreaks.com/topic/222406-mysqli_real_escape_string-not-working-right/#findComment-1150406 Share on other sites More sharing options...
chaseman Posted December 22, 2010 Author Share Posted December 22, 2010 Ahh that was the last thought I had, but I wasn't sure if that's really the issue, thank you. Link to comment https://forums.phpfreaks.com/topic/222406-mysqli_real_escape_string-not-working-right/#findComment-1150407 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.