Jump to content

[SOLVED] Wrong parameter count error


envexlabs

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/68075-solved-wrong-parameter-count-error/
Share on other sites

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
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.