Forum Moderators: coopster

Message Too Old, No Replies

PHP/MYSQL Issue -- Where Condition Problem

         

Knucklehead00

4:04 pm on Oct 23, 2008 (gmt 0)

10+ Year Member



Hey all.

While I am new to WW, I am not new to PHP/MYSQL. So, you can be as advanced in your speaking as you want to be and I will try my best to interpret :)

My current issue is with a SELECT query. Here is the code:

----------------------------------------------------------------------------------------------

$query = "SELECT phpfox_conference.conference_name, vault_sessions.title FROM vault_sessions
LEFT JOIN phpfox_conference ON (phpfox_conference.id = vault_sessions.conference)
WHERE vault_sessions.id=$session_id AND vault_sessions.conference=$es_event";
$title = current(getDataRow($query)) or die(mysql_error());

----------------------------------------------------------------------------------------------

The 'getDataRow' function is constructed on a different page. Here is the code for that function:

------------------------------------------------

function getDataRow($query){
$result = mysql_query($query);
$data = array();
while($row = mysql_fetch_row($result))
$data[] = $row;
return $data;
}

-------------------------------------------------

I am using the current function to step into the array and just grab the first result as that is all I need because I am in a FOR loop.

Now what is happening is this:

When the second WHERE condition is added to the query, "AND vault_sessions.conference=$es_event", the query fails to work and does not display an error or anything. Just no data is returned (I am doing a print_r on $title after the query is executed). However, when that second WHERE condition is taken out, the query works just fine.

Anyone have any other ideas about how to troubleshoot the issue or have an idea about what is wrong with my syntax or something of that sort?

Thanks for your time and I look forward to your responses.

RonPK

4:24 pm on Oct 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does this query return any rows?

$query = "SELECT vault_sessions.title  
FROM vault_sessions
WHERE vault_sessions.id=$session_id AND vault_sessions.conference=$es_event";

If not, that would explain why your query returns 0 rows...

Knucklehead00

4:32 pm on Oct 23, 2008 (gmt 0)

10+ Year Member



Array ( [title] => Magic, Madness and the Muse ) Array ( [title] => Righteous Game Audio ) Array ( [title] => Audio for Guild Wars ) Array ( [title] => Truly Original Melodies For Game Music: Use Your Head To Escape Your Head ) Array ( [title] => How to Rule the World (of Warcraft): Ten Lessons ) Array ( [title] => How to Rule the World (of Warcraft): Ten Lessons ) Array ( [title] => No More Excuses: Time for great game audio! ) Array ( [title] => Designing for Global Entertainment: Launching FINAL FANTASY XI on Multiple Platforms ) Array ( [title] => Designing for Global Entertainment: Launching FINAL FANTASY XI on Multiple Platforms ) Array ( [title] => Coming to America, Nexon's Micro-transaction Revolution ) Array ( [title] => Coming to America, Nexon's Micro-transaction Revolution ) Array ( [title] => Business Lessons for Post-WOW Games ) Array ( [title] => Business Lessons for Post-WOW Games ) Array ( [title] => How to Get Your Games into China ) Array ( [title] => How to Get Your Games into China ) Array ( [title] => Licensing MMOs Worldwide ) Array ( [title] => Licensing MMOs Worldwide ) Array ( [title] => When Did You Last Level Up? Career Advice From an Industry Veteran ) Array ( [title] => When Did You Last Level Up? Career Advice From an Industry Veteran ) Array ( [title] => Building Bridges: How to develop Social Networks as part of Community Management )

------------------------

Returns precisely what it should with that query.

RonPK

9:21 pm on Oct 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, as the query doesn't throw a MySQL error, perhaps it simply returns zero rows. Are you sure there should be matches?