Jump to content

bothered: '1 (16 - 31) 2007'


jnroche

Recommended Posts

okay now im trying to query a string datatype from a db table the field is: payperiod (varchar(20)), in php i do this :$tblovertimes = mysql_query("SELECT * FROM tblovertimes WHERE payperiod='".$period."', $db); <--- that is single quote followed by double quote then vice versa$fetch = mysql_fetch_array($tblovertimes);that line does not produce any results at all!but THIS:$tblovertimes = mysql_query("SELECT * FROM tblovertimes WHERE payperiod='1 (16 - 31) 2007', $db);$fetch = mysql_fetch_array($tblovertimes); DOESOR THIS:$period = '1 (16 - 31) 2007';$tblovertimes = mysql_query("SELECT * FROM tblovertimes WHERE payperiod='".$period."', $db);$fetch = mysql_fetch_array($tblovertimes);ALSO PRODUCES RESULTSBUT THIS:$period = $month." (".$from." - ".$to.") ".$yearnow; //echoes 1 (16 -31) 2007 with the right spacing.. assuming variables are in the right order of values$tblovertimes = mysql_query("SELECT * FROM tblovertimes WHERE payperiod='".$period."', $db);$fetch = mysql_fetch_array($tblovertimes);DOES NOT PRODUCE ANY RESULTS AT ALL! WHY WHY WHY OH WHY!!!! :)

Link to comment
Share on other sites

I don't know if you done this when you posted here or it's in your code too, but there's two problems that I see right now, where the second one can be the real "bug":1. You don't end the strings. Here's an example

mysql_query("SELECT * FROM tblovertimes WHERE payperiod='".$period."', $db); // Note the lack of a last double quoteshoud be:mysql_query("SELECT * FROM tblovertimes WHERE payperiod='".$period."'", $db); // Note the last double quote

2. You've forgot a space when you put the string together (after the - )

$period = $month." (".$from." - ".$to.") ".$yearnow;  // the result of this is '... -31 ..' => "negative 31"should be:$period = $month." (".$from." -  ".$to.") ".$yearnow; // the result of this is '... - 31...'

Hope that helped.Good Luck and Don't PANIC.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...