Jump to content

Fatal error: [] operator not supported for strings


dominicpv

Recommended Posts

I am new at php and I am stuck on these two errors.

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: YES) in /addresses.php on line 96

 

Fatal error: [] operator not supported for strings in /addresses.php on line 101

 

here is that section of my code:

 

$cxn = mysql_connect($host,$username,$password,$database); *line 96

foreach($_POST as $field => $vaule)

{

if ($field != "Button" and $field !="do")

{

$fields[]=$field;  *line 101

$value[] = strip_tags(trim($value));

$values[]= mysql_real_escape_string($value,$cxn);

$$field = $value;

}

}

 

any help would be appreciated.

you're already assigning $value in the original foreach() loop, which you then attempt to convert to an array.  you'll need to rename that variable in the if() block or in the foreach() loop.

 

as for the mysql_connect(), there's a sticky regarding this error in the PHP Help forum; it's the result of a change in going from PHP4 to PHP5.

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.