<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Using mysqli_real_escape_string with gform_after_submission and a mySQL database</title>
		<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database</link>
		<description>Gravity Support Forums Topic: Using mysqli_real_escape_string with gform_after_submission and a mySQL database</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 22:01:19 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database" rel="self" type="application/rss+xml" />

		<item>
			<title>Richard Vav on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-360257</link>
			<pubDate>Wed, 03 Jul 2013 15:22:25 +0000</pubDate>
			<dc:creator>Richard Vav</dc:creator>
			<guid isPermaLink="false">360257@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Andrew, thanks for sharing.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>andrew carbn on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-360247</link>
			<pubDate>Wed, 03 Jul 2013 15:20:31 +0000</pubDate>
			<dc:creator>andrew carbn</dc:creator>
			<guid isPermaLink="false">360247@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;For anybody who is interested, here is the final code which is tested and working:&#60;/p&#62;
&#60;p&#62;ORIGINAL EXAMPLE CODE:&#60;br /&#62;
*************************************************************************************&#60;br /&#62;
add_action(&#34;gform_after_submission_1&#34;, &#34;push_fields&#34;, 10, 2);&#60;br /&#62;
function push_fields($entry, $form){&#60;/p&#62;
&#60;p&#62;$uploaderName = $entry[&#34;1&#34;];&#60;br /&#62;
$venueName = $entry[&#34;2&#34;];&#60;br /&#62;
$uploaderEmail = $entry[&#34;3&#34;];&#60;/p&#62;
&#60;p&#62;$con=mysqli_connect(&#34;$DB_HOST&#34;,&#34;$DB_USER&#34;,&#34;$DB_PASSWORD&#34;,&#34;$DB_NAME&#34;);&#60;br /&#62;
mysqli_query($con,&#34;INSERT INTO $TABLE_NAME&#60;br /&#62;
(uploaderName, venueName, uploaderEmail)&#60;br /&#62;
VALUES&#60;br /&#62;
('$uploaderName', '$venueName', '$uploaderEmail')&#34;);&#60;br /&#62;
}&#60;br /&#62;
*************************************************************************************&#60;/p&#62;
&#60;p&#62;NEW CODE USING mysqli_real_escape_string via $wpdb:&#60;br /&#62;
!!!!! Note re-ordering of SQL login details in line 9 below !!!!!!&#60;br /&#62;
!!!!! DO NOT add or remove any double or single quotes !!!!!!&#60;br /&#62;
*************************************************************************************&#60;br /&#62;
add_action(&#34;gform_after_submission_1&#34;, &#34;push_fields&#34;, 10, 2);&#60;br /&#62;
function push_fields($entry, $form){&#60;/p&#62;
&#60;p&#62;$uploaderName = $entry[&#34;1&#34;];&#60;br /&#62;
$venueName = $entry[&#34;2&#34;];&#60;br /&#62;
$uploaderEmail = $entry[&#34;3&#34;];&#60;/p&#62;
&#60;p&#62;global $wpdb;&#60;br /&#62;
$con = new wpdb (&#34;$DB_USER&#34;, &#34;$DB_PASSWORD&#34;, &#34;$DB_NAME&#34;, &#34;$DB_HOST&#34;);&#60;br /&#62;
$con-&#38;gt;show_errors();&#60;br /&#62;
$con-&#38;gt;INSERT('$TABLE_NAME',&#60;br /&#62;
array(&#60;br /&#62;
'uploaderName'=&#38;gt;$uploaderName,&#60;br /&#62;
'venueName'=&#38;gt;$venueName,&#60;br /&#62;
'uploaderEmail'=&#38;gt;$uploaderEmail,&#60;br /&#62;
),&#60;br /&#62;
array(&#60;br /&#62;
'%s','%s','%s'&#60;br /&#62;
)&#60;br /&#62;
);&#60;br /&#62;
}&#60;br /&#62;
*************************************************************************************
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-344251</link>
			<pubDate>Tue, 25 Jun 2013 12:15:45 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">344251@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;It is because that method will do the escaping for you. As long as you are using the methods from $wpdb, you don't have to worry about escaping. That is the beauty of it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>andrew carbn on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-344190</link>
			<pubDate>Tue, 25 Jun 2013 11:22:52 +0000</pubDate>
			<dc:creator>andrew carbn</dc:creator>
			<guid isPermaLink="false">344190@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks.&#60;br /&#62;
I've had a look at that page and something is not making sense to me.&#60;br /&#62;
Under the section &#34;INSERT rows&#34; is says &#34;Both $data columns and $data values should be &#34;raw&#34; (neither should be SQL escaped).&#34;&#60;br /&#62;
Is this because I am &#34;inserting&#34; data, and the danger is only when I am &#34;querying&#34; the data?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-337229</link>
			<pubDate>Fri, 21 Jun 2013 18:14:56 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">337229@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello Andrew,&#60;br /&#62;
What you want to do is look at using the global $wpdb variable instead. It will handle escaping for you. Following is the doc page for it.&#60;br /&#62;
&#60;a href=&#34;http://codex.wordpress.org/Class_Reference/wpdb&#34; rel=&#34;nofollow&#34;&#62;http://codex.wordpress.org/Class_Reference/wpdb&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>andrew carbn on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-336848</link>
			<pubDate>Fri, 21 Jun 2013 13:10:52 +0000</pubDate>
			<dc:creator>andrew carbn</dc:creator>
			<guid isPermaLink="false">336848@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Excellent. Thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-334777</link>
			<pubDate>Thu, 20 Jun 2013 15:33:32 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">334777@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm going to send this thread to our developers to look at.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>andrew carbn on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-334577</link>
			<pubDate>Thu, 20 Jun 2013 12:56:57 +0000</pubDate>
			<dc:creator>andrew carbn</dc:creator>
			<guid isPermaLink="false">334577@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello, I'm still waiting for a reply.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>andrew carbn on "Using mysqli_real_escape_string with gform_after_submission and a mySQL database"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/using-mysqli_real_escape_string-with-gform_after_submission-and-a-mysql-database#post-323487</link>
			<pubDate>Fri, 14 Jun 2013 14:51:48 +0000</pubDate>
			<dc:creator>andrew carbn</dc:creator>
			<guid isPermaLink="false">323487@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;br /&#62;
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.&#60;br /&#62;
I'm using the below code (which is tested and working) to push the submitted data from a gravity form into mySQL.&#60;/p&#62;
&#60;p&#62;&#38;lt;?php&#60;br /&#62;
add_action(&#34;gform_after_submission_9&#34;, &#34;push_fields&#34;, 10, 2);&#60;br /&#62;
function push_fields($entry, $form){&#60;/p&#62;
&#60;p&#62;$uploaderName = $entry[&#34;1&#34;];&#60;br /&#62;
$organiserName = $entry[&#34;2&#34;];&#60;br /&#62;
$organiserEmail = $entry[&#34;3&#34;];&#60;br /&#62;
$organiserNumber = $entry[&#34;4&#34;];&#60;br /&#62;
$venueNumber = $entry[&#34;5&#34;];&#60;/p&#62;
&#60;p&#62;$con=mysqli_connect(&#34;hostname&#34;,&#34;username&#34;,&#34;password&#34;,&#34;dbname&#34;);&#60;br /&#62;
mysqli_query($con,&#34;INSERT INTO table (uploaderName, organiserName,&#60;br /&#62;
organiserEmail, organiserNumber, venueNumber) VALUES ('$uploaderName',&#60;br /&#62;
'$organiserName', '$organiserEmail', '$organiserNumber', '$venueNumber')&#34;);&#60;br /&#62;
}&#60;br /&#62;
?&#38;gt;&#60;/p&#62;
&#60;p&#62;So how do I use real_escape_string?&#60;/p&#62;
&#60;p&#62;I tried these two ideas but neither worked:&#60;br /&#62;
$uploaderName = mysqli_real_escape_string($entry[&#34;1&#34;]);&#60;br /&#62;
and&#60;br /&#62;
$uploaderNameX = $entry[&#34;1&#34;];&#60;br /&#62;
$uploaderName = mysqli_real_escape_string($uploaderNameX);&#60;/p&#62;
&#60;p&#62;And by &#34;neither worked&#34; 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.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
