473,788 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ 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_arr ay(): supplied argument is not a valid MySQL result resource in C:\wamp\www\tes t\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 1372
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
3435
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 new values are updated in all corresponding tables (the function of the pages in question). However, on the page that does the DB update, I also want to do some checks on the data before performing the update. Now, the problem that I am...
3
2422
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 format specifiers in addition to the string specifier and nothing worked. Traceback (most recent call last): File "e:\my_python_scripts\commercecraft.py", line 36, in ? cursor.execute ("UPDATE product SET price = '%s' WHERE competitorID=1
0
3948
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 version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
1
121535
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 alpha) so I deinstall mysql5-server and mysql5-client And then I install mysql41-server and mysql41-client on FreeBSD 5.3 by ports but now , mysql is not workable
0
1641
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: 'NoneType' object has no attribute 'cursor'
4
1895
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. When I use mysql It just gives an error or nothing when I try to execute any mysql function (e.g. mysql_connect).
0
11704
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 java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"; We get such errors generally on inserts or updates while applying a
18
2249
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
367743
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 needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
1
9587
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 things (stored procedures, functions).. we have to manually edit. That time, we face some interesting challenges.. I failed to document all of them, but whatever I can share with u.. I will try.. :) ...
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7519
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5403
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
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 we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.