Jump to content


Photo

need help


  • Please log in to reply
9 replies to this topic

#1 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 02:57 AM

i'm beginner in PHP and i have some problems here. this is my coding:

<?
if (isset($_GET['page']))
{
$page = $_GET['page'];
}
else
{
$page = 0;
}

if ($page == "1")
{
$filename = addslashes($_POST['filename']);
if ($filename=="")
{
echo("*** No information given! ***");
}
else
{
$data = file ( '$filename' ); 
echo("*** hello!! ***<br>");
echo("*** $filename ***");
}
}
else
{
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<center>
<form name= "form1" form method="post"action="<?=$_SERVER['PHP_SELF']?>?page=1"enctype="multipart/form-data?page=1">
<p>
<input type="file" name="filename">
</p>
<p>&nbsp;</p>
<p>
<input name="Submit" type="submit" id="Submit" value="Grade" onkeypress="Check()">
//<input type="hidden" id="formaction" value="uploadNow">
<input name="reset" type="reset" id="reset" value="Clear">
</p>
</form>
</center>
<?
}
?>

and the output is here:

Warning: file($filename) [function.file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\grade.php on line 20
*** hello!! ***
*** C:\\\\Documents and Settings\\\\user\\\\Desktop\\\\hardware.txt ***

i need to open a file and the location so shown with many slashes (\\\\). why this happen and how to solve this. if u have any other coding that does solve this problem. plz let me know. and since i'm a beginner, plz give full instruction on wat to do, cause i might don't know. advance thanx for ur help.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 05:03 AM

Try removing addslashes() for a second to debug your result.

#3 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 06:34 AM

i appreciate ur help... thanx... ur advise worked but still have few problems

from:
$filename = addslashes($_POST['filename']);

i changed to:
$filename = $_POST['filename'];

and the output was:
Warning: file($filename) [function.file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\grade.php on line 20
*** hello!! ***
*** C:\\Documents and Settings\\user\\Desktop\\navz.txt ***

the slashes were less... but there is one more problem... i cannot ignore the whole...
//$filename = addslashes($_POST['filename']);
because it will not read the filename inserted.... so how? help... thanx...


#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 06:55 AM

Wait a sec. What exactly are you trying to do? You realise that if you move this code to a server it will not work? I mean, you wont be able to open a file on the clients machine.

Another problem is you need double quotes around $filename. I don't know how your code is working at all.

$data = file ( "$filename" );

can you post all your current code and any errors?

#5 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 07:05 AM

the whole code is above there.... actually this code will in a server and the client pc will access that page to grade the student according to the marks in the file.... so.... that's the coding about... how am i suppose to do that... i'm just a beginner in PHP... i hope u might help... thanx...

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 07:09 AM

You will need to upload the file to the server.

#7 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 07:10 AM

yes... i need to upload it to server... how to do that?  ???

#8 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 August 2006 - 07:16 AM

There is a tutorial on this site which will show you how to upload an image... the process is the same.

#9 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 07:17 AM

thanx... the double quating (") help me to solve the problem to open the file... thanx bro... but i still need to know how this code will work... i mean... i know i made a mistake... i know this won't work because when we accessing the server and the client pc have to send that file to the server to generate the grade into the file and to be send back to client pc... how do i do that?

#10 thibz21

thibz21
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 17 August 2006 - 07:18 AM

There is a tutorial on this site which will show you how to upload an image... the process is the same.


thanx alot bro... i really appreciate ur help... i'll refer that web u gave me.... any problems i'll get back to u later... i hope u don't mind i asking question... thanx again bro.... later...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users