sql - PHP - where clause equals 2 values grabbed from URL is not showing any results? -


i trying results specific race @ specific meet.

raceresult.php?meet=<i>august meet</i>&race=<i>allowance fillies 2yo</i> 

the meet , race showing first query , of results show. example:

this 1 works

raceresult.php?meet=meet=2013 ojcr australian derby&race=allowance - 9f on turf 3yo 

does not work

raceresult.php?meet=2009 gulfstream park grand opening meet&race=flying stakes - grade i, 3 yr old+, 8f on dirt 

are there characters causing error in second example? can go through , fix issue pretty i'm not sure keeping url working while other 1 works great.

my code follows.

<?php   $sql = "select * racing `meet` = '$meet' limit 1";  $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); while($row = mysql_fetch_array($query)){   $date= $row['date']; echo "<h2><strong>$meet</strong> ($date)</h2>"; echo "<b>$race</b><br>"; } ?>  <?php   $sql = "select * racing `meet`='$meet' , `race`='$race' order place";  $query = mysql_query($sql) or die( mysql_error() . "<br />" . $sql ); while($row = mysql_fetch_array($query)){   $place= $row['place']; $horse= $row['horse']; $farm= $row['farm'];  echo"$place. $horse owned $farm";  } ?> 

as starting point, when creating variables url, should passed through urlencode convert spaces can used.

once in script on page, use urldecode replace encoded characters normal ones. (this bit might not required - try it)

then pass them through mysql_escape_string make them play nice , lower chance of sql injection.

try echoing created $sql string screen or log can see exactly being attempted. making sure variables coming through correctly. also, can try running sql directly in mysql session check sql correct.

finally, stop using mysql_ functions - they're deprecated. mysqli_ or pdo way o


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -