function fopen error

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Tedd Master

Tedd Master

14/01/2009 23:35:00
Quote Anchor link
Het gaat om een profile script

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?
GLOBAL $message;

$err=$_GET["err"];
$site=$_GET["site"];

if(empty($site))
    echo "<Center>No url specified!</center>";
else{
?>

<script>

function is_email(val)
{
    var at = val.indexOf("@")
    if(at == -1){
     return false
     }
    else
    {
        var at_parts = val.split("@")
        if(at_parts[0].length < 1){
            return false
            }
        else{
            point = at_parts[1].indexOf(".")
            if(point == -1) return false
            else{
              point_parts = at_parts[1].split(".")
              if((point_parts[1].length < 2) || (point_parts[1].length > 3)) return false
              else  return true
            }
        }
    }
}


function accept(str){
acc="~_`.!,:_#@$^&*+|{}/?=-0123456789abcdefghijklmnoprstuvxzqywABCDEFGHIJKLMNOPRSTUVXZYQW "

var ch
var found = true

if (str.length == 0)
{
   return true
}
for (i = 0; i < str.length ;i++){
        ch = str.charAt(i)
        if(acc.indexOf(ch)==-1){
            found=false
            }
}
return found
        
}


function validate()
{
    f = document.frm
    
    isOK = true
    usr_account = f.id.value
    usr_pass = f.password.value
    usr_pass_conf = f.password_.value
    usr_em = f.email.value
    usr_web=f.webpage.value
    
    
    
    if (!accept(usr_account))
    {
        alert("Invalid Id")
        isOK = false
    }

    
    if (!accept(usr_web))
    {
        alert("Invalid Web page")
        isOK = false
    }
        
    if (!accept(usr_pass))
    {
        alert("Wrong password")
        isOK = false
    }
    
    if (!accept(usr_em))
    {
        alert("Invalid Email")
        isOK = false
    }
        
    
    if(usr_account.length < 4)
    {
        alert("Id minimum 4 chars")
        isOK = false
    }
    if(usr_pass.length < 1)
    {
        alert("Type a password")
        isOK = false
    }
    
    if(!is_email(usr_em))
    {
        alert("Email invalid")
        isOK = false
    }
    
    if(usr_pass_conf!=usr_pass){
        alert("Password don't match")
        isOK = false
    }
    
    //validare pentru campurile custom-sa contina caractere acceptate
    for (j = 5; j < f.length-1 ;j++){
        field=f[j].value
        if(field!='T' && field!='F')                
            if(!accept(field))
                {
                    alert("Field "+f[j].name+" ("+field+") invalid")
                    isOK = false
                }        
    }
    
    
    return isOK
}    
</script>
<?

if( ($handle=fopen("server_fields.cfg","r"))==NULL){ <<<<<<<
    echo "Erorr opening server_fields.cfg";
    die();
}
else
    {
    $name=array();
    $fields=array();
    $type=array();
    $length=array();
        
    $i=0;
    while (!feof($handle)) {
        list($name[$i],$fields[$i],$type[$i],$length[$i])=explode("-",fgets($handle));                
        $i++;
        }

    
    $i--;
    fclose($handle);
    }


?>


<table  border="0" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td height="111" valign="top" align="left">
        <br>
        <b><? echo $message['Accepted chars']; ?><B>
        <font size='+1'>_`.!,:_#@$^&*+|{}/?=-</font> <? echo $message['letters and numbers'];?>
        <br>
        <br>
                <b><font color='red'><? echo $message['Required'];?></font><b>
            
                <form name="frm" action="modules/insert_user.php" method="post">
                <? if($err==1) echo "<br><font color='red'>Id or Email already exists</font><br>"; ?>
                Id:*<br>
                <input type="text" size="20" maxlength="20" name="id" /><br>
                
                <? echo $message['Password'];?>:*<br>
                <input type="password" size="20" maxlength="20" name="password" /><br>
                
                
                <? echo $message['Confirm Password'];?>:*<br>
                <input type="password" size="20" maxlength="20" name="password_" /><br>
                
                
                Email:*<br>
                <input type="text" size="20" maxlength="60" name="email" /><br>
                
                <? if($err==2) echo "<br><font color='red'>Web page already exists</font><br>"; ?>
                
                <? echo $message['Web page'];?>:<br>
                <input type="text" size="30" maxlength="255" name="webpage" /><br>
                <? echo $message['Receive news'];?>
                <input type='radio' name='news' value='yes'/>Yes
                <input type='radio' name='news' value='no' checked />No
                <input type="hidden" value="<? echo $site; ?>" name="site"/>
                <br>
                <?
                for($j=0;$j<$i;$j++){
                
                    #
                    #int(1) means bool.
                    #

                    if(strcmp($type[$j],"int")!=0 && $length[$j]!=1)
                        echo "
                        "
.$name[$j].":<Br>
                        <input type='text' name='"
.$fields[$j]."' /><br>
                        "
;
                    else
                        echo "
                        "
.$name[$j].":
                        <input type='radio' name='"
.$fields[$j]."' value='_BOOL_T_' />Yes
                        <input type='radio' name='"
.$fields[$j]."' value='_BOOL_F_' checked />No
                        <br>
                    "
;    
                        
                }

                ?>

                <br>
                <center><input type='submit' value="Register" onClick="return validate()"/></center>
                <!-- transmit situl mai departe pt prelucrare -->
                
                </form>
            
    </td>
  </tr>
</table>
<?
}
?>



Ik heb geprobeerd op dit zelf op te lossen maar kom er niet uit
deze error bevind zich op lijn 137 welke ik met <<<<<<< heb afgesloten....
het script kan dus server_fields.cfg niet open welke ik afvraag of deze on de fly word aangemaakt wat ik denk van wel maar ergens gaat er iets niet lekker...

wie kan die oplossen of kan mij verder helpen.

als je verder vragen heb over het script hoor ik het graag bedankt php hulp

Tedd
Gewijzigd op 01/01/1970 01:00:00 door Tedd Master
 
PHP hulp

PHP hulp

05/01/2025 12:28:55
 
Ed

Ed

15/01/2009 00:10:00
Quote Anchor link
Mijn glazen bol zegt dat het ligt aan,...... he das balen, de batterijen zijn net leeg.
 
Hipska BE

Hipska BE

15/01/2009 00:29:00
Quote Anchor link
nja leuk script denk ik.

Waar zit je foutcontrole, of waar zet je de foutberichten aan? Indien ze aan zouden staan wat is je Foutbericht? En dan nog, wat is de relevante code dan?
 
Terence Hersbach

Terence Hersbach

15/01/2009 00:31:00
Quote Anchor link
wat meer duidelijkheid over je probleem.. het is nog steeds phphulp en niet phpmoet.
 
Tedd Master

Tedd Master

16/01/2009 15:21:00
Quote Anchor link
Heb nog wel wat oplaatbat AA voor je:p

Het gaat hieromzo beter beschreven
Het probleem is de parse error op lijn 16

function is_email(var)
{
var at = val.indexOf("@")
if(at == -1){
return false
}

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);  
?>


<?
GLOBAL $message;

$err=$_GET["err"];
$site=$_GET["site"];

if(empty($site))
    echo "<Center>No url specified!</center>";
else{
 
function
is_email(var)
{
    var
at = val.indexOf("@")
    if(at == -1){
     return false
     }
    else
    {
        var
at_parts = val.split("@")
        if(at_parts[0].length < 1){
            return false
            }
        else{
            point = at_parts[1].indexOf(".")
            if(point == -1) return false
            else{
              point_parts = at_parts[1].split(".")
              if((point_parts[1].length < 2) || (point_parts[1].length > 3)) return false
              else  return true
            }
        }
    }
}


function
accept(str){
acc="~_`.!,:_#@$^&*+|{}/?=-0123456789abcdefghijklmnoprstuvxzqywABCDEFGHIJKLMNOPRSTUVXZYQW "

var ch
var found = true

if (str.length == 0)
{

   return true
}
for (i = 0; i < str.length ;i++){
        ch = str.charAt(i)
        if(acc.indexOf(ch)==-1){
            found=false
            }
}

return found
        
}


function
validate()
{

    f = document.frm
    
    isOK = true
    usr_account = f.id.value
    usr_pass = f.password.value
    usr_pass_conf = f.password_.value
    usr_em = f.email.value
    usr_web=f.webpage.value
    
    
    
    if (!accept(usr_account))
    {

        alert("Invalid Id")
        isOK = false
    }

    
    if (!accept(usr_web))
    {

        alert("Invalid Web page")
        isOK = false
    }
        
    if (!accept(usr_pass))
    {

        alert("Wrong password")
        isOK = false
    }
    
    if (!accept(usr_em))
    {

        alert("Invalid Email")
        isOK = false
    }
        
    
    if(usr_account.length < 4)
    {

        alert("Id minimum 4 chars")
        isOK = false
    }
    if(usr_pass.length < 1)
    {

        alert("Type a password")
        isOK = false
    }
    
    if(!is_email(usr_em))
    {

        alert("Email invalid")
        isOK = false
    }
    
    if(usr_pass_conf!=usr_pass){
        alert("Password don't match")
        isOK = false
    }
    
    //validare pentru campurile custom-sa contina caractere acceptate
    for (j = 5; j < f.length-1 ;j++){
        field=f[j].value
        if(field!='T' && field!='F')                
            if(!accept(field))
                {

                    alert("Field "+f[j].name+" ("+field+") invalid")
                    isOK = false
                }        
    }

    
    
    return isOK
}    
</script>

<?

if( ($handle=fopen("server_fields.cfg","r"))==NULL){
    echo "Erorr opening server_fields.cfg";
    die();
}
else
    {
    $name=array();
    $fields=array();
    $type=array();
    $length=array();
        
    $i=0;
    while (!feof($handle)) {
        list($name[$i],$fields[$i],$type[$i],$length[$i])=explode("-",fgets($handle));                
        $i++;
        }

    
    $i--;
    fclose($handle);
    }


?>


<table  border="0" align="center" cellpadding="0" cellspacing="1">
  <tr>
    <td height="111" valign="top" align="left">
        <br>
        <b><? echo $message['Accepted chars']; ?><B>
        <font size='+1'>_`.!,:_#@$^&*+|{}/?=-</font> <? echo $message['letters and numbers'];?>
        <br>
        <br>
                <b><font color='red'><? echo $message['Required'];?></font><b>
            
                <form name="frm" action="modules/insert_user.php" method="post">
                <? if($err==1) echo "<br><font color='red'>Id or Email already exists</font><br>"; ?>
                Id:*<br>
                <input type="text" size="20" maxlength="20" name="id" /><br>
                
                <? echo $message['Password'];?>:*<br>
                <input type="password" size="20" maxlength="20" name="password" /><br>
                
                
                <? echo $message['Confirm Password'];?>:*<br>
                <input type="password" size="20" maxlength="20" name="password_" /><br>
                
                
                Email:*<br>
                <input type="text" size="20" maxlength="60" name="email" /><br>
                
                <? if($err==2) echo "<br><font color='red'>Web page already exists</font><br>"; ?>
                
                <? echo $message['Web page'];?>:<br>
                <input type="text" size="30" maxlength="255" name="webpage" /><br>
                <? echo $message['Receive news'];?>
                <input type='radio' name='news' value='yes'/>Yes
                <input type='radio' name='news' value='no' checked />No
                <input type="hidden" value="<? echo $site; ?>" name="site"/>
                <br>
                <?
                for($j=0;$j<$i;$j++){
                
                    #
                    #int(1) means bool.
                    #

                    if(strcmp($type[$j],"int")!=0 && $length[$j]!=1)
                        echo "
                        "
.$name[$j].":<Br>
                        <input type='text' name='"
.$fields[$j]."' /><br>
                        "
;
                    else
                        echo "
                        "
.$name[$j].":
                        <input type='radio' name='"
.$fields[$j]."' value='_BOOL_T_' />Yes
                        <input type='radio' name='"
.$fields[$j]."' value='_BOOL_F_' checked />No
                        <br>
                    "
;    
                        
                }

                ?>

                <br>
                <center><input type='submit' value="Register" onClick="return validate()"/></center>
                <!-- transmit situl mai departe pt prelucrare -->
                
                </form>
            
    </td>
  </tr>
</table>
<?
}
?>

Gewijzigd op 01/01/1970 01:00:00 door Tedd Master
 
Joren de Wit

Joren de Wit

16/01/2009 15:25:00
Quote Anchor link
Het lijkt erop dat je hier PHP met javascript aan het mixen bent. Dat gaat natuurlijk nooit werken...
 
Tedd Master

Tedd Master

16/01/2009 15:32:00
Quote Anchor link
okay dan haal ik hem wel door phpdesigner heen
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.