Jump to content

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
https://forums.phpfreaks.com/topic/139616-solved-no-results-no-errors/
Share on other sites

Are you running mysql_query on the query?

 

Or you checking if it errors out? You should really do mysql_real_escape_string on $_GET['sports'] as if you have a ' in that get statement it will cause an error. And it leaves you open to SQL Injection.

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'];

}

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

<?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. ;)

<?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.

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.