הרשם שאלות ותשובות רשימת חברים לוח שנה חיפוש הודעות מהיום סמן פורומים כנקראו

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 01-08-07, 12:28   # 1
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

שאלה ב php

שלום לכולם,
יש לי את הקוד הבא:

PHP קוד:
 <?php

            $errors 
= array();

            if(isset(
$_REQUEST["seen_already"])){

                
validate_data();
                if(
count($errors) != 0){
                    
display_errors();
                    
display_welcome();
                } 
                else {
                    
process_data();
                }
            } 
            else {
                
display_welcome();
            }

            function 
validate_data()
            {
                global 
$errors;
                if(
$_REQUEST["Name"] == "") {
                    
$errors[] = "<FONT COLOR='RED'>Please enter your name</FONT>";
                }

                if(
strcmp($_REQUEST["Number"], strval(intval($_REQUEST["Number"])))) {
                    
$errors[] = "<FONT COLOR='RED'>Please enter an integer</FONT>";
                }
            }

            function 
display_errors()
            {
                global 
$errors;

                foreach (
$errors as $err){
                    echo 
$err"<BR>";
                }

                foreach (
$errors as $err){
                    echo 
$err"<BR>";
            }

            function 
process_data()
            {
                echo 
"Your name is ";
               
                
$ok_text htmlentities ($_REQUEST["Name"]);
                echo 
$ok_text;

                echo 
"Your integer is ";
                echo 
$_REQUEST["Number"];
            }

            function 
display_welcome()
            {
                echo 
"<FORM METHOD='POST' ACTION='index.php'>";
                echo 
"What's your name?";
                echo 
"<BR>";
                echo 
"<INPUT NAME='Name' TYPE='TEXT'>";
                echo 
"<BR>";
                echo 
"<BR>";
                echo 
"<INPUT TYPE=SUBMIT VALUE=Submit>";
                echo 
"<INPUT TYPE=HIDDEN NAME='seen_already' VALUE='hidden_data'>";
                echo 
"</FORM>";
          
             echo 
"<FORM METHOD='POST' ACTION='index.php'>";
                echo 
"Please enter an integer.";
                echo 
"<BR>";
                echo 
"<INPUT NAME='Number' TYPE='TEXT'>";
                echo 
"<BR>";
                echo 
"<BR>";
                echo 
"<INPUT TYPE=SUBMIT VALUE=Submit>";
                echo 
"<INPUT TYPE=HIDDEN NAME='seen_already' VALUE='hidden_data'>";
                echo 
"</FORM>";


      }
        
?>

שאני מריץ את זה זה כותב לי את השגיאה הבאה:
PHP קוד:
Parse errorparse error in c:program fileseasyphp1-8wwwregistarindex.php on line 79 
איך מתקנים את זה?

תודה מראש.
  Reply With Quote
ישן 01-08-07, 14:58   # 2
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

הבעייה היא כי שכחת }
באמת, אני לא רוצה להעליב, אבל כדאי לך לעדכן את הידע שלך ב-HTML.
בכ"מ, תיקנתי לך את הכל.
PHP קוד:
<?php
$to_print 
null;
$errors = array();
if (isset(
$_REQUEST["seen_already"])) {
    
validate_data();
    if (
count($errors) != 0) {
        
display_errors();
        
display_welcome();
    } else {
        
process_data();
    }
} else {
    
display_welcome();
}

function 
validate_data()
{
    global 
$errors;
    if (
$_REQUEST["Name"] == "") {
        
$errors[] = "<span style='color:red;'>Please enter your name</span>";
    }

    if (
strcmp($_REQUEST["Number"], strval(intval($_REQUEST["Number"])))) {
        
$errors[] = "<span style='color:red;'>Please enter an integer</span>";
    }
}

function 
display_errors()
{
    global 
$errors;

    foreach (
$errors as $err) {
        
$to_print.= $err"<br />";
    }

    foreach (
$errors as $err) {
        
$to_print.= $err"<br />";
    }
}
    function 
process_data()
    {
        global 
$to_print;
        
$to_print.= "Your name is ";

        
$ok_text htmlentities ($_REQUEST["Name"]);
        
$to_print.= $ok_text;

        
$to_print.= "Your integer is ";
        
$to_print.= $_REQUEST["Number"];
    }

    function 
display_welcome()
    {
        global 
$to_print;
        
$to_print.= <<<EOF
        <form method='POST' action='index.php'>
        What's your name?
        <br />
        <input type="text" name='Name'>
        <br />
        <br />
        <input type="submit" VALUE="Submit">
        <input type="hidden" name='seen_already' value='hidden_data'>
        </form>

        <form method='POST' action='index.php'>
        Please enter an integer.
        <br />
        <input type="text" name='Number'>
        <br />
        <br />
        <input type="hidden" name='seen_already' value='hidden_data'>
        <input type="submit" VALUE="Submit">
        </FORM>
EOF;
    }
echo 
$to_print;
    
?>
  Reply With Quote
ישן 01-08-07, 15:15   # 3
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

תודה אחי,ובכל מקרה אין מה להעליב,זה פשוט עניין של תקניות מה שכתבתי היה נכון.(ב html).

אממ זה הסתדר הכל עובד אבל עדיין מציג לי שגיאה למעלה:
Notice: Undefined variable: to_print in c:\program files\easyphp1-8\www\registar\index.php on line 33

Last edited by Ron | CSite.co.il; 01-08-07 at 15:24..
  Reply With Quote
ישן 01-08-07, 15:47   # 4
Daniel
אחראי פורום
 
מיני פרופיל
תאריך הצטרפות: Mar 2007
הודעות: 2,875

Daniel לא מחובר  

תוקן.
ותקינות וכל הדברים האלה זה דבר מאוד חשוב.
PHP קוד:
<?php
$to_print 
null;
$errors = array();
if (isset(
$_REQUEST["seen_already"])) {
    
validate_data();
    if (
count($errors) != 0) {
        
display_errors();
        
display_welcome();
    } else {
        
process_data();
    }
} else {
    
display_welcome();
}

function 
validate_data()
{
    global 
$errors$to_print;
    if (
$_REQUEST["Name"] == "") {
        
$errors[] = "<span style='color:red;'>Please enter your name</span>";
    }

    if (
strcmp($_REQUEST["Number"], strval(intval($_REQUEST["Number"])))) {
        
$errors[] = "<span style='color:red;'>Please enter an integer</span>";
    }
}

function 
display_errors()
{
    global 
$errors$to_print;

    foreach (
$errors as $err) {
        
$to_print.= $err"<br />";
    }

    foreach (
$errors as $err) {
        
$to_print.= $err"<br />";
    }
}
    function 
process_data()
    {
        global 
$to_print;
        
$to_print.= "Your name is ";

        
$ok_text htmlentities ($_REQUEST["Name"]);
        
$to_print.= $ok_text;

        
$to_print.= "Your integer is ";
        
$to_print.= $_REQUEST["Number"];
    }

    function 
display_welcome()
    {
        global 
$to_print;
        
$to_print.= <<<EOF
        <form method='POST' action='index.php'>
        What's your name?
        <br />
        <input type="text" name='Name'>
        <br />
        <br />
        <input type="submit" VALUE="Submit">
        <input type="hidden" name='seen_already' value='hidden_data'>
        </form>

        <form method='POST' action='index.php'>
        Please enter an integer.
        <br />
        <input type="text" name='Number'>
        <br />
        <br />
        <input type="hidden" name='seen_already' value='hidden_data'>
        <input type="submit" VALUE="Submit">
        </FORM>
EOF;
    }
echo 
$to_print;
    
?>
  Reply With Quote
ישן 01-08-07, 15:57   # 5
hod206
אחראי פורום Off-Topic
 
מיני פרופיל
תאריך הצטרפות: Dec 2005
גיל: 34
הודעות: 2,070
שלח הודעה באמצעות ICO אל hod206 שלח הודעה באמצעות MSN אל hod206

hod206 לא מחובר  

ציטוט:
נכתב במקור על ידי MasterT צפה בהודעה
תוקן.
ותקינות וכל הדברים האלה זה דבר מאוד חשוב.
תקינות קוד זה לא כזה דבר חשוב, אתר יכול להראות מעולה בכל הדפדפנים גם בלי שהוא תקין (ע"ע google).
__________________
אנטי וירוס חינם
  Reply With Quote
ישן 01-08-07, 15:58   # 6
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

תודה רבה .אפשר לנעול.
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 

כלים לאשכול
תצורת הצגה

חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 21:11.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ