Honesty Rocks! truth rules.

PHP and SQL calling table value issue Im Stuck Again

HOME      >>       Websites and Web Designing

karlosantana

I have no idea why the heck I'm struggling with this, I'm usually the one giving the help for this sort of thing! Anyway here goes: It's my date comparison script again, I've added the abbility to select "from" and "to" using THIS script I've made the code below

<?php require_once 'class.sql2csv.php'; $params = array( 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'database_name' ); $query = "SELECT * FROM form_data WHERE (sd >='_$date') and (sd < '_$date2')"; new SQL2CSV($params, $query);?>

Now what's happening is: it'll pick up "date2" but not "date" and I have no idea what the heck is going on! I've tried all that I know to try and get it right, I'm still confusled!

I'm left in your capable hands, thanks in advance
Kyle

karlosantana

*UPDATE*
I have now made it easier to see what I mean, a link to the site can be found HERE and you can take a look at the code HERE. You may have noticed I've added $_POST in the dump_data file. I was trying another way of skinning this cat!
Thanks again
Kyle


karlosantana

Ok download wont work attached insteadclass.sql2csv.zip


Soviet Rathe

If you're still having problems try this:

<?php//log into the database$dbhost = 'localhost';$dbuser = 'username';$dbpass = 'password';$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');$dbname = 'dbname';mysql_select_db($dbname);// get the sql info$query = mysql_query("SELECT `date`,`date2` FROM `dbtable` WHERE `id`=" . mysql_real_escape_string . " LIMIT 1");//then you need to get the result into an array$result = mysql_fetch_assoc($query);?>
Then to show the result:
{$result['date']}{$result['date2']}
Hope that works.