473,406 Members | 2,843 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,406 software developers and data experts.

Can't query database

155 100+
I'm trying to do this:
Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM response WHERE recipe_id='$file' AND allow='1'";
  2. $result = mysql_query($query) or trigger_error("Query: $query\n<br>MySQL Error: " . mysql_error());
  3. if (!$result)
  4. {
  5. echo "";
  6. }
  7. else
  8. {
  9. echo "blah blah";
  10. }
But it's not working. It must be something to do with the AND part but I don't know what. Any clues?
Dec 3 '08 #1
5 1283
Dormilich
8,658 Expert Mod 8TB
mysql_query() returns a resource so I wouldn't check that (this should always return true). do you get any errors?

regards
Dec 3 '08 #2
Markus
6,050 Expert 4TB
What datatype is 'allow'. If it's ~int, then you shouldn't have single quotes around it.

Doesn't help when you don't tell use what's isn't happening.
Dec 3 '08 #3
NeoPa
32,556 Expert Mod 16PB
David - Check PMs please.
Dec 3 '08 #4
DavidPr
155 100+
"allow" is an INT. The field will either have a 1 or 2 in it. When set to 1 the recipe will be displayed and 2 it will not be displayed.

When a user submits a recipe, the allow field is automatically set to 1. I'm sent an email letting me know that there's a new recipe. I check it to make sure that it is not spam or something and if it's OK I change "allow" to 2, which will make the recipe viewable.

OK, so NO '' around this number. I'll try it and tell you how it works. Thanks.
Dec 4 '08 #5
Markus
6,050 Expert 4TB
@DavidPr
OK, you do that.
Dec 4 '08 #6

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

Similar topics

1
by: Bob Kaku | last post by:
I'm trying to retrieve a text value from a MySQL database, put it into an updateable form, allow edits, and send back the edited text back into the MySQL database. I've been able to successfully...
4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
3
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
10
by: Rada Chirkova | last post by:
Hi, at NC State University, my students and I are working on a project called "self-organizing databases," please see description below. I would like to use an open-source database system for...
4
by: sparks | last post by:
We have a database that reads in and formats raw data. We were using queries to format the data per person and outputing reports. The other database has the persons personal information. I changed...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
1
by: Pradeep83 | last post by:
Hi All Problem : I am unable to retrieve the data from the table in postgres database using C application which i have written in solaris os. Query: How to check whether connection is there...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.