Jump to content

ksun

Members
  • Posts

    14
  • Joined

  • Last visited

ksun's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i did print_r for the $flist(amount of files in the defult diirectory) and it said 5 items, i then did the amount of files in the directory i'm trying to get to(public html) and it ssyas there is no items in the array. ive tried to echo chdir($conn, "public_html"), but it says. Warning: ftp_chdir() [function.ftp-chdir]: Can't change directory to public_html: No such file or directory in /home/a3893538/public_html/test.php on line 25. but when i echo something like chdir($conn, "../"), it works fine. ty
  2. ok, so i'm kinda new to ftp with php, i'm having difficulties with getting contents of my public_html directory (i'm using a free web hosting service) when i'm using ftp_rawlist(); to retrieve public_html content, it returns an empty array. <?php $ftpServer = "usetheforce.hostei.com"; $ftpUser = "*"; $ftpPass = "*"; $conn = @ftp_connect($ftpServer) or die("Couldn't connect to FTP server"); $login = @ftp_login($conn, $ftpUser, $ftpPass); $workingDir = ftp_pwd($conn); echo "Files for directory: $workingDir<br><br>"; $fList = @ftp_nlist($conn, $workingDir); if(is_array($fList)) { $newDir = $fList[4]; // public_html if(ftp_chdir($conn, $newDir)) { $fList1 = ftp_rawlist($conn,$newDir); echo ftp_chdir($conn, $newDir); if(is_array($fList1)) { echo "Files for directory: $newDir<br><br>"; echo sizeof($fList1); for($i = 0; $i < sizeof($fList1); $i++) { echo $fList1[$i] . "<br>"; } } else { echo "$newDir contains no files."; } } else { echo "An error occured while changing to $newDir or $newDir is not a directory"; } } else { echo "$workingDir contains no files."; } ?> i've kinda isolated the problem, when i use: echo chdir($conn, "public_html") , it says: Warning: ftp_chdir() [function.ftp-chdir]: Can't change directory to public_html:. if anyone could help that would be gr8 thanks
  3. is it possible to use javascript?
  4. i can't 2 much code. the idea is this <?php $data = 1; $number = 2; function change() { global $data, $number; $data += 1; echo $number; } ?> <body> <table width="358" border="3"> <tr> <th scope="col"><?php echo $data; ?></th> <th scope="col"><?php change(); ?></th> <th scope="col"> </th> </tr> </table> <table width="200" border="3"> <tr> <th scope="col"> </th> </tr> </table> </body> </html> see where the $data is echoed??? it's mean't to echo 2, instead it echos 1; cause it echos B4 it adds 1; what i want to know is, is there any way for it to echo 2 while still retaining the structure of the function change();
  5. so here's one for ya, i've got a block of php code within a section of a html table with 3 columns, once the php code is phrased, it will echo stuff in the middle column in the html table. however this block of code will also change some variables, that are already echoed in the first column of the html table. seeing as how php and html is up to down, everytime the middle column php code is pharsed and echoed the variables in the first column will stay as if the variables are not changed. I really hope someone can help me and that there's a really newby/easy way to solve this problem.
  6. well , what i kinda want, is say i want to write a php variable like $data
  7. function displayinfo() { document.getElementById("demo").innerHTML=<?php echo "hi";?>; } never done this b4, can anyone help me?
  8. this code in my php while loop echo '<input type="radio" name="character" value=$data[0]; />'."<br/>"; for some reason i can't seem to get $data array value, help is appreciated ty
  9. woops, just figured out that PHP functions cannot see variables unless they are passed, or declare it global yep i'm that newb.
  10. OK, for some reason this function wont execute mysql_query when called upon. function attack() { mysql_query("UPDATE user SET HP = HP - 10 WHERE username = '$user'"); } to my best knowledge, i don't see why this wont work. i am 100% sure there is nothing wrong with the mysql_query. btw if am calling it, simply with this "attack();" so if anyone can help that would be gr8
  11. hi this is the skeleton code for a simple game thats suppose to take away 10 hp from enemy_hp each time the fight button is pressed but there seems to be something wrong with it, if anyone can help out, that would be gr8. the enemy hp seems to not fall below 90. <?php include('config.php'); include('user.php'); if(!loggedin()) { header("Location: login.php"); } $fight = $_POST['fight']; if($fight) { $defult = false; $enemy_hp = $enemy_hp - 10; echo $enemy_hp; } if(defult){ $user_hp = 100; $enemy_hp = 100; } $defult = true; ?> <body> <table width="444" height="278" border="3"> <tr> <td width="212"><form id="form1" name="form1" method="POST" action=""> <?php echo $user."\n <br>"; echo "hp = ".$user_hp; ?> <p><img src="images/monkey.png" width="108" height="97" /></p> <p> <input type="radio" name="attack" value="attack" /> attack</p> <p> <input type="radio" name="attack" value="radio" /> defend</p> <p> <input type="radio" name="attack" value="radio" /> skill 1 </p> <p> <input type="radio" name="attack" value="radio" /> <label for="radio"></label> skill 2</p> <p> <input type="radio" name="attack" value="radio" /> skill 3</p> <p> <input type="radio" name="attack" value="radio" /> skill 4</p> <p> <input type="submit" name="fight" value="fight" /> </p> </form></td> <td width="212"> <?php echo "ENEMY <br>"; echo "hp = ".$enemy_hp; ?> </tr> </table> </body>
  12. I have a problem with my php code on setting sessions and cookies for logins i have 4 pieces of code so far <?php session_start(); $hostname = "##########"; $username = "##########"; $password = "###########"; $db_name = "############"; mysql_connect("$hostname","$username","$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select database"); function loggedin() { if(isset($_COOKIE['username']) || isset($_SESSION['username']) ) { $loggedin = true; return $loggedin; ="submit" name="butto } } ?> config.php include to connect to database and use function <?php include('config.php'); if(loggedin()){ header('Location: membersarea.php' ); } ?> <html> <body> <form id="form1" name="form1" method="post" action="login.php"> <p> <label for="textarea"></label> <label for="textfield"></label> </p> <p> </p> <p>Login</p> <p>username: <input type="text" name="username" id="textfield" /> </p> <p> <label for="textfield"></label> password: <input type="text" name="password" id="textfield" /> </p> <p> rememberme <input name="rememberme" type="checkbox" value="" /> <input typen" id="button" value="Submit" /> </p> </form> </body> </html> login.html <?php include('config.php'); $username = $_POST['username']; $password = $_POST['password']; $rememberme = $_POST['rememberme']; session_start(); if($username&&$password) { $login = mysql_query("SELECT * FROM user WHERE username = '$username'"); while($row = mysql_fetch_assoc($login)) { $db_password = $row['password']; if($password == $db_password){ echo "success"; $loginok = true; } } } else { die("enter both fields."); } if($loginok == true) { if($rememberme == "on") { setcookie("username", $username, time()+7200); } else if($rememberme == "") { $_SESSION['username'] = $username; } header("location:membersarea.php"); } else { $loginok = false; die("wrong password"); } ?> login.php <?php include('config.php'); ?> <a href="logout.php">LOG OUT NOW</a> memberspage.php the main problem is when i goto login.html it instantly goes to memberspage even before i set session. if anyone can help out that would be gr8
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.