Ver Mensaje Individual
  #7 (permalink)  
Antiguo 25/09/2007, 10:52
Avatar de sumolari
sumolari
 
Fecha de Ingreso: mayo-2006
Ubicación: localhost
Mensajes: 1.367
Antigüedad: 18 años
Puntos: 18
Re: no logro crear un funcion que conecte a mi bd

Gracias, con eso ya no da error, pero me queda una última duda, ¿y si necesito más de una función?

He comprobado que cada una de las funcioens funciona bien por separado, pero juntas no, aquí está el código:
core.php
Código PHP:
<?php
function sitename()
{
    require_once(
'Connections/SCMS.php');
    
mysql_select_db($database_SCMS$SCMS);
    
$query_site_config "SELECT * FROM site";
    
$site_config mysql_query($query_site_config$SCMS) or die(mysql_error());
    
$row_site_config mysql_fetch_assoc($site_config);
    
$totalRows_site_config mysql_num_rows($site_config);
    echo 
$row_site_config['name'];
    
mysql_free_result($site_config);
}
function 
echo_site($value)
{
    require_once(
'Connections/SCMS.php');
    
mysql_select_db($database_SCMS$SCMS);
    
$query_site_config "SELECT * FROM site";
    
$site_config mysql_query($query_site_config$SCMS) or die(mysql_error());
    
$row_site_config mysql_fetch_assoc($site_config);
    
$totalRows_site_config mysql_num_rows($site_config);
    
$site_value $row_site_config[$value];
    echo 
$site_value;
    
mysql_free_result($site_config);
    
}
?>
test.php
Código PHP:
<?php
include('core.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php sitename(); ?></title>
</head>
<body>
<p><?php echo_site('desc'); ?></p>
</body>
</html>

Última edición por sumolari; 25/09/2007 a las 11:02