473,394 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

mysql_fetch_array() expects parameter 1 to be resource, ...error in your SQL syntax

2
I have this error message --> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\script.php on line 24

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'date']; ?>','3:00am')' at line 1

The one that i bold and underline is Line 24

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3.  
  4. $hostname = "localhost";
  5. $username = "root";
  6. $password = "";
  7. $dbname = "futsal";
  8. $tblname = "booking";
  9.  
  10. $connection = mysql_connect($hostname, $username, $password) or die(mysql_error());
  11. $db = mysql_select_db($dbname, $connection) or die (mysql_error());
  12.  
  13. $username = $_SESSION['username'];
  14. $courts = $_POST['courts'];
  15. $date = $_POST['date'];
  16. $time = $_POST['time'];
  17.  
  18.     $result_user_id = mysql_query("select user_id FROM user WHERE username = '$username'");
  19.     if($row = mysql_fetch_array($result_user_id)){
  20.     $user_id = $row['user_id'];
  21.     }
  22.  
  23.     $resultz = mysql_query("select * FROM booking WHERE date = '$date' AND time = '$time' AND courts = '$courts' ");echo $resultz;
  24. line 24->        if($row = mysql_fetch_array($resultz)){
  25.     echo "<table width='100%'><td height='50' align='center' bgcolor='#85A157'><font size='4'><strong>The court are not available</strong></font></td></table>";
  26.     echo "<meta http-equiv='refresh' content='1;url=booking.php'>";
  27.     }
  28.  
  29.     else
  30.     {
  31.     $sql = "INSERT INTO booking(user_id,username,courts,date,time) VALUE ('$user_id','$username','$courts','$date','$time')";
  32. $result = mysql_query($sql) or die (mysql_error());
  33.  
  34.     $_SESSION['courts'] = $courts;
  35.     $_SESSION['date'] = $date;
  36.     $_SESSION['time'] = $time;
  37.  
  38.  
  39.  
  40.     //echo "<meta http-equiv='refresh' content='10;url=booking_success.php'>"
  41.     echo "<table width='100%'><td height='50' align='center' bgcolor='#85A157'><font size='4'><strong>PROCESS BOOKING</strong></font></td></table>";
  42.     echo "<table width='1000'><td align='center'><img src='image futsal/loading3.gif'></td></table>";
  43.     echo "<meta http-equiv='refresh' content='1;url=booking_success.php'>";
  44.     }
  45.  
  46. ?>
  47.  
  48.  
  49.  
Nov 30 '10 #1
3 3264
Dormilich
8,658 Expert Mod 8TB
the error message says it all. your SQL query fails, therefore mysql_query() returns false (a boolean) and that is not the expected parameter type (resource) for mysql_fetch_array().
Dec 1 '10 #2
mocha
2
does this mean phpMyAdmin has false sql query??

Because my friend can run it without problem at all.I wonder why..
Dec 2 '10 #3
Dormilich
8,658 Expert Mod 8TB
not phpMyAdmin has a false query, you have. print out the SQL string before submitting it and check the syntax.
Dec 2 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Senthil | last post by:
Hi, I created a stored procedure in the sql server. I try to insert a record from the aspx page. But I keep getting this error, "procedure expects parameter <@firstname>, which was not...
2
by: kalpana.sinduria | last post by:
Hi all, how to remove the following complle error. When I compiling the code I get the following errors: Compiling... CDrtEachDefFeat.cpp d:\ include\common\cdrtintegfeat.h(39) : error...
1
by: jfturcott | last post by:
Prepared statement '(@p1 int,@p2 tinyint,@p3 varchar(8000),@p4 varchar(8000),@p5 bit' expects parameter @p1, which was not supplied. I get the above error when trying to update a datagridview to...
1
by: malayappa | last post by:
Hi All here is the error what i m getting Warning: domdocument::domdocument() expects parameter 2 to be long, string given in D:\Program Files\Apache Software...
7
by: roseple | last post by:
Hi, can anyone please help me why I got this error every I uploaded files. Error: Here is the code on the said warning message: # Gather all required data $name =...
1
by: dragos42 | last post by:
m from Romania and I bought the book let yourself, bother with a problem to conduct script 14.2 appear: The file has been uploaded! Warning: mysqli_query() expects parameter 1 to be mysqli,...
3
BRawn
by: BRawn | last post by:
Hi, I'm writing an application which needs SQL parameters to be passed, and even though I've assigned parameters to the stored procedure, I keep getting the following error message from the...
12
by: Rana Chakra | last post by:
<?php $username="root"; $password=""; $database="lko_phone"; $host="localhost"; $msg=""; mysql_connect($host,$username,$password); @mysql_select_db($database); if($_SERVER == "POST")
3
bansari
by: bansari | last post by:
Hi..i tried to make insert stored procedure. ------------------------------------------------------- ALTER PROCEDURE . ( @empno int, @empname varchar(100), @emppassword varchar(100),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.