Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mysql_fetch_row() expects parameter 1 to be resource, boolean given

 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I'm having a problem returning the result of a query



The error is here





This my logcat error

<b>Warning</b>: mysql_fetch_row() expects parameter 1 to be resource, boolean given in <b>C:\xampp\htdocs\ebspmamobile\index.php</b> on line <b>47</b><br />


Any way to fix it?

Thanks
 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That suggests mysql_query is returning false, which it will do if there is an error. Check the value of mysql_error(), that should tell you something about what is going wrong.
 
Gil Carvalho
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks

It was an error in name of a column but i still have an issue

This is my table times

idtempo inicio fim
------- -------- ----------
11 08:15:00 09:00:00
12 09:00:00 09:45:00
13 10:00:00 10:45:00
14 10:45:00 11:30:00
15 11:40:00 12:25:00
16 12:25:00 13:10:00
17 13:20:00 14:05:00
18 14:05:00 14:50:00
19 15:00:00 15:45:00
20 15:45:00 16:30:00
21 16:45:00 17:30:00
22 17:30:00 18:15:00

I need to check if classrrom is booked before an user can make a new booking




But i can make a new booking even if the classroom is already booked

idreserva idutilizador idsala idtempoInicio idTempoFim data
--------- ------------ ------ ------------- ---------- ----------
29 1261 1 11 14 2014-05-12
46 1261 1 15 16 2014-05-12
48 1261 1 14 15 2014-05-12

So if the classroom is booked between idtempoInicio 15 and idTempoFim 16 i shouldn't be capable of make the last booking

Whats wrong?

Thanks
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do something like



use mysqli_* or PDO instead of mysql_* because it has been deprecated
 
John David Peter
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got this error. Because your query return nothing. I request you to use die(mysql_error()) next to your mysql query. If you use this, then you'll get mysql error. Another option is, before execute query, echo the query, copy and past it to mysql database to see whether it give correct answer or not.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic