Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Mysql_escape with an array


  • Please log in to reply

#1
lillya

lillya

    Member

  • 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:

if(!function_exists(mysql_real_escape_array))
{function mysql_real_escape_array($t)
{return array_map("mysql_real_escape_string",$t);
}}
mysql_real_escape_array($_GET);
mysql_real_escape_array($_POST);

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

Advertisements







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