Hi,
I think I'm correct in saying it is best practice to use mysqli_real_escape_string when pushing any user-generated text into a mySQL database.
I'm using the below code (which is tested and working) to push the submitted data from a gravity form into mySQL.
<?php
add_action("gform_after_submission_9", "push_fields", 10, 2);
function push_fields($entry, $form){
$uploaderName = $entry["1"];
$organiserName = $entry["2"];
$organiserEmail = $entry["3"];
$organiserNumber = $entry["4"];
$venueNumber = $entry["5"];
$con=mysqli_connect("hostname","username","password","dbname");
mysqli_query($con,"INSERT INTO table (uploaderName, organiserName,
organiserEmail, organiserNumber, venueNumber) VALUES ('$uploaderName',
'$organiserName', '$organiserEmail', '$organiserNumber', '$venueNumber')");
}
?>
So how do I use real_escape_string?
I tried these two ideas but neither worked:
$uploaderName = mysqli_real_escape_string($entry["1"]);
and
$uploaderNameX = $entry["1"];
$uploaderName = mysqli_real_escape_string($uploaderNameX);
And by "neither worked" I mean the first one crashed my entire site, and the second one just left that column blank in the mySQL table but entered all other info correctly.