-3

Why does it give above mentioned error?

Here's the code:

$replace =  str_replace(", "," | ", $result2);
while ($line = mysql_fetch_array($result2, MYSQL_BOTH)){ 
    mysql_query("INSERT INTO listings
Corrie
  • 147
  • 2
  • 3
  • 9
  • 3
    Possible duplicate of http://stackoverflow.com/questions/5473981/warning-mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in and http://stackoverflow.com/questions/5482538/warning-mysql-num-rows-expects-parameter-1-to-be-resource-array-given-in all from you! Why? – eisberg Mar 30 '11 at 08:20
  • It is not the same as this issue is in the loop – Corrie Mar 30 '11 at 08:22
  • 6
    Seriously, you need to learn to debug yourself. Sit down and apply the answers to your previous question to this very similar problem. – Matt Mar 30 '11 at 08:24
  • 4
    Oh come on... *please* read the manuals before asking more questions on this topic. Voting to close. – Aron Rotteveel Mar 30 '11 at 08:24
  • check the spelling of your fields (lisitngs), my god. – tetris Mar 30 '11 at 08:33
  • Listen you guys, I am new to this! So if you don't want to help, then don't. But please keep your negative comments to yourself!! – Corrie Mar 30 '11 at 09:31

3 Answers3

2

You are using a string function on a resource. PHP is weakly typed so it lets you get away with it in the short term (no runtime error), but it is done by converting the resource to string first, then doing the substitutuin. So it is not a resource anymore.

vbence
  • 19,714
  • 8
  • 64
  • 114
1

mysql_fetch_array() needs a valid mysql ressource as the first parameter. You can not use a str_replace() in a MYSQL ressource. So I assume that $result2 is not a mysql ressource.

$result2 should be generated with a mysql_query().

Haza
  • 2,935
  • 1
  • 15
  • 13
0

Guess you did not read all comments and answers in your own question (duplicate one)? You already got answer from me about this problem there but yo're too lazy to read, right?

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

Close it down!

Community
  • 1
  • 1
Wh1T3h4Ck5
  • 8,295
  • 9
  • 56
  • 77
  • You never helped at any of my questions! If you just want to sit here and criticize then do what makes you happy! If you don't want to help then don't! Ignore my questions, as there are people that actually wants to help! – Corrie Mar 30 '11 at 09:38
  • Anybody, compare this question with previous one and tell us all what's wrong. Agree,"there are people that actually wants to help", but they are just developers... – Wh1T3h4Ck5 Mar 30 '11 at 09:50