Jump to content

[SOLVED] Little Help Please


paulman888888

Recommended Posts

I tryed but for some reason it wont work.

 

Heres my code

 

<?php
error_reporting(E_ALL);
include'connection_1.php';
$strr = $_GET['only'];
$strr = strtolower($strr);
$allowedonly = array('upcoming', 'events');
if(isset($_GET['only'])){
if(in_array($strr,$allowedonly)){
if($strr='upcoming'){$opp='>';}
elseif($strr='past'){$opp='<';}
$sort="WHERE date_field ".$opp." '".date("Y-m-d")."'"; 
}else{$error='Search Not Found';$sort='';}}else{$sort='';}
  $result = mysql_query("SELECT * FROM chess_events '$sort'"); 
?>

and i get error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/site/events.php on line 46

 

thankyou

for all the help!

Paul

 

Link to comment
Share on other sites

I think your code is unnecessarily complicated.  What about simplifying?

 

<?php
error_reporting(E_ALL);

include'connection_1.php';

$query = "SELECT * FROM chess_events";
if (isset($_GET['only']))
{
if ($_GET['only'] == 'upcoming')
{
	$query .= " WHERE date_field > CURDATE()"; 
}
elseif ($_GET['only'] == 'past')
{
	$query .= " WHERE date_field < CURDATE()";
}
}
$result = mysql_query($query); 
?>

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.