troubleshooting Question

How Do I Escape Strings in the Header Row of an Upload File for either CSV or TXT

Avatar of Ridgejp
RidgejpFlag for United Kingdom of Great Britain and Northern Ireland asked on
13 Comments1 Solution136 ViewsLast Modified:

I'm using the following to import data into MySql Database via PHP, but how do I Escape Strings that are found in the header row of the data itself? In the example below the first header $order-id contains "-" which stops the import rountine.

How the best way to get around this without having to change the header rows?

while(($fileop = fgetcsv($handle,10000,",")) !== false)
			$order-id			= $mysqli->real_escape_string($fileop[0]);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros