Foros del Web » Programando para Internet » PHP »

Errores varios en script

Estas en el tema de Errores varios en script en el foro de PHP en Foros del Web. Hola webforeros!! Estoy con un proyecto con php y mysql y al intentar usar una de mis opciones del menu que es insertar un cliente ...
  #1 (permalink)  
Antiguo 10/02/2011, 11:24
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Errores varios en script

Hola webforeros!!
Estoy con un proyecto con php y mysql y al intentar usar una de mis opciones del menu que es insertar un cliente en la base de datos me sale este error, sé que me falta la conexión a la base de datos, pero esto es anterior..

Estos son los errores:




Notice: Undefined variable: POST in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 24

Notice: Use of undefined constant SCRIPT - assumed 'SCRIPT' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 31

Notice: Undefined variable: PHP_SELF in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 31

Notice: Use of undefined constant NAME - assumed 'NAME' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 32

Deprecated: Function mysql_db_query() is deprecated in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 54

Deprecated: mysql_db_query() [function.mysql-db-query]: This function is deprecated; use mysql_query() instead in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 54
No database selected


ÉSTE ES EL CÓDIGO DONDE ME DA EL FALLO:



<?
/************************************************** *****************************
* file: insert_customer.php
* description: Inserts a Customer
* templates: insert.tpl
************************************************** *****************************/
session_start();

require_once('class.FastTemplate.php4');
require_once('connection_data.php');
require_once('mysql_func.php');
require_once('insertFunc.php');
require_once('class.rc4crypt.php');
require_once('crypt.inc.php');
//------------------------------ main -------------------------------------

$ret = 2;
//get the information via http post

$insert = $POST['Insert'];

//initialize the fast templates
$tpl = new FastTemplate(".");
$tpl->define(array("main" => "templates/insert.tpl"));

$tpl->assign(SCRIPT, $PHP_SELF); // redirige a la misma pagina
$tpl->assign(NAME, "Insert Customer"); //asigna a NAME el 'titulo' del form
showServices($tpl); //llama a funcion showServices para mostrar la lista de servicios
ShowContactPerson($tpl); //llama a showContactPerson para mostrar la lista de personas
$tpl->assign(DATE, date("Y-m-j"));

if ($insert == 'Insert')
{
$ret = checkValues($tpl);

}
else resetValues($tpl);

// check values and then all are correct
if ($ret==0)
{
//insert values into database
$cus_id = insertValuesIntoDB();

confirmInsertion("templates/confirm.tpl");
//reset values
reset($POST);
$ret = 2;
$insert = "";

exit();

}

else if ($ret==1)
{
$tpl->assign(NAME, "<FONT COLOR=\"red\"> Error </FONT>");
}
$tpl->assign(BUTTONS, '<input class="buttons" type = "submit" value="Insert" color=blue name="Insert"> <input class="buttons" type="reset" value="Reset" name="reset">');

//display the template
$tpl->parse(result, "main");
$tpl->FastPrint(result);

?>


Alguna idea?

Gracias!!
  #2 (permalink)  
Antiguo 10/02/2011, 11:26
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

definitivamente todos los errores son muy claros, ¿no sabes usar un traductor?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #3 (permalink)  
Antiguo 10/02/2011, 11:29
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

jo macho así no me ayudas, se que pone variable no definida, pero es que este proyecto lo hice hace meses y me funcionaba, y ahora me saca estos "notices" que no sé a que se refieren..
  #4 (permalink)  
Antiguo 10/02/2011, 11:36
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

Cita:
Iniciado por edugilc Ver Mensaje
jo macho así no me ayudas, se que pone variable no definida, pero es que este proyecto lo hice hace meses y me funcionaba, y ahora me saca estos "notices" que no sé a que se refieren..
por eso, si entiendes lo que dicen?

Cita:
Notice: Undefined variable: POST
primero, $POST no existe... ¿de verdad antes te funcionaba? no lo creo, ya que dicha variable nunca ha existido en PHP... lo que si existe es $_POST, lo mismo pasa con $PHP_SELF, ya que deberías usar $_SERVER['PHP_SELF']

Cita:
Notice: Use of undefined constant SCRIPT - assumed 'SCRIPT'
eso pasa por usar nombres de constante no definidos, y que por ende deberías definir correctamente.. osea, usar un string como nombre de la constante!!

Cita:
Deprecated: Function mysql_db_query() is deprecated
dice que la función es obsoleta, por favor, por todo... consulta el manual....
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #5 (permalink)  
Antiguo 10/02/2011, 11:46
 
Fecha de Ingreso: enero-2011
Ubicación: DF
Mensajes: 898
Antigüedad: 13 años, 2 meses
Puntos: 155
Respuesta: Errores varios en script

cambia algunas cosas


Código PHP:
/*para por si no se han mandado datos desde el post no te saque el notice de indefinido aunque pienso que deberias inicializar*/
@$insert $_POST['Insert']; 

la funcion mysql_db_query esta en desuso
aqui viene la alternativa

http://php.net/manual/en/function.mysql-db-query.php

Código PHP:
/*veo que usas fast template

las variables se definen asi*/

$tpl->assign("SCRIPT"$PHP_SELF);
/*con comillas*/ 
Código PHP:
/*se me hace que la variable de phpself que quieres usar es esta*/ 
$_SERVER['PHP_SELF'

por que antes jalaba? pienso que hubo una actualizacion de version de php en donde ejecutabas esos scripts

Última edición por mogurbon; 10/02/2011 a las 11:52
  #6 (permalink)  
Antiguo 10/02/2011, 12:58
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

Antes de nada, gracias por tu tiempo!!

Comentarte, que los errores a los que me refiero me salen en TODAS las opciones que tengo del menú:

Insertar Cliente
Editar Cliente
Buscar Email
..
..

Por lo que que pienso que debe ser algo mas general..
Fiate de mí en que esto antes funcionaba..


te pongo algunos ejemplos para que veas a lo que me refiero:

Los errores del insertar cliente al final me quedaron así:

Notice: Use of undefined constant SCRIPT - assumed 'SCRIPT' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 30

Notice: Use of undefined constant NAME - assumed 'NAME' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\insert_customer.php on line 31

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 51


No sé como declarar esas variables que me dices aquí..

EDITAR CLIENTES ME DA ESTOS FALLOS:

Notice: Undefined variable: COLOR in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 22

Notice: Trying to get property of non-object in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 22

Notice: Undefined variable: COLOR in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 23

Notice: Trying to get property of non-object in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 23

Notice: Undefined variable: COLOR in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 24

Notice: Trying to get property of non-object in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\general.inc.php on line 24

Notice: Use of undefined constant Insert - assumed 'Insert' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\select_customer.php on line 35

Notice: Undefined variable: HTTP_POST_VARS in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\select_customer.php on line 35

Notice: Use of undefined constant SCRIPT - assumed 'SCRIPT' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\select_customer.php on line 41

Notice: Use of undefined constant NAME - assumed 'NAME' in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\select_customer.php on line 42

Notice: Undefined variable: country_html in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\select_customer.php on line 50

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 51




Y este es su código:

el de select_customer.php:


<?php
session_start();


require_once('class.FastTemplate.php4');
require_once('connection_data.php');
require_once('mysql_func.php');

require_once('insertFunc.php');
require_once('editFunc.php');

require_once('general.inc.php');
require_once('color.inc');

require_once('class.rc4crypt.php');
require_once('crypt.inc.php');

//------------------------------ main -------------------------------------

$ret = 2;

//get the information via http post

$insert = $HTTP_POST_VARS[Insert];

//initialize the fast templates

$tpl = new FastTemplate(".");
$tpl->define(array("main" => "templates/edit_list.tpl"));
$tpl->assign(SCRIPT,$PHP_SELF);
$tpl->assign(NAME, "Customer");


//-------------------------------------------------------------------------------------------------------------------

country_select($tpl,$country_html);
getSelectValue_3($tpl,"edit_customer.php",$letter) ;
editListServices ($tpl, $services_html);
company_select($tpl,$companylist_html); //added by egil 15.10.2009

if ($edit == "Edit") {
?>
<script>

function redir(){
window.location.href = "edit_customer.php?id=<?echo($id);?>&serv=<?echo($ services_html);?>"
}

redir();

</script>
<?php

}

//$tpl->assign(BUTTONS_1, '<input method = "" class="buttons" type ="submit" value="Sent" name="ordered"> ');
$tpl->assign(BUTTONS, '<input method = "" class="buttons" type ="submit" value="Edit" name="edit"> ');

//display the template

$tpl->parse(result, "main");
$tpl->FastPrint(result);
?>



El de general.inc.php:


$CT = $COLOR->title;//title colour
<?php
$CL1 = $COLOR->oddlines;//Line 1(& odd table lines) colour
$CL2 = $COLOR->evenlines;//Line 2(& even table lines) colour

function printfullarray( $arr){fprintfullarray( $arr,"ARRAY KEY","VALUE",1);}
//It Prints all and sorted array Keys names and the value of this array Key.


function fprintfullarray( $arr, $KeyColumn_name, $ValueColumn_name, $tborder){
// It Prints all and sorted array Keys names and the value of this array Key,
// and you can specify the display name of the columns, and the table border
if (isset ( $arr ) ) {
global $color;
global $CT;
global $CL1;
global $CL2;
$color=$CT;
?>
<table border=<?echo ($tborder);?> WIDTH="100%" CELLPADDING=6>

<? if ($KeyColumn_name || $ValueColumn_name){?>
<THEAD>
<tr BGCOLOR=<?echo $color ?>>
<th vAlign=center align=left><b><? ttchs($KeyColumn_name);?></b></th>
<th vAlign=center align=left><b><? ttchs($ValueColumn_name);?></b></th>
</tr>
</THEAD>
<? } ?>
<TBODY>
<?
foreach ($arr as $val){
$name = key($arr);
($color== $CL1)? $color= $CL2 : $color= $CL1;?>
<tr BGCOLOR=<? echo $color ?>>
<td WIDTH="30%" vAlign=TOP align=left><b><? ttchs($name) ." :"; ?></b></td>
<td vAlign=TOP align=left><b><? printany($val) ?></b></td>
</tr>
<input type=hidden name=<? ttchs($name); ?> value="<? ttchs($val) ?>">
<?
next($arr);
}
echo "</TBODY></table>";
}
else {echo "NOT DEFINED <BR>";}
}

function printfullobject($obj){
//It Prints all and sorted object propierties
//(fields) names and the value of this propierties.
fprintfullobject($obj,"FIELD NAME", "VALUE ", 1);
}

function fprintfullobject($obj, $KeyColumn_name, $ValueColumn_name, $tborder){
//It Prints all and sorted object propierties
//(fields) names and the value of this propierties.
// and you can specify the display name of the columns, and the table border
if (isset ( $obj ) ) {
$arr=get_object_vars($obj);
fprintfullarray( $arr, $KeyColumn_name, $ValueColumn_name, $tborder);
}
else {echo "NOT DEFINED <BR>";}
}


function printany($val){
// Combo Function becouse print all and sorted info of the passed variable
is_array($val) ? $KeyColumn_name="ARRAY KEY": $KeyColumn_name="FIELD NAME";
fprintany($val, $KeyColumn_name, "VALUE", 1);
}


function fprintany($val, $KeyColumn_name, $ValueColumn_name, $tborder){
// Combo Function becouse print all and sorted info of the passed variable
// and you can specify the display name of the columns, and the table border
if (isset ( $val ) ) {
if(is_array($val)== TRUE){
fprintfullarray($val, $KeyColumn_name, $ValueColumn_name, $tborder);}
elseif(is_object($val)== TRUE){
fprintfullobject($val, $KeyColumn_name, $ValueColumn_name, $tborder);}
else{echo ttchs($val);}
}
else {echo "NOT DEFINED <BR>";}
}

function ttchs($var) {
// Transform To a Correct Html String & better
echo isset($var) ? addslashes(htmlSpecialChars(stripslashes(trim(esca peshellcmd($var))))) : "";
}


/* Transform to a correct HTML string */
function ttchsNoPrint($var) {
return isset($var) ? addslashes(htmlSpecialChars(stripslashes(trim(esca peshellcmd($var))))) : "";
}


?>


Gracias!!!!!
  #7 (permalink)  
Antiguo 10/02/2011, 13:02
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

Mogurbon gracias!!

Antes funcionaba, era la version php 4 puede ser por eso?

tambien todo el diseño lo hice en linux pero tambien funcionaba en windows..
  #8 (permalink)  
Antiguo 10/02/2011, 13:03
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

yo lo único que veo es un montón de código de antaño, que quizá te funcionaba -aún no lo creo- pero ahora, ya esta demasiado desfasado...

y realmente corregir todo ello poco a poco te va a salir costoso de tiempo y paciencia, deberías Googlear error por error para conocer las soluciones posibles... (:
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #9 (permalink)  
Antiguo 10/02/2011, 13:08
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

gracias paquetetrueke, que de verdad que si que funcionaba!!!!jajaja

mogurbon, con las comillas ya me han desaparecido los "notice"
ahora sólo me sale lo de la base de datos:

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 51

el código es este y no se muy bien que quiere decir con lo de que espera el parametro 2.. :



// mysql_func.php

// Always you Include this Library you must include so the Library
// connection_data.php (or any other) to give valids
// Data Base Name, Host Name, User Name and Password


// Into the file connection_data.php
// is definited the setup global variable $MySQL
// if you don't include this Library you need specify
// the Data Base Name, Host Name, User Name and Password to use with.

/* Functions for a simple Database-Interface */
/* ----------------------------------------- */

myconnect();

function myconnect() {
global $MySQL;

if (! $linkid=mysql_connect("$MySQL->Host","$MySQL->User","$MySQL->Passw")) {
echo "The connection to ",$MySQL->Host," could not be established <br>";
exit;

mysql_query( "SET NAMES utf8", $linkid );

mysql_query( "SET CHARACTER SET utf8", $linkid );


}
return $linkid;
}

function createdb($db, $lkid) {
if (! $res=mysql_create_db($db, $lkid)) {
echo mysql_error($lkid);
exit;
}
return $res;
}

function send_sql($db, $sql) {
if (! $res=mysql_query($db, $sql)) {
echo mysql_error();
exit;
}
return $res;
}


function tab_out($result) {
$anz=mysql_num_fields($result);
echo "<table width=68% border=0 cellpadding='2' cellspacing='2'>";
echo "<tr bgcolor=#D0D0D0>";
for ($i=0;$i<$anz;$i++){
echo "<th>";
echo mysql_field_name($result,$i);
echo "</th>";
}
echo "</tr>";
echo "<tr>";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
foreach ($row as $elem) {
echo "<td bgcolor='#E8E8E8'><font size='-1'>$elem</font></td>";
}
echo "</tr>";
}
echo "</table>";
} // tab


// with the option MYSQL_ASSOC takes only the key names of every field

function fetch_array($qid) {
return mysql_fetch_array($qid, MYSQL_ASSOC);
}
function fetch_object($qid) {
return mysql_fetch_object($qid, MYSQL_ASSOC);
}
function fetch_row($qid) {
return mysql_fetch_row($qid);
}
function num_rows($qid){
return mysql_num_rows($qid);
}


function FFAK($queryID) {
// Fetch Full in Array with its Key names
// Return a Full array of Fetched arrays

while ($aux = fetch_array($queryID)) {$array[]=$aux;}
return $array;
}

function FFO($queryID) {
// Fetch Full in Object with its Key names
// Return a Full array of Fetched objects

while ($aux = fetch_object($queryID)){$array[]=$aux;}
return $array;
}


/* Added by Natalia Costas */

function get_last_id(){
return mysql_insert_id();
}

function num_affected_rows(){
return mysql_affected_rows();
}

?>
  #10 (permalink)  
Antiguo 10/02/2011, 13:12
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

pues por eso lee el manual...
http://php.net/mysql_query

así te darás cuenta de que es lo que haces mal, y el orden y tipo de los argumentos de dicha función...
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #11 (permalink)  
Antiguo 10/02/2011, 13:25
 
Fecha de Ingreso: enero-2011
Ubicación: DF
Mensajes: 898
Antigüedad: 13 años, 2 meses
Puntos: 155
Respuesta: Errores varios en script

esta linea

Código PHP:
mysql_query($db$sql
seria alreves

Código PHP:
mysql_query($sql$db
  #12 (permalink)  
Antiguo 10/02/2011, 13:59
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

sigue saliendo el mismo error..

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 51
  #13 (permalink)  
Antiguo 10/02/2011, 14:07
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

Cita:
Iniciado por edugilc Ver Mensaje
sigue saliendo el mismo error..

Warning: mysql_query() expects parameter 2 to be resource, string given in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 51
a ver, se nota que no te gusta leer las referencias del lenguaje... y peor aún, gozas de copiar y pegar código sin entender lo que pasa...

el segundo argumento que debes pasar a mysql_query() es la conexión a la BD, no el nombre de la BD... así que la pregunta sería, ¿como estas llamando a la función que llama internamente a mysql_query(), y que argumentos le estas pasando?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #14 (permalink)  
Antiguo 10/02/2011, 14:22
 
Fecha de Ingreso: enero-2011
Ubicación: DF
Mensajes: 898
Antigüedad: 13 años, 2 meses
Puntos: 155
Respuesta: Errores varios en script

a ver pruebale asi


Código PHP:
mysql_query($sql
  #15 (permalink)  
Antiguo 10/02/2011, 16:16
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

Muchas gracias por tu paciencia..

haciendo lo que me dices tu poniendolo asi:

if (! $res=mysql_query($db, $sql)) me sale el siguiente error:

Fatal error: Call to undefined function mysql_connect() in C:\Users\eduardo\Desktop\EDU\INFORMATICA\PROYECTO\ xampp-win32-1.7.4-VC6\xampp\htdocs\pagina_16_12\mysql_func.php on line 29

Gracias!!
  #16 (permalink)  
Antiguo 10/02/2011, 16:40
 
Fecha de Ingreso: enero-2011
Ubicación: DF
Mensajes: 898
Antigüedad: 13 años, 2 meses
Puntos: 155
Respuesta: Errores varios en script

el mysql_query ponlo asi porfa


Código PHP:
mysql_query($sql
esto por que si no hay un identificador definido como parametro dentro de la funcion , toma el que se encuentre en el momento en el ambiente del script

por otro lado podrias pegar nuevamente todo el script para poderlo ver como va porfa?

por que ese nuevo error esta medio raro

Fatal error: Call to undefined function mysql_connect()

quiere decir que no tienes habilitado el soporte para esa funcion
  #17 (permalink)  
Antiguo 10/02/2011, 16:52
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

Muchas gracias de nuevo!!

Ya lo he probado poniendolo así:
mysql_query($sql)
y sale el mismo error.

el script es esta:




// mysql_func.php

// Always you Include this Library you must include so the Library
// connection_data.php (or any other) to give valids
// Data Base Name, Host Name, User Name and Password


// Into the file connection_data.php
// is definited the setup global variable $MySQL
// if you don't include this Library you need specify
// the Data Base Name, Host Name, User Name and Password to use with.

/* Functions for a simple Database-Interface */
/* ----------------------------------------- */

myconnect();

function myconnect() {
global $MySQL;

if (! $linkid=mysql_connect("$MySQL->Host","$MySQL->User","$MySQL->Passw")) {
echo "The connection to ",$MySQL->Host," could not be established <br>";
exit;

mysql_query( "SET NAMES utf8", $linkid );

mysql_query( "SET CHARACTER SET utf8", $linkid );


}
return $linkid;
}

function createdb($db, $lkid) {
if (! $res=mysql_create_db($db, $lkid)) {
echo mysql_error($lkid);
exit;
}
return $res;
}

function send_sql($db, $sql) {
// if (! $res=mysql_query($sql, $db))
{
if (! $res=mysql_query($sql))
echo mysql_error();
exit;
}
return $res;
}

function tab_out($result) {
$anz=mysql_num_fields($result);
echo "<table width=68% border=0 cellpadding='2' cellspacing='2'>";
echo "<tr bgcolor=#D0D0D0>";
for ($i=0;$i<$anz;$i++){
echo "<th>";
echo mysql_field_name($result,$i);
echo "</th>";
}
echo "</tr>";
echo "<tr>";
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
foreach ($row as $elem) {
echo "<td bgcolor='#E8E8E8'><font size='-1'>$elem</font></td>";
}
echo "</tr>";
}
echo "</table>";
} // tab

// with the option MYSQL_ASSOC takes only the key names of every field

function fetch_array($qid) {
return mysql_fetch_array($qid, MYSQL_ASSOC);
}
function fetch_object($qid) {
return mysql_fetch_object($qid, MYSQL_ASSOC);
}
function fetch_row($qid) {
return mysql_fetch_row($qid);
}
function num_rows($qid){
return mysql_num_rows($qid);
}

function FFAK($queryID) {
// Fetch Full in Array with its Key names
// Return a Full array of Fetched arrays

while ($aux = fetch_array($queryID)) {$array[]=$aux;}
return $array;
}

function FFO($queryID) {
// Fetch Full in Object with its Key names
// Return a Full array of Fetched objects

while ($aux = fetch_object($queryID)){$array[]=$aux;}
return $array;
}

function get_last_id(){
return mysql_insert_id();
}

function num_affected_rows(){
return mysql_affected_rows();
}

?>
  #18 (permalink)  
Antiguo 10/02/2011, 16:57
 
Fecha de Ingreso: diciembre-2010
Mensajes: 788
Antigüedad: 13 años, 4 meses
Puntos: 51
Respuesta: Errores varios en script

Y si cambias mysql_connect por mysqli_connect? No creo que tenga que ver, pero por las dudas XD
  #19 (permalink)  
Antiguo 10/02/2011, 17:17
 
Fecha de Ingreso: enero-2011
Ubicación: DF
Mensajes: 898
Antigüedad: 13 años, 2 meses
Puntos: 155
Respuesta: Errores varios en script

si el horror (error XD ) sigue siendo este :

Fatal error: Call to undefined function mysql_connect()


es que no esta habilitada esa funcion en tu php, y ya va mas por onda de configuracion , debes buscar en tu php.ini esta linea

;extension=php_mysql.dll <--- y quitarle el punto y coma

extension=php_mysql.dll<--- asi


quiero creer que xamp tiene todos los dlls descargados
  #20 (permalink)  
Antiguo 10/02/2011, 17:52
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Errores varios en script

es extraño todo esto, ya que si la función mysql_query() te arrojaba error, significa que dicha extensión de MySQL esta instalada!!

entonces lo raro es que ahora mysql_connect() no exista, siendo parte de la misma extensión, ¿de verdad no has modificado nada de la configuración de php?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #21 (permalink)  
Antiguo 10/02/2011, 18:41
Avatar de jonasanx  
Fecha de Ingreso: enero-2011
Ubicación: La Via Lactea, Mexico, Mexico, Mexico
Mensajes: 134
Antigüedad: 13 años, 3 meses
Puntos: 4
Respuesta: Errores varios en script

Una solución mas sencilla, seria utilizar la versión de PHP que tenia antes (broma).

function_exists() verifica si la función existe.
http://php.net/manual/en/function.function-exists.php

Nota: ¿alguien sabe hasta cuando puedo colocar urls?
  #22 (permalink)  
Antiguo 10/02/2011, 19:37
(Desactivado)
 
Fecha de Ingreso: enero-2011
Mensajes: 293
Antigüedad: 13 años, 3 meses
Puntos: 4
Respuesta: Errores varios en script

wao esto parece un viaje en el tiempo aiaia que buena un dato curioso fue el requier_once , tambien esta include_once nose como funcionan solo conozco el include jaja bueno chao.
  #23 (permalink)  
Antiguo 10/02/2011, 21:50
Avatar de jonasanx  
Fecha de Ingreso: enero-2011
Ubicación: La Via Lactea, Mexico, Mexico, Mexico
Mensajes: 134
Antigüedad: 13 años, 3 meses
Puntos: 4
Respuesta: Errores varios en script

Cita:
Iniciado por yooom Ver Mensaje
wao esto parece un viaje en el tiempo aiaia que buena un dato curioso fue el requier_once , tambien esta include_once nose como funcionan solo conozco el include jaja bueno chao.
heee.... el require, include, require_ once e include_ once siguen siendo totalmente validos, solo han cambiado algunas cosas internas, ya que cada uno tiene una función especifica... (no son lo mismo).
  #24 (permalink)  
Antiguo 11/02/2011, 10:36
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: Errores varios en script

Si que está activada las líneas

extension=php_mysql.dll

extension=php_mysqli.dll
.....

Miren, voy a intentar una cosa, poner el PHP4 que era el que usaba para el proyecto éste y les cuento , porque todos estos fallos me suenan a algo de la versión, porque no es un error o dos en alguna de las opciones, en todo el menú me van saliendo errores de cosas que no tendrían porqué salir.
Voy a probar unas cosas y cuando tenga noticias les aviso.

Muchas gracias a todos por su tiempo e interés!!


Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:55.