Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

PHP and SQL calling table value issue


3 replies to this topic

#1 karlosantana

    Advanced Member

  • Kontributors
  • PipPipPipPipPipPipPip
  • 145 posts
  • Gender:Male
  • Location:Wales(But I'm not a welsh farmer!)

Posted 16 February 2010 - 10:14 AM

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

#2 karlosantana

    Advanced Member

  • Kontributors
  • PipPipPipPipPipPipPip
  • 145 posts
  • Gender:Male
  • Location:Wales(But I'm not a welsh farmer!)

Posted 17 February 2010 - 02:37 PM

*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

#3 karlosantana

    Advanced Member

  • Kontributors
  • PipPipPipPipPipPipPip
  • 145 posts
  • Gender:Male
  • Location:Wales(But I'm not a welsh farmer!)

Posted 17 February 2010 - 02:51 PM

Ok download wont work attached insteadAttached File  class.sql2csv.zip   8.06K   0 downloads

#4 Soviet Rathe

    Super Member

  • Kontributors
  • PipPipPipPipPipPipPipPipPip
  • 426 posts
  • Gender:Male
  • Location:Illinois USA
  • myCENT:88.04

Posted 16 March 2010 - 08:03 PM

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.

Edited by Soviet Rathe, 16 March 2010 - 08:05 PM.





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users