Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Mysql_escape with an array

  • Please log in to reply




  • Member
  • PipPip
  • 22 posts
Let me start by saying that I am totally new to PHP and MySQL. I am just learning - and the code I was given/am currently using is WAY beyond my current level of knowledge; so please be understanding if I say something totally stupid ;D

So, I am trying to get the mysql_escape_string function to work with an array. I found a useful tutorial online that suggested the following:

{function mysql_real_escape_array($t)
{return array_map("mysql_real_escape_string",$t);

So, I would like to try out this solution, but to be completely honest, I don't understand PHP well enough to know what to do with it :-[ I know that these are really basic questions, but here is what I can't figure out:

1) Am I right in assuming that I need to replace the $t with the name of my array and then leave the rest as it is?

2) WHERE in my code do I put all of this? Does it matter where it goes? And is there an easy way to figure it out without me having to post all of my script?

3) Ok this may be the dumbest question yet, but how do I know what the name of my array is? I am fairly certain it is one of three things - but I have a hard time telling for sure because everything seems to get relabeled (if that even makes any sense). Here is a snippet of my code that I *think* my array name is in. I am not sure if this is even helpful, but just in case:

foreach($variablen as $name=>$value) {
mysql_query ("ALTER TABLE $table ADD `$name` VARCHAR(15)");

I would really appreciate some help with this. I have been trying to figure out a solution for HOURS now and I am just totally lost. I know I will get more savvy with this as time progresses, but right now I really just need my site to work.

Thanks so much!!!

Edited by lillya, 04 June 2009 - 04:52 AM.

  • 0


Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP