Jump to content

Recommended Posts

 

index.php:

 

include('code/incs.php');
include('code/main.php');

 

code/incs.php:

 

function getRec($taulu, $kentat, $lopuke = '') {
  $qstr = "SELECT $kentat FROM $taulu $lopuke";
  $qres = mysql_query($qstr);
  if ($qres === false) return false;
  $t = mysql_fetch_array($qres, MYSQL_ASSOC);
  mysql_free_result($qres);
  return $t;
}

function func() {
  global $arr;
  $arr = getRec('versiot', '*', "WHERE active=1"); }
}

 

 

code/main.php:

 

func();

 

if in function func() i comment the global line, the code is not loaded twice.

Link to comment
https://forums.phpfreaks.com/topic/134238-php-loading-twice/#findComment-698792
Share on other sites

 

if from getRec I return a record from database,

Array
(
    [id] => 32
    [sitename] => sp1
    [logo] => 
    [valikot] => valikot_sp1
    [active] => 0
    [onwork] => 1
    [teema] => perus
    [naytalogo] => 0
    [naytasitename] => 0
    [kanta] => sp1
)

 

then all are loaded twice. If I return an array: array(1,2,3), that does not happen.

 

?

Link to comment
https://forums.phpfreaks.com/topic/134238-php-loading-twice/#findComment-698805
Share on other sites

Srange: If I use MYSQL_NUM insted of MSQL_ASSOC, all works properly. Nothing is loaded again.

 

function getRec($taulu, $kentat, $lopuke = '') {
  $qstr = "SELECT $kentat FROM $taulu $lopuke";
  $qres = mysql_query($qstr);
  if ($qres === false) return false;
  $t = mysql_fetch_array($qres, MYSQL_NUM);
  mysql_free_result($qres);
  return $t;
}

Link to comment
https://forums.phpfreaks.com/topic/134238-php-loading-twice/#findComment-698840
Share on other sites

Srange: If I use MYSQL_NUM insted of MSQL_ASSOC, all works properly. Nothing is loaded again.

 

function getRec($taulu, $kentat, $lopuke = '') {
  $qstr = "SELECT $kentat FROM $taulu $lopuke";
  $qres = mysql_query($qstr);
  if ($qres === false) return false;
  $t = mysql_fetch_array($qres, MYSQL_NUM);
  mysql_free_result($qres);
  return $t;
}

 

MSQL_ASSOC?  Do you mean MYSQL_ASSOC?  I don't even see where you use this in the first place...

Link to comment
https://forums.phpfreaks.com/topic/134238-php-loading-twice/#findComment-698886
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.