Jump to content

Undefined index mysql_real_escape_string problem


luminous

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']));

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.