".mysql_error()); } function getRecordSet ($sql) { ($result = mysql_query($sql)) or die($sql."
".mysql_error()); return $result; } function getDicc ($taula, $idcmp, $ordcmp = '') { $sql = "SELECT * FROM $taula "; if ($ordcmp) $sql .= "ORDER BY $ordcmp"; $result = getRecordSet($sql); while ($row = mysql_fetch_array($result)) $dicc[$row[$idcmp]]=$row[valor]; mysql_free_result ($result); return $dicc; } function putDicc (&$dicc, $taula, $idcmp, $tipval=0) { $cm=prepSep($tipval); while (list($k,$v) = each ($dicc)) execSql ("UPDATE $taula SET valor = $cm$v$cm WHERE $idcmp = '$k'"); } function update (&$f, $proc, $txtInd=0) { if ($txtInd) $comet="'"; else $comet=""; $rs = getRecordSet ("SELECT * FROM gravacio WHERE form = '$proc' ORDER by taula"); if (mysql_num_rows ($rs)) { $rsFields = mysql_fetch_array($rs); $taula = $rsFields[taula]; $sql = "UPDATE ".$_SESSION['meeting']."_$taula SET "; $sset=Array(); do { if ($rsFields[taula] != $taula) { $sql .= join (', ', $sset). " WHERE $idt= $comet$idtv$comet "; execSql($sql); $rsFields = mysql_fetch_array($rs); $taula = $rsFields[taula]; $sql = "UPDATE ".$_SESSION['meeting']."_$taula SET "; $sset=Array(); } switch ($rsFields[tipus]) { case "T": $sset[] = " $rsFields[camp] = '".protCom($f[$rsFields[fcamp]])."'"; break; case "N": $sset[] = " $rsFields[camp] = ".protNum($f[$rsFields[fcamp]]); break; case "B": if ($f[$rsFields[fcamp]] == "on") $sset[] = " $rsFields[camp] = 1"; else $sset[] = " $rsFields[camp] = 0"; break; } $idtv = $f[$rsFields[idTaula]]; $idt = $rsFields[idTaula]; } while ($rsFields=mysql_fetch_array($rs)); $sql .= join (', ', $sset)." WHERE $idt = $comet$idtv$comet"; execSql($sql); mysql_free_result ($rs); } } function getNouIndex ($taula, $indcmp, $refcmp, $ref) { execSql ("INSERT INTO $taula ($refcmp) VALUES ('$ref')"); return mysql_insert_id (); } function insRecord (&$f, $proc) { $rs = getRecordSet ("SELECT * FROM gravacio WHERE form = '$proc' ORDER by taula"); if (mysql_num_rows($rs)) { $rsFields=mysql_fetch_array($rs); $taula = $rsFields[taula]; $camps = "INSERT INTO ".$_SESSION['meeting']."_$taula ("; $valors = ""; $lcamps = Array(); $lvals = Array(); do { if ($rsFields[taula] != $taula) { $sql = $camps. join (", ", $lcamps). ") VALUES (". join (", ", $lvals). ")"; execSql($sql); $taula = $rsFields[$taula]; $camps = "INSERT INTO ".$_SESSION['meeting']."_$taula ("; $valors = ""; $lcamps = Array(); $lvals = Array(); } else { $lcamps[] = $rsFields[camp]; switch ($rsFields[tipus]) { case "T": $lvals[] = "'". protCom($f[$rsFields[fcamp]])."'"; break; case "N": $lvals[] = protNum($f[$rsFields[fcamp]]); break; case "B": if ($f[$rsFields[fcamp]] == "on") $lvals[] = "1"; else $lvals[] = "0"; } } } while ($rsFields=mysql_fetch_array($rs)); $sql = $camps . join (", ", $lcamps). ") VALUES (". join (", ", $lvals). ")"; //print $sql; execSql($sql); mysql_free_result($rs); } } function delRecord ($taula, $indcmp, $indval, $txtInd) { if ($txtInd) $comet="'"; else $comet=""; execSql ("DELETE FROM $taula WHERE $indcmp = $comet$indval$comet"); } #Utilitats function pad ($t,$n) { return str_pad ($t,$n,"0",STR_PAD_LEFT); } function elimEspais($t) { return (trim($t)); } function elimCRLF ($t) { return str_replace ("\r\n"," ",$t); } function translStr ($txt,$a,$b) { return str_replace ($a,$b,$txt); } function elimStr ($txt,$a) { return str_replace ($a,"",$txt); } function protCom ($t) { $t1=str_replace ("\"",""",$t); return str_replace ("'","’",$t1); } function protNum($t) { return str_replace (",",".",$t); } function elimNoChar ($t) { # elimina dels extrems $a="������������������������<>()"; while (strpos($a,substr($t,0,1)) !== false) $t=delStr($t,0,1); while (strpos($a,substr($t,strlen($t)-1,1)) !== false) $t=delStr($t,strlen($t)-1,1); return $t; } function noAccents ($t) { return translStr ($t,"������������������������","aaeeiioouucnAAEEIIOOUUCN"); } function delStr ($a,$p1,$l) { return substr_replace ($a,"",$p1,$l); } # Dates function avui () { return date("Ymd"); } function ara () { return date ("His"); } function moment () { return date("YmdHis"); } function getTimestamp ($dat) { if (strlen($dat) == 8) return mktime(0,0,0,substr($dat,4,2),substr($dat,6,2),substr($dat,0,4)); else return mktime(substr($dat,8,2),substr($dat,10,2),substr($dat,12,2),substr($dat,4,2),substr($dat,6,2),substr($dat,0,4)); } function prdata ($idi,$dat) { if (strlen($dat) == 8) return date ("d/m/Y",getTimestamp($dat)); else return date("d/m/Y H:i",getTimestamp($dat)); } function plantilla (&$f,$txt) { reset ($f); foreach ($f as $k => $v) $txt=str_replace("%$k%",$v,$txt); return $txt; } function redirect ($url) { header ("Location:$url"); exit; } ?> Can't connect to MySQL server on 'www.aopc.es' (111)