envexlabs Posted September 5, 2007 Share Posted September 5, 2007 Hey, I have this query and a function: $search_form_query = mysql_query('SELECT * FROM `products` WHERE `name` LIKE CONVERT(_utf8 \'%' . $_GET[search_field] . '%\' USING latin1) COLLATE latin1_swedish_ci OR `description` LIKE CONVERT(_utf8 \'%' . $_GET[search_field] . '%\' USING latin1) COLLATE latin1_swedish_ci') or die('No results found for "' . $_GET[search_field] . '"'); page_counter($search_form_query); the function: function page_counter($query){ $page_count = mysql_result($query); print_r($page_count); } When i execute the script i get this error: Warning: Wrong parameter count for mysql_result() in /mnt/gs02/herd02/20143/domains/werehavingasale.com/html/inc/php/php_functions.php on line 777 Can i not use a query as a function variable? Any help is appreciated! Thanks, envex Quote Link to comment https://forums.phpfreaks.com/topic/68075-solved-wrong-parameter-count-error/ Share on other sites More sharing options...
lemmin Posted September 5, 2007 Share Posted September 5, 2007 You get that error because it is the wrong parameter count for mysql_result(). It takes two parameters: http://us3.php.net/manual/en/function.mysql-result.php Quote Link to comment https://forums.phpfreaks.com/topic/68075-solved-wrong-parameter-count-error/#findComment-342179 Share on other sites More sharing options...
envexlabs Posted September 5, 2007 Author Share Posted September 5, 2007 bingo! thanks. Quote Link to comment https://forums.phpfreaks.com/topic/68075-solved-wrong-parameter-count-error/#findComment-342180 Share on other sites More sharing options...
cooldude832 Posted September 5, 2007 Share Posted September 5, 2007 I think your function needs some optimizing, tell me what the goal of it is, but anyway your issue is that your query is returning >1 row thus you need to supply an argument to mysql_result() saying which part of the data you want. For this I would recommend this modification: <?php function page_counter($query){ while($row = mysql_fetch_array($query)){ //echo out return data or store in a multideminisonal array for print_r functions } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68075-solved-wrong-parameter-count-error/#findComment-342183 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.