Jump to content

wepnop

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

wepnop's Achievements

Member

Member (2/5)

0

Reputation

  1. Thats a way but... my problem is also that i was looking to instantiate some complex object that can have lots of data only a time in the server, and be accesed permantley, so you dont waste resources recreating that object.
  2. Exist in php a way to load or execute a thing only when you start the server and anything more? Because using sessions for example, you can check if exist, but thas too bugy and also exist a sesion for each user, so if i want a permament array of errors, for example, for each conection it will be created that array and some other things, and i want to have all the errors in one...
  3. Is a test function that prints a mark or variable: $cant_pe = 1; function pe ($val='') { global $cant_pe; # Si no se pasa ningun texto, muestra 'error x'. if (!$val) { $txt = "$cant_pe"; # Augmenta contador de pe's $cant_pe++; } else { $txt = (string)$val; } echo '<font color="red" >' . "<u><br><b>ERROR:</b>$txt<br> </u></font>"; }
  4. Im iterating a array but it dont work. Its says that only exist the Memoria Ram A, ehen there are 12 elements. But the strangest thing is that: $arr = $categorias[$clave]['lista_referencias']; $max = count($arr) -1; It says that max is an array. Wtf? count is converting it to array? This is the code that iterate: $categorias = &$_SESSION['reg']->GetInvCategorias(); $arr = $categorias[$clave]['lista_referencias']; $max = count($arr) -1; pe($max); # Itera en la lista de referencias para mostrar una descripcion con todas ellas for ($i=0; $i<= $max ; $i++) { #foreach ($categorias[$clave]['lista_referencias'] as $referencia) { $referencia = $categorias[$clave]['lista_referencias'][$i]; p($categorias[$clave]['lista_referencias'][$i]); $id_ref = $referencia[1]; echo "<b><u>Selecciona $id_ref. </b></u>"; #echo "<br><select name='$id_ref'><br><br>"; $nombre_sql = $categorias[$referencia[0]]['nombre_sql']; $cons = "SELECT * FROM `$nombre_sql`"; #echo "<option value=Ninguno>Ninguno</option>"; #p($cons); $res_ref = consultar_bd($cons, true); #insp_res($res_ref); while($row = mysql_fetch_array($res_ref)) { $array_keys = array_keys($row); $id = $row['ID']; $descripcion = ''; $i=1; #insp_sql_row($row); foreach($array_keys as $key) { $campo = $row[$key]; #iv ($campo); if ($i%2 == 0) { $descripcion .= "( $key : $campo) "; } $i++; } echo $descripcion . '<br>'; #echo "<option value='$id'>$descripcion</option>"; } And this the array that contais the array thats iterated(lista referencias) $categorias['PC'] = array( # Codigo identificativo interno 'nombre' => 'PC', # Nombre que sera visto por los usuarios externos 'nombre_externo' => 'PC', # El nombre que se va a usar en la tabla sql 'nombre_sql' => 'PC', # Titulo de la pagina 'titulo' => 'Insertar ordenador', # Encabezado de la pagina 'encabezado' => 'Insertar ordenador', # Descripcion del modulo en general 'descripcion' => 'Los ordenadores contienen otros elementos.', # Imagen que se mostrar junto a la descripcion 'imagen' => 'ordenador.jpg', # Contenedora: las contenedoras tienen dentro de si mismas otras categorias, en una relacion por ejemplo, PC-Componenete. 'contenedora' => true, # Lista de referencias: aqui se ponen los nombres-codigo de cada componente que posee # cada contenedora # array(Nombre de la cateogira, Identificador unico que se vera por el usuario) 'lista_referencias' => array( array('Memoria Ram', 'Ranura Ram A'), array('Memoria Ram', 'Ranura Ram B'), array('CPU', 'CPU'), array('DVD', 'DVD'), array('Placa base', 'Placa base'), array('Disquetera', 'Disquetera'), array('Dico Duro', 'Dico Duro'), array('Raton', 'Raton'), array('Teclado', 'Teclado'), array('Caja', 'Caja'), array('Caja Disco Externo', 'Caja Disco Externo'), array('SO', 'SO') ), # Activada: si no lo esta no se vera en la aplicacion a nivel externo 'activada' => true, # Campos del formulario, tipo, nombre y descripcion para cada uno. Ordenados como saldran. 'campos' => array( 0 => array( # Tipo: 1: numero, 2: texto, 3: lista de opciones 'tipo' => 2, # Ha de coincidir con el campo sql 'nombre sql' => 'Modelo', # Ha de coincidir con el campo sql 'tipo sql' => 'Texto', # Tamaño del campo sql 'tamanyo sql' => 25, # Nombre usado por la web 'nombre' => 'Modelo', # Descripcion del elemento 'descripcion' => 'Modelo del ordenador' ) ) );
  5. Sorry maybe its that my english is bad, but i think i asked it: What i need is to get the max of the ID value in the ordenador table using php + mysql. Thats the code i was using but it dont works, when i try to get the ID it says that index dont exist. I need some way to know and store in a php variable what is the higest ID value.
  6. I need to get the max of the field called ID, from the table ordenador. This is my actual code: $cons = "SELECT MAX(ID) FROM `ordenador`"; $maxrow = consultar_bd($cons); $id_contiene = $maxrow['ID']; consultar_bd is a function that executes a sql query and returns a fetched result as a array.
  7. Well, actually my problem is that somewhat this still failing, but its too random i think. The problem is that times it dont create the register when its not instantied. Its a wtf but its happening...
  8. How i can pass complex strings with spaces using $_POST? see for example: $string = 'I have spaces'; <input type=hidden value=$string> The value will be only I. Any suggestion for these things?
  9. I need a clean and stable way to execute code only when the program starts. I use that to create a register in the $_SESSION, and do some other things that i really need one time. I also save a error array in my register object so if its recreated each time that is losed. This is the file that is called always in all my files, in the first line. <?php # Various includes for functions include 'bd.php'; include 'sesiones.php'; include 'test.php'; include 'web_inventario.php'; include 'errores.php'; include 'usuarios.php'; include_once 'registroglobal.php'; # This start the session so i can check for it and store in it without warnings and problems. session_start(); # This code is the code that will be executed the first time. reg is the register thats persistent through sesions. The idea is that # if the register isnt isset it will be settled and this is all, just for the first time-. if (!isset($_SESSION['reg'])) { $reg = RegistroGlobal::GetInstance(); p('SETEJA SES'); # Configura para usar la libreria basica $reg->setConf('Libreria usada', 'Inventario'); include '/../ijb_categorias.php'; include '/../ijb_configuracion.php'; # Set various configurations and save in $_SESSION $reg->setInvConfig($configuracion); $reg->setInvCategorias($categorias); $_SESSION['reg'] = $reg; $_SESSION['reg']->setConf('Ruta BD', $configuracion['conexion_bd'][0]); $_SESSION['reg']->setConf('Nombre usuario', $configuracion['conexion_bd'][1]); $_SESSION['reg']->setConf('Contraseña', $configuracion['conexion_bd'][2] ); $_SESSION['reg']->setConf('Nombre BD', $configuracion['conexion_bd'][3]); $_SESSION['reg']->setConf('Logs', $configuracion['Logs'][3]); # Primero setea la conexion de la base de datos sin selccionar ninguna, # de esta forma no da error y permite crear una nueva o navegar sin ella $_SESSION['reg']->setDB(conectar_bd(false)); if ($configuracion['Recargar inicio'] ) { cargarConfiguracionCategorias(); #echo 'MARCA REGGGGGGGGGGGGGGGGGGGGGGGGGGGG<br><br>'; } # Actualiza el administrador $usradm = $configuracion['Administrador']; $cons = "UPDATE `usuarios` SET rango = 3 WHERE nombre = '$usradm'"; modificar_bd($cons); } # Code to execute always(conect to database) # Se asegura de conectar con la base de datos seleccionando, podria fer consulta sql de si existe o no bd $_SESSION['reg']->setDB(conectar_bd()); ?> But this isnt working. Its giving me troubles. When i think it works, in other computer or at the next day it gets broken. I dont understand why i only need that...
  10. Bueh, i solved it, but using some control exceptions. Now i call my menu function with a argument for when its categories or not. Also now i understand the auto-add of urls in html. If you write a / before the url, it adds the base path to it, it was bugging me a lot.
  11. Then how i can work with absolute paths? I need to use then only /tr/? (as it is www/tr) I get it. Absolute path is this: http://localhost/tr/categorias/listar_Ordenador.php But that only works in pure localhost. Bad idea. I think i cant use absolute paths for this, no?
  12. They can be large, anyway changue it is 1m and 0 if i know it on now.
  13. c:\wamp\www\tr\categorias\listar_Ordenador.php this the link generated
×
×
  • 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.