Visualizzazione risultati 1 fino 11 di 11

Discussione: chiarimenti su function

  1. #1
    Guest

    Predefinito chiarimenti su function

    Scusate l'ennesimo distrubo volevo un chiarimento sull'utilizzo del tag function.

    Ho creato una piccola pgina di esempio ma ricevo errori strani volevo sapere se qulacuno può aiutarmi a capire.

    Codice PHP:
    <?
    $ROOT_DIR
    = realpath(dirname(__FILE__));
    $ROOT_DIR = str_replace('\\', '/', $ROOT_DIR);

    include (
    "$ROOT_DIR/script/config.php");

    include(
    "$ROOT_DIR/script/mysql.class.php");

    $db = new sql_db($db_host, $db_username, $db_password, $databse_name, false);
    if(!
    $db->db_connect_id) {
    include(
    "user/header.php");

    echo
    "<br><font color=\"red\"><h5><br><center>Error:</b><br><hr><br>
    <b>Connection to database has faild!<br>
    check mysql server/database name/username/password </center>
    <br><br><br><br><br><br><br><br><br>"
    ;
    echo
    mysql_error();
    include(
    "user/footer.php");
    die();
    }

    function
    edit_(apple) {
    global
    $db,$prefix1;

    $apple_sql = $db->sql_query("SELECT * FROM $prefix1_apple");
    $apple= $db->sql_fetchrow($apple_sql);

    $titolo = stripslashes($apple['titolo']);
    $categoria = stripslashes($apple['categoria']);
    $testo = stripslashes($apple['testo']);
    }

    ?>
    Grazie

  2. #2
    Guest

    Predefinito

    che errori ricevi?

  3. #3
    Guest

    Predefinito

    syntax error, unexpected ')', expecting '&' or T_VARIABLE in script/gestione.php on line 22

    Nel file view in cui è incluso
    Ultima modifica di wtech : 03-09-2009 alle ore 19.02.24

  4. #4
    Guest

    Predefinito

    Mancava il simbolo del dollaro ($) nella funzione per definire la variabile:
    Codice PHP:
    <?php

    $ROOT_DIR
    = realpath(dirname(__FILE__));
    $ROOT_DIR = str_replace('\\', '/', $ROOT_DIR);

    include(
    $ROOT_DIR . '/script/config.php');

    include(
    $ROOT_DIR . '/script/mysql.class.php');

    $db = new sql_db($db_host, $db_username, $db_password, $databse_name, false);

    if(!
    $db->db_connect_id)
    {
    include(
    "user/header.php");

    echo
    '<br /><font color="red"><h5><br /><center>Error:</b><br /><hr><br />';
    echo
    '<b>Connection to database has faild!<br />';
    echo
    'check mysql server/database name/username/password </center>';
    echo
    '<br /><br /><br /><br /><br /><br /><br /><br /><br />';
    echo
    mysql_error();

    include(
    "user/footer.php");
    die();
    }

    function
    edit_($apple)
    {
    global
    $db, $prefix1;

    $apple_sql = $db->sql_query('SELECT * FROM ' . $prefix1_apple);
    $apple = $db->sql_fetchrow($apple_sql);

    $titolo = stripslashes($apple['titolo']);
    $categoria = stripslashes($apple['categoria']);
    $testo = stripslashes($apple['testo']);
    }

    ?>

  5. #5
    Guest

    Predefinito

    Ora mi esce questo errore:

    Warning: include(/script/script/config.php) [function.include]: failed to open stream: No such file or directory in /home/wtechnet/public_html/script/gestione.php on line 6

    Warning: include() [function.include]: Failed opening '/script/script/config.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/wtechnet/public_html/script/gestione.php on line 6

    Warning: include(/script/script/mysql.class.php) [function.include]: failed to open stream: No such file or directory in /script/gestione.php on line 8

    Warning: include() [function.include]: Failed opening '/script/script/mysql.class.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/wtechnet/public_html/script/gestione.php on line 8

    Cosa sto sbagliando?

    Grazie per il precedente aiuto.

  6. #6
    Guest

    Predefinito

    Dipende da $ROOT_DIR, devi controllare i percorsi.

  7. #7
    Guest

    Predefinito

    Ecco ho una domanda su questo attributo, cosa vuole dire????

    Si riferisci alla home vero?

  8. #8
    Guest

    Predefinito

    Usa ./ oppure ../ in base a dove si trova lo script e le cartelle da dove includi i file

  9. #9
    Guest

    Predefinito

    uffa ho modificato ora continua a darmi errori relativi a questo file ma è collegato:

    Fatal error: Cannot redeclare class sql_db in /script/mysql.class.php on line 8

    Non capisco proprio

  10. #10
    Guest

    Predefinito

    Sicuramente includi già in un altro file, incluso a sua volta in questo script, il file /script/mysql.class.php

  11. #11
    Guest

    Predefinito

    Allora non so più dove mettere le mani ho scritto quella pagina sulla falsa riga di questo script già fatto.


    Codice PHP:
    <?
    if (eregi("functions.php", $_SERVER['SCRIPT_NAME'])) {
    Header("Location: index.php"); die();
    }

    error_reporting(E_ALL ^ E_NOTICE);

    set_magic_quotes_runtime(0);

    if (!
    ini_get("register_globals")) {
    import_request_variables('GPC');
    }

    $phpver = phpversion();
    if (
    $phpver < '4.1.0') {
    $_GET = $HTTP_GET_VARS;
    $_POST = $HTTP_POST_VARS;
    $_SERVER = $HTTP_SERVER_VARS;
    }
    $phpver = explode(".", $phpver);
    $phpver = "$phpver[0]$phpver[1]";
    if (
    $phpver >= 41) {
    $PHP_SELF = $_SERVER['PHP_SELF'];
    }

    if(isset(
    $master)){
    $master = base64_decode($master);
    $master = addslashes($master);
    $master = base64_encode($master);
    }
    if(isset(
    $admin)){
    $admin = base64_decode($admin);
    $admin = addslashes($admin);
    $admin = base64_encode($admin);
    }
    if(isset(
    $user)){
    $user = base64_decode($user);
    $user = addslashes($user);
    $user = base64_encode($user);
    }

    foreach (
    $_GET as $sec_key => $secvalue) {
    if ((
    eregi("<[^>]*script*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*object*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*iframe*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*applet*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*meta*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*style*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*form*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*img*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||
    (
    eregi("\([^>]*\"?[^)]*\)", $secvalue)) ||
    (
    eregi("\"", $secvalue))) {
    die (
    "not allowed");
    }
    }
    foreach (
    $_POST as $secvalue) {
    if ((
    eregi("<[^>]*onmouseover*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]script*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]meta*\"?[^>]*>", $secvalue)) ||
    (
    eregi("<[^>]style*\"?[^>]*>", $secvalue))) {
    die (
    "not allowed");
    }
    }

    $ROOT_DIR = realpath(dirname(__FILE__));
    $ROOT_DIR = str_replace('\\', '/', $ROOT_DIR);

    include (
    "$ROOT_DIR/script/config.php");

    include(
    "$ROOT_DIR/script/mysql.class.php");

    $db = new sql_db($db_host, $db_username, $db_password, $databse_name, false);
    if(!
    $db->db_connect_id) {
    include(
    "user/header.php");

    echo
    "<br><font color=\"red\"><h5><br><center>Error:</b><br><hr><br>
    <b>Connection to database has faild!<br>
    check mysql server/database name/username/password </center>
    <br><br><br><br><br><br><br><br><br>"
    ;
    echo
    mysql_error();
    include(
    "user/footer.php");
    die();
    }
    $options_sql = $db->sql_query("SELECT * FROM ".$prefix."_options");
    $options = $db->sql_fetchrow($options_sql);

    $site_name = stripslashes($options['site_name']);
    $site_email= stripslashes($options['site_email']);
    $site_url = stripslashes($options['site_url']);
    $site_info = stripslashes($options['site_info']);
    $language = stripslashes($options['language']);
    $tmp_header = stripslashes($options['tmp_header']);
    $tmp_footer = stripslashes($options['tmp_footer']);

    include (
    "$ROOT_DIR/lang/$language.php");

    function
    is_logged_in($user) {
    global
    $db,$prefix;

    $read_cookie = explode("|", base64_decode($user));
    $userid = addslashes($read_cookie[0]);
    $passwd = $read_cookie[2];
    $userid = intval($userid);

    if (
    $userid != "" AND $passwd != "") {
    $result = $db->sql_query("SELECT password FROM ".$prefix."_users WHERE userid='$userid'");
    $row = $db->sql_fetchrow($result);
    $pass = $row['password'];
    if(
    $pass == $passwd && $pass != "") {
    return
    1;
    }
    }
    return
    0;
    }

    function
    is_logged_in_admin($admin) {
    global
    $db,$prefix;

    $read_cookie = explode("|", base64_decode($admin));
    $adminid = addslashes($read_cookie[0]);
    $passwd = $read_cookie[2];
    $adminid = intval($adminid);

    if (
    $adminid != "" AND $passwd != "") {
    $result = $db->sql_query("SELECT password FROM ".$prefix."_admin WHERE adminid='$adminid'");
    $row = $db->sql_fetchrow($result);
    $pass = $row['password'];
    if(
    $pass == $passwd && $pass != "") {
    return
    1;
    }
    }
    return
    0;
    }

    function
    is_logged_in_master($master) {
    global
    $db,$prefix;

    $read_cookie = explode("|", base64_decode($master));
    $masterid = addslashes($read_cookie[0]);
    $passwd = $read_cookie[2];
    $masterid = intval($masterid);

    if (
    $masterid != "" AND $passwd != "") {
    $result = $db->sql_query("SELECT password FROM ".$prefix."_master WHERE masterid='$masterid'");
    $row = $db->sql_fetchrow($result);
    $pass = $row['password'];
    if(
    $pass == $passwd && $pass != "") {
    return
    1;
    }
    }
    return
    0;
    }


    function
    msg_redirect($msg,$url,$seconds){
    global
    $site_name, $site_url;

    echo
    "<html dir=\""._LTR_RTL."\">\n"
    ."<head>\n"
    ."<title>$site_name</title>\n"
    ."<meta http-equiv=\"Refresh\" content=\"$seconds; URL=$url\">\n"
    ."<meta http-equiv=\"Content-Type\" content=\"text/html; charset="._CHARSET."\">\n"
    ."<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">\n"
    ."</head>\n\n"
    ."<body>\n"
    ."<br />\n"
    ."<br />\n"
    ."<br />\n"
    ."<br />\n\n\n"
    ."<div align=\"center\">\n"
    ."<table cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"70%\" bgcolor=\"#E1E1E1\">"
    ."<tr>"
    ."<td bordercolor=\"#808080\">"._REDIRECTING."</td>"
    ."</tr> "
    ."<tr> "
    ."<td align=\"center\" bgcolor=\"#FFFFFF\">"
    ."<blockquote> "
    ."<p>&nbsp;</p>"
    ."<p><h3>$msg</h3></p>"
    ."<p><a href=\"$url\"> "
    .""._CLICK_HERE_BROWSER_REDIRECT."</a></p><br />"
    ."</blockquote>"
    ."</div>\n"
    ."</td>\n"
    ."</tr>\n"
    ."</table>\n\n\n"
    ."</body>\n"
    ."</html>";
    }


    ?>

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •