mysql_fetch_assoc data to COOKIE in user browser

Posted by Gowtham Raj on Stack Overflow See other posts from Stack Overflow or by Gowtham Raj
Published on 2013-11-02T03:49:14Z Indexed on 2013/11/02 3:53 UTC
Read the original article Hit count: 205

Filed under:
|
|

I had data in mysql, where it does not need any security.

I had a sql query string to get the data out every time using mysql_fetch_assoc.

So, I planed to store data in users browser.To reduce no of quires to sql.

    if (!isset($_COOKIE['countries'])){
    $query = "SELECT iso,name FROM sel_country";
    $countries = mysql_query($query);
    setcookie('countries', serialize($countries), time()+3600);
   }else{
    $countries = $unserialize($_COOKIE['countries']);
    }
while ($row = mysql_fetch_assoc($countries)) {echo $row['name']}

But, When cookie is set it is showing following error

Fatal error: Function name must be a string in /home/worlds/public_html/index/ctrl.php on line 15

My cookie in browser displaying content as i%3A0%3B

Please help me out, how should i go?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql