Jump to content

Recommended Posts

I'm passing some values into a function in the form of an array. The values pass into the function fine (i've checked this with a print_r inside the function, the values are set so I know they're being passed into the function) however when I move these values into the query they don't seem to show up

 


// function..... $params is array being passed in
function new_exhibition($params)
{
       /// database connection...
       db_connect();
      // print_r on $params, the array is full of values set outside the function....
        print_r($params);
     // the query...
$query = sprintf("INSERT INTO exhibitions 
				 				SET
								exhibitioname = '%s',
								startdate = '%s',
								enddate = '%s',
								Year = '%s',
								details = '%s',
								address= '%s'
								",
				mysql_real_escape_string($params['exhibitioname']),
				mysql_real_escape_string($params['startdate']),
				mysql_real_escape_string($params['enddate']),
				mysql_real_escape_string($params['Year']),
				mysql_real_escape_string($params['details']),
				mysql_real_escape_string($params['address']));


 

Each time I get back "Undefined index" error for the escaped values. I've tried printing the query string and it's empty each time so I'm at a loss to know what's going on here.

 

Please help!

you need key 'post' in your array

...
				mysql_real_escape_string($params['post']['exhibitioname']),
				mysql_real_escape_string($params['post']['startdate']),
				mysql_real_escape_string($params['post']['enddate']),
				mysql_real_escape_string($params['post']['Year']),
				mysql_real_escape_string($params['post']['details']),
				mysql_real_escape_string($params['post']['address']));

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.