Page 1 of 1

Error !!

Posted: Wed Jun 11, 2008 2:55 pm
by Monopoly
Error : Warning: Cannot use a scalar value as an array in /home/a5886547/public_html/main_forum.php on line 74


Code:

$sql5="SELECT MAX(id) AS Maxid FROM forum_question WHERE forums_id='$f_id'"; (line72)
$rows1=mysql_query($sql5); (line73)
i$rows1['Maxid']=$id; (line74)

What is causing the error??

Thank you.

Re: Error !!

Posted: Wed Jun 11, 2008 3:22 pm
by Benjamin
$rows1 is not an array.

Re: Error !!

Posted: Wed Jun 11, 2008 9:44 pm
by hansford
$sql5="SELECT MAX(id) AS Maxid FROM forum_question WHERE forums_id='$f_id'"; (line72)
$rows1=mysql_query($sql5); (line73)
$row = mysql_fetch_array($rows1); //need to fetch array or association
$row['Maxid']=$id; (line74) //can assign to array, but not to DB

Re: Error !!

Posted: Thu Jun 12, 2008 4:16 am
by Monopoly
Thank you , lads !

how stupid of me... :lol:

BTW , another error : Duplicate entry '1' for key 1 (I guess its from MySQL)

Here is the code :

$sql="INSERT INTO forum_question(forums_id, id, topic, detail, name, email, datetime) VALUES('$f_id', '$id', '$topic', '$detail', '$name', '$email', '$datetime')";
$result=mysql_query($sql) or die(mysql_error());

P.S. None of the fields are auto_increment

Re: Error !!

Posted: Thu Jun 12, 2008 4:35 am
by Benjamin
One of your table fields has the unique property set rather than just an index.

Re: Error !!

Posted: Thu Jun 12, 2008 5:26 am
by Monopoly
Thanks , it worked !!