473,473 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

MYSQL Error when i try to execute

10 New Member
i have the following error when i trying to execute the page

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\test\ouraction.php on line 14

here's my
ouraction.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $host = "localhost"; 
  3. $user = "root"; 
  4. $pass = ""; 
  5. $dbname = "univeristy"; 
  6.  
  7. $connection = mysql_connect("localhost","root","") or die (mysql_errno().": ".mysql_error()."<BR>"); 
  8. mysql_select_db($dbname); 
  9. //error_reporting(0);
  10. $sql = "select * from hotel where name='" . $_POST['name'] . "' and myrtlebeacharea='" . $_POST['myrtlebeacharea'] . "'"; 
  11. //echo $sql; 
  12.  
  13. $query = mysql_query($sql); 
  14. while ($row = mysql_fetch_array($query)) { 
  15. echo "<p>",$row['name'],": ",$row['myrtlebeacharea']; 
  16.  
  17. ?> 
  18.  
and this is my form
Expand|Select|Wrap|Line Numbers
  1. <html> 
  2. <head> 
  3. <title>Search Hotels</title> 
  4. </head> 
  5. <body> 
  6. <form name="form1" method="POST" action="ouraction.php"> 
  7. <p> Hotel name: <input name="name" type="text" id="name"><p> 
  8. <SELECT name="myrtlebeacharea"> 
  9. <OPTION VALUE="ns">North Strand 
  10. <OPTION VALUE="mb">Myrtle Beach 
  11. <OPTION VALUE="ss">South Strand 
  12. </SELECT> 
  13. <SELECT name="city"> 
  14. <OPTION VALUE="cherygrove">Cherry Grove 
  15. <OPTION VALUE="northmb">North Myrtle Beach 
  16. <OPTION VALUE="myrtlebeach">Myrtle Beach 
  17. <OPTION VALUE="surfside">Surfside Beach 
  18. <OPTION VALUE="gardencity">Garden City 
  19. </SELECT> 
  20. <p><input type="submit" name="submit" value="submit"> 
  21. </form> 
  22. </body> 
  23. </html> 
  24.  
please help me what is the mistake i done.

Thanks in Advance
Nov 17 '07 #1
1 1361
ak1dnar
1,584 Recognized Expert Top Contributor
//echo $sql;
Hi,
uncomment this line and print the $sql variable. copy it and execute the query in your MySQL query window. is there any Error while executing?
Nov 17 '07 #2

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

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
3
by: Paul M | last post by:
I encountered the following error when trying to perform a SQL UPDATE to a MySQL database table from Python. I would apprciate any assistance. In the Python code I have tried integer and decimal...
0
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
0
by: Daniel Crespo | last post by:
Hi to all, I'm using adodb for accessing mysql and postgres. My problem relies on the mysql access. Sometimes, when I try to execute a query (using ExecTrans method below), I get this error:...
4
by: ImOk | last post by:
I have the following setup: Windows XP Prof, IIS, PHP5 PHP5 works no problem with either PHP-CGI.EXE and mySQL, PHP5 also works no problem with php5isapi.dll as long as I dont use mySQL....
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
18
by: Bruce A. Julseth | last post by:
I have the following code $Host = "localhost"; $User = "Fred"; $Database = "house"; $Password = "mypw" echo "before mysqli<br />Host: " . $Host . "<br />" . $User . "<br />" . $Database;
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
1
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.