/    Sign up×
Community /Pin to ProfileBookmark

MySQL Select Query no longer working

I have been using the following query in a ticketing system for many years

[CODE]“select * from Callbacks where Callbacks.cartId = TicketsSold.OrderID and TicketsSold.MC_EventDate = ‘Fri 22nd Apr’ GROUP BY cartId”[/CODE]

And its always returned the necessary data, however now its telling me that [i]Unknown column ‘TicketsSold.OrderID’ in ‘where clause’[/i]

The data in the table is still the same as are the tables and their columns.

Can anyone advise what is incorrect about this please? I have tried adding ‘ around the table.column but that just returns no data

Many thanks for any help

Just to add to this….I have added the single quotes and it no longer errors, but I get on data. Below is my code to output the data:

[code]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Attendance List Fri 22nd April 2011</title>
<?php
//we need to connect to the database so
require(‘db_connect.php’);
?>
<?php
$query = “select * from Callbacks where Callbacks.cartId = ‘TicketsSold.OrderID’ and ‘TicketsSold.MC_EventDate’ = ‘Fri 22nd Apr’ GROUP BY cartId”;
$results = mysql_query($query) or die(mysql_error());
?>
<style type=”text/css”>
<!–
.style1 {font-family: Verdana}
.style2 {font-family: Verdana; font-size: 13px; }
–>
</style>
</head>

<body>
<p class=”style1″><font size=”4″ face=”Tahoma”>Online Ticketing<b> <br />
Attendance List for :</b></font> Friday 22nd April 2011</p>
<p>
<title></title>
<hr /> <?php

while ($row = mysql_fetch_array($results)) {
extract($row);
echo “<table width=”100&#37;” border=”0″>”;
echo “<tr>”;
echo “<td width=”17%”><span class=”style1 style36 style10″><strong>Ticket No </strong></span></td>”;
echo “<td width=”20%”><span class=”style1 style36 style10″><strong>Name</strong></span></td>”;
echo “<td width=”43%”><span class=”style1 style36 style10″><strong>Address</strong></span></td>”;
echo “<td width=”21%”><span class=”style1 style36 style10″><strong>Ticket Details </strong></span></td>”;
echo “</tr>”;
echo “<tr>”;
echo “<td valign=”top” class=”style2″>$cartId </td>”;
echo “<td valign=”top” class=”style2″>$customername</td>”;
echo “<td valign=”top” class=”style2″>$customeraddress</td>”;
echo “<td valign=”top” class=”style2″>$M_disc </td>”;
echo “</tr>”;
echo “</table>”;
echo “<hr>”;
}

?>

</p>
<p class=”style2″>End of List for this Date</p>
</body>
</html>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DarrenauthorApr 21.2011 — Scrap that, solved it by changing my query to

[CODE]"select * from TicketsSold, Callbacks where Callbacks.cartId = TicketsSold.OrderID and TicketsSold.MC_EventDate = 'Fri 22nd Apr' GROUP BY cartId"[/CODE]
Copy linkTweet thisAlerts:
@DasherApr 21.2011 — for easier reading I always write my queries in caps like this;

"SELECT * FROM TicketsSold, Callbacks WHERE Callbacks.cartId = TicketsSold.OrderID AND TicketsSold.MC_EventDate = 'Fri 22nd Apr' GROUP BY cartId"

Your event date must be just a text entry, since a real MySQL date would be more like '2011-04-22 0000:00:00'
Copy linkTweet thisAlerts:
@DarrenauthorApr 21.2011 — Thanks.......i'm intrigued though as to why it after all this time suddenly needs the amendment to work

?
×

Success!

Help @Darren spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...