Error !!

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Error !!

Post 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.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Error !!

Post by Benjamin »

$rows1 is not an array.
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Error !!

Post 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
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Re: Error !!

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Error !!

Post by Benjamin »

One of your table fields has the unique property set rather than just an index.
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Re: Error !!

Post by Monopoly »

Thanks , it worked !!
Post Reply