473,387 Members | 1,456 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,387 software developers and data experts.

not able to compare & fetch data from table using where clause

Hi,

i am building a small forum site as my final year project & stuck in a very trivial problem.

I have a table which are varchar type of data & i am trying to fetch data from table based on some condition.

$query = 'select reply_Id, post_Id, replied_by, reply, date_of_reply from reply_info where reply_info.post_Id ='. $x;

as $x='pi_1';

here $x has string value & post_Id in table has varchar value & has the same value (for that column in table) as given to $x, but still this query execution is failing. it returns false for result.

Now if i dont give any where clause query fetches all the rows of table. I tried this to confirm if connection to data base is working fine.

this is really urgent..i have already wasted an hour in this :-(

thanks in advance.
Mar 22 '09 #1
1 1891
Markus
6,050 Expert 4TB
There's nothing that sticks out at me, other than that IDs are generally stored as integers. Are you positive it's a VARCHAR?

When you're developing something, you should be debugging it. So, use mysql_error() if a query fails, to see why it failed.

Expand|Select|Wrap|Line Numbers
  1. $query = "SELECT * FROM `tbl1` WHERE 1";
  2. $query_result = mysql_query( $query ) or die ( mysql_error() );
  3.  
As soon as the query is stored in $query_result, if there's an error, your page will die with the cause of the error displayed, e.g. 'tbl1 doesn't exist'.
Mar 22 '09 #2

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

Similar topics

8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
22
by: Marc Mones | last post by:
Hello, I'working with IBM DB2 V8.1 and CLI/ODBC. I've got a problem with the following statement: ******************************************************************************** SELECT...
0
by: Peter Wang | last post by:
I have a function and am using cursor. All the columns I select in the cursor clause are BYTEA datatype. I need to compare the after-fetch-value for two BYTEA columns which is temp2 and temp3...
9
by: Acupuncture | last post by:
Hi, I am developing a JDBC application and I encountered this problem (DB2 for ISeries). I want to do a select for update and also use the fetch first rows clause. This is my sql statement: ...
3
by: Mike Charney | last post by:
I have a two part question: First I want to insert data into a table and I am using the following command: INSERT INTO tblmain SELECT field1, field2, etc... FROM tblimport WHERE ?????? The...
4
by: Jane T | last post by:
I appreciate how difficult it is to resolve a problem without all the information but maybe someone has come across a similar problem. I have an 'extract' table which has 1853 rows when I ask for...
3
by: pks83 | last post by:
Hi I am relatively new to MSSQL.... when i am trying to fetch the data from table using this query. update ticket set escalation=activity where escalation like '2008%31' escalation and...
4
by: arnuld | last post by:
This program follows from the section 6.5 of K&R2 where authors created a doubly-linked list using a binary-tree based approach. The only thing I have rewritten myself is the getword function. I am...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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:
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...

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.