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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.