LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-15-2005, 12:01 AM   #1
aznita
LQ Newbie
 
Registered: Jun 2005
Posts: 11

Rep: Reputation: 0
Help in PHP ASAP


can anybody help me with below coding. There are data in the database but the record won't come out. What's wrong with this coding. I am very new in PHP...but I familiar with ASP...please..please


$sql="SELECT Acquirer_Master.Name, Fraud_Score.Score, Transaction_Master.* FROM ((Acquirer_Master INNER JOIN Merchant_Master ON Acquirer_Master.Merchant_Id = Merchant_Master.Merchant_Id) INNER JOIN Transaction_Master ON (Acquirer_Master.Acquirer_Id = Transaction_Master.AcquirerID) AND (Merchant_Master.Merchant_Id = Transaction_Master.Merchant_Id)) INNER JOIN Fraud_Score ON Transaction_Master.Trx_Id = Fraud_Score.Transaction_Id WHERE Transaction_Master.TimeStamp = #" .$TimeStampDate."#";
if ($merchant <> 0)
{
$sql=$sql . "WHERE MERCHANT_MASTER.MERCHANT_ID = '" .$merchant. "'";
}
if ($transdate <> "")
{
$sql=$sql . "AND TRANSACTION_MASTER.TIMESTAMP = #" .$transdate. "#";
}
if ($paymentmode <> 0)
{
$sql=$sql . "AND TRANSACTION_MASTER.PAYMENT_MODE = '" .$paymentmode. "'";
}
if ($status <> "")
{
$sql=$sql . "AND TRANSACTION_MASTER.STATUS = '" .$status. "'";
}
$rs=odbc_exec($conn,$sql);

if (!$rs)
{
exit("Error in SQL");
}
 
Old 06-15-2005, 02:22 AM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
It looks like you are not separating the clauses with spaces, which may be causing problems. You should echo the SQL query to the screen so you can make sure it is correct, and then copy and paste the query into an alternative database tool (e.g psql for postgres) so you can see if there is actually any data.
 
Old 06-15-2005, 03:01 AM   #3
aznita
LQ Newbie
 
Registered: Jun 2005
Posts: 11

Original Poster
Rep: Reputation: 0
thanks..this is after i change the statement. It seems like it does read the if statement.

$sql="SELECT Acquirer_Master.Name, Fraud_Score.Score, Transaction_Master.* FROM ((Acquirer_Master INNER JOIN Merchant_Master ON Acquirer_Master.Merchant_Id = Merchant_Master.Merchant_Id) INNER JOIN Transaction_Master ON (Acquirer_Master.Acquirer_Id = Transaction_Master.AcquirerID) AND (Merchant_Master.Merchant_Id = Transaction_Master.Merchant_Id)) INNER JOIN Fraud_Score ON Transaction_Master.Trx_Id = Fraud_Score.Transaction_Id WHERE Merchant_Master.Merchant_Id = Transaction_Master.Merchant_Id" ;
if ($merchant <> 0)
{
$sql=$sql . "AND MERCHANT_MASTER.MERCHANT_ID = '" .$merchant. "'";
}
if ($transdate <> "")
{
$sql=$sql . "AND TRANSACTION_MASTER.TIMESTAMP = #" .$transdate. "#";
}
if ($paymentmode <> 0)
{
$sql=$sql . "AND TRANSACTION_MASTER.PAYMENT_MODE = '" .$paymentmode. "'";
}
if ($status <> 0)
{
$sql=$sql . "AND TRANSACTION_MASTER.STATUS = '" .$status. "'";
}
echo $sql;
$rs=odbc_exec($conn,$sql);
 
Old 06-15-2005, 03:02 AM   #4
aznita
LQ Newbie
 
Registered: Jun 2005
Posts: 11

Original Poster
Rep: Reputation: 0
sorry...it does not read the if statement
 
Old 06-15-2005, 08:20 PM   #5
aznita
LQ Newbie
 
Registered: Jun 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Please..anyone...help me..
 
Old 06-17-2005, 02:28 AM   #6
AMDers
LQ Newbie
 
Registered: Jun 2005
Location: Indonesia
Distribution: SuSE, RedHat, Mandrake, DamnSmallLinux
Posts: 1

Rep: Reputation: 0
hi..
I'll try to answer... (but sorry for my english before )
Like CroMagnon said that it seems you have to look at the strings at your SQL statement (it needs spaces after the quotes).

## if ($merchant <> 0)
## {
## $sql=$sql . "AND MERCHANT_MASTER.MERCHANT_ID = '" .$merchant. "'";
## }

it think you should add spaces so it looks like this..

if ($merchant <> 0)
{
$sql=$sql . " AND MERCHANT_MASTER.MERCHANT_ID = '" .$merchant. "' ";
}


I hope it help..

br,
Rizal
 
Old 06-17-2005, 04:32 AM   #7
aznita
LQ Newbie
 
Registered: Jun 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Thank you for all..It's work..thank you soo much
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help ASAP! coasterfreak212 Fedora - Installation 2 03-21-2004 05:05 PM
***** Need Help ASAP PLEASE!!! ****** iLLuSionZ Linux - Newbie 4 11-18-2003 02:59 PM
Need Help Asap don_dimo Linux - Software 9 10-19-2003 02:11 PM
Need HELP ASAP!!!!! adamgedde Linux - Networking 12 10-18-2003 04:14 PM
Help asap! DoobyWho Linux - General 8 04-02-2003 05:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration