Jump to content

[SOLVED] No results, no errors


timmah1

Recommended Posts

I get no errors or no results with this.

$sport = $_GET['sports'];
$query = "SELECT * FROM articles WHERE sport = '$sport' AND publish = '".date('Y-m-d')."'";

 

If I hard-code the variables in like this

$query = "SELECT * FROM articles WHERE sport = 'nba' AND publish = '2009-01-05'";

 

Can someone tell me why?

 

Thanks in advance

Link to comment
Share on other sites

When I echo $query, I get this

SELECT * FROM articles WHERE sport = 'nba' AND publish = '2009-01-05' 

 

Just what I need, but no results

 

The code is like so

$query = "SELECT * FROM articles WHERE sport = '$sport' AND publish = '".date('Y-m-d')."'";
$q = mysql_query($query);
while ($a = mysql_fetch_array($q)) {
echo $a['article'];

}

Link to comment
Share on other sites

Holy.  Crap.  I beg of you people to put OR die(mysql_error()) after your queries so you can see what's going on. =/

 

I thought DarkWater already set you straight...  Add or die(mysql_error()) at the end of your query!

Link to comment
Share on other sites

yes he did, and I've already done that

<?php
$sport = mysql_real_escape_string($_GET['sports']);
$query = "SELECT * FROM articles WHERE sport = '$sport' AND publish = '".date('Y-m-d')."'";
$q = mysql_query($query)
or die("Sorry, there was a problem selecting the articles<br /> ".mysql_error());	
while ($a = mysql_fetch_array($q)) 
{
echo $a['article'];

}
?>

 

With no results, no errors, nothing

Link to comment
Share on other sites

<?php
$sport = mysql_real_escape_string($_GET['sports']);
$query = "SELECT * FROM articles WHERE sport = '$sports' AND publish = '".date('Y-m-d')."'";

 

You're using $sports in the query, and setting $sport on the line above it.  Pick one. ;)

 

 

lol sorry was funny.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.