mysql - Why won't my SQL results get printed in PHP site? -



mysql - Why won't my SQL results get printed in PHP site? -

i'm having real problems code, have external server trying phone call , add together info single php info site. reason after reading loads on subject still cannot work.

the next code below, , concept have in mind, reason, having no luck in getting work correctly?

any help much appreciated:

<html> <head> </head> <body> <?php // determine yesterday date_default_timezone_set('europe/london'); $m= date("m"); // month value $de= date("d"); //today's date $y= date("y"); // year value $yd = date('d', mktime(0,0,0,$m,($de-1),$y)); $ym = date('m', mktime(0,0,0,$m,($de-1),$y)); $yy = date('y', mktime(0,0,0,$m,($de-1),$y)); $yest = $yy.'-'.$ym.'-'.$yd; $cd = date("y-m-d"); // create mysql connection ini_set('mysql.connect_timeout', '240'); // create mysql connection $con=mysql_connect("location", "username", "password"); // check mysql connection if (mysql_connect_errno()) { echo "failed connect mysql: " . mysql_connect_error(); } $test= mysql_query("select * db1.table date(datecreated) between '$yest' , '$yest'") or die(mysql_error()); echo "<table border='1'> <tr> <th> datafield1 </th> </tr>" while($row=mysql_fetch_array($test)){ echo "<tr> <th>" .$row['datafield1']. "</th> </tr><tr> <th>" .$row['datafield2']. "</th> </tr>"; } echo"</table>"; mysql_close($con); ?> </body> <footer> </footer> </html>

i'm sure it's glaringly obvious problem, i'm bit of novice database connections. current code produces nil on webpage when loaded.

meta-level error:

date(datecreated) between '$yest' , '$yest'

is wordy/useless version of

date(datecreated) = '$yest'

and if that's supposed "yesterday", of php date mangling code pointless. far easier straight in database:

where date(datecreated) = (curdate() - interval 1 day)

and functional errors:

if (mysql_connect_errno()) {

this function doesn't exist. mysql_*() functions homecoming boolean false, , you'd check this:

$db = mysql_connect(...); if ($db === false) { die(mysql_error()); }

php mysql database connection

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -