blogit Posted May 23, 2008 Share Posted May 23, 2008 I'm having trouble with a script that is pretty basic but my coding is that great so far i have it getting the current domain and putting it into a variable which is simple enough, I then want it to run a search on a table in a database and if the current domain is there to echo it out. The mysql query im using is below if anyone can help with the rest i'd really appreciate it. <?php include 'config.php'; include 'opendb.php'; $pageUR1 = ereg_replace("/(.+)", "", $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); $curdomain = str_replace("www.", "", $pageUR1); $query = "SELECT page_url FROM page LIKE '%$curdomain%'"; Link to comment https://forums.phpfreaks.com/topic/106867-search-for-a-variable-in-mysql/ Share on other sites More sharing options...
pocobueno1388 Posted May 23, 2008 Share Posted May 23, 2008 Try <?php include 'config.php'; include 'opendb.php'; $pageUR1 = ereg_replace("/(.+)", "", $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); $curdomain = str_replace("www.", "", $pageUR1); $query = "SELECT COUNT(*) FROM page WHERE page_url='$curdomain'"; $result = mysql_query($query)or die(mysql_error()); $count = mysql_result($result, 0); if ($count > 0) echo $curdomain; else echo "Domain not in database"; ?> Link to comment https://forums.phpfreaks.com/topic/106867-search-for-a-variable-in-mysql/#findComment-547811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.