dflow Posted December 23, 2008 Share Posted December 23, 2008 SELECT * FROM country_list WHERE CountryID = $row_RsPDetails['CountryID'] i want this query to GET the queried product's CountryID what am i doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/ Share on other sites More sharing options...
Yesideez Posted December 23, 2008 Share Posted December 23, 2008 Not a lot to go on, many things could be wrong. Have you checked the contents of $row_RsPDetails['CountryID'] to see exactly what you're looking with? Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-722235 Share on other sites More sharing options...
dflow Posted December 23, 2008 Author Share Posted December 23, 2008 lets try the logical part and maybe you have a solution this is a product page filtered by the ProductID each product has a unique CountryID i want to get the CountryID without a CountryID url parameter Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-722254 Share on other sites More sharing options...
Yesideez Posted December 23, 2008 Share Posted December 23, 2008 I can see what you're trying to do but without any code and any error message it's impossible to say what's wrong! Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-722291 Share on other sites More sharing options...
Mark Baker Posted December 23, 2008 Share Posted December 23, 2008 On the database, is CountryID a VARCHAR2 or other character data type? Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-722457 Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 dflow, please post ALL the relevant code. We don't know how $row_RsPDetails['CountryID'] is created. Do you have debugging on for both PHP and your query statements? Like Yesideez said, we need more information or we're just guessing! Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-722503 Share on other sites More sharing options...
dflow Posted December 24, 2008 Author Share Posted December 24, 2008 CountryID is VARCHAR here is the code <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_RsPDetails = "-1"; if (isset($_GET['ProductID'])) { $colname_RsPDetails = $_GET['ProductID']; } mysql_select_db($database_international, $international); $query_RsPDetails = sprintf("SELECT * FROM products WHERE ProductID = %s", GetSQLValueString($colname_RsPDetails, "int")); $RsPDetails = mysql_query($query_RsPDetails, $international) or die(mysql_error()); $row_RsPDetails = mysql_fetch_assoc($RsPDetails); $totalRows_RsPDetails = mysql_num_rows($RsPDetails); mysql_select_db($database_international, $international); $query_RsCountry = "SELECT * FROM country_list WHERE CountryID = $row_RsPDetails['CountryID']"; $RsCountry = mysql_query($query_RsCountry, $international) or die(mysql_error()); $row_RsCountry = mysql_fetch_assoc($RsCountry); $totalRows_RsCountry = mysql_num_rows($RsCountry); ?> Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-723140 Share on other sites More sharing options...
flyhoney Posted December 24, 2008 Share Posted December 24, 2008 Hows about using your formatting function on that query: <?php $query_RsCountry = sprintf("SELECT * FROM country_list WHERE CountryID = %s", GetSQLValueString($row_RsPDetails['CountryID'], 'int')); ?> Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-723151 Share on other sites More sharing options...
revraz Posted December 24, 2008 Share Posted December 24, 2008 Non Integers need a single quote around them in your Query. Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-723153 Share on other sites More sharing options...
flyhoney Posted December 24, 2008 Share Posted December 24, 2008 Oh, just realized you said CountryID is a varchar. <?php $query_RsCountry = sprintf("SELECT * FROM country_list WHERE CountryID = %s", GetSQLValueString($row_RsPDetails['CountryID'], 'text')); ?> Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-723154 Share on other sites More sharing options...
dflow Posted December 24, 2008 Author Share Posted December 24, 2008 thx works like a charm Quote Link to comment https://forums.phpfreaks.com/topic/138169-get-and-query-string/#findComment-723260 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.