Spring
-
Posts
224 -
Joined
-
Last visited
Posts posted by Spring
-
-
Didn't really work how I wanted it to, I want to change the HTML class to 'current' depending on what page they're on. For example:
$page = $_SERVER['PHP_SELF']; if($page === '/blah/game/index.php') { echo 'class="current"'; } if($page === '/blah/game/register.php') { echo 'class="current"'; }
That didn't work, any suggestions?
-
Is there a function to check the name of the current page? Such as login.php or something like that? If not, does anyone have a custom function already created?
-
Change this part to initialize an empty $comments variable before the loop, then use the concatenation operator .= instead of the assignment operator =
Also, you should list the fields you want to SELECT in your query instead of using a wildcard SELECT *
$i=0; $comments = ''; while ($i < $num) { $comments .= mysql_result($result,$i,"comment"); $i++; }
Thank you for the tip and the quick fix.
-
I'm trying to loop out 10 rows of comment, but this code only displays comment one time, how do I display all rows?
$query = "SELECT * FROM ".$prefix."comments WHERE userto = '".$user."' ORDER BY comment DESC LIMIT 0, 10"; $result = mysql_query($query); $num = mysql_num_rows($result); //Loop out code $i=0; while ($i < $num) { $comments=@mysql_result($result,$i,"comment"); $i++; }
-
Here's the link
http://99.5.218.227/trollmev2/
When you go to the site you will notice that it scrolls down and shows too much whitespace, what am I doing wrong and how can I fix it? I tried making the wrappers margin smaller but it didn't work, any ideas?
and here's the css.
html, body { background: url('images/background.gif') repeat-x; padding:0; margin:0; width: 100%; height: 100%; } .logo{ background: url('images/logo.gif') no-repeat; width:177px; height:106px; margin-left:200px; position:relative; top:25px; } .header{ width:100% height:100%; } .header marquee{ margin-top:55px; font-size:18px; font-weight:italic; } .signbox{ position:relative; bottom:393px; left:1190px; background: url('images/signup.gif') no-repeat; width:298px; height:509px; } #welcomeback{ padding-top:25px; font:bold 25px "Helvetica Neue",Arial,Sans-serif; color:#333; padding-left:30px; } #hr1{ border-color:black; width:200px; border-top:1px } #username{ position:relative; left:20px; color:#333; font-family: "Helvetica Neue",Arial,Sans-serif; font-weight:bold; font-size:20px; } #usernamef{ position:relative; left:20px; border-color:black; width: 250px; height: 35px; border-width:1px; } #passwordf{ position:relative; left:20px; border-color:black; width: 250px; height: 35px; border-width:1px; } #password{ position:relative; left:20px; color:#333; font-family: "Helvetica Neue",Arial,Sans-serif; font-weight:bold; font-size:20px; } #formsubmit{ position:relative; left:30px; } #hr2{ border-color:black; width:200px; border-top:1px } #newuser{ font-size:18px; padding:0px 10px 0px 15px; margin-left:17px; } #link{ color: #FFFFFF; text-decoration: none; font-size:20px; margin-left:43px; } .wrapper{ } .welcomemsg{ margin-left:460px; font-size:27px; font-family:"Helvetica Neue"; } #textarea{ margin-left:340px; padding-top:10px; padding-left:20px; resize:none; border-color:transparent; background-color:transparent; background: url('images/textarea2.gif') no-repeat; width: 678px; height: 142px; border-width:1px; }
-
Can anyone help me? Here's the css. Also, can you tell me why it scrolls down so far? I don't want it stretching like that.
html { width:1024px; height:768px; overflow-x:auto; overflow-y:auto; } #bodyhome { border-style:solid; background-color:#c9c8c8; margin: 0px -590px 0px 0px; padding: 0px 0px 155px 0px; background-image:url('images/background.gif'); background-repeat: repeat-x; } #wrapper { border-style:solid; margin: 16px 0px 0px -20px; padding: 0px 0px 250px 0px; } .logo { margin: -4px 650px 0px 9px; padding: 0px 0px 0px 80px; } #question { font-size:14px;height:82px;padding:15px;width:479px; margin: -300px 0px 0px 300px; padding: 0px 200px 130px 50px; } #answerbox { position:relative; bottom:65px; left:90px; } #empty { resize: none; font-style:italic; } #statbox { position:relative; top:60px; left:70px; } #submit { position:relative; bottom:50px; left:240px; } #arrow { position:relative; left:120px; } #randompost { color: #c9c7c6; font-family: “Trebuchet MS”, Verdana, Arial, Helvetica, sans-serif; position:relative; bottom:60px; left:150px; font-family:Microsoft Sans Serif; font-size:20px; font-style:italic; font-weight:bold; } #darrow { position:relative; left:100px; bottom:7px; } #checkbox { position:relative; bottom:20px; left:90px; font-weight:bold; } #rightside { border-style:solid; position:relative; left:670px; bottom:300px; } #vr { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; border-style:solid; border-top-style:none; border-bottom-style:none; border-left-style:none; height: 200px; } #field { width: 340px; height: 37px; border-color: #c9c7c6; } #formsign { left:50px; border-style:solid; position:relative; bottom:150px; } #labels { font-family: “Trebuchet MS”, Verdana, Arial, Helvetica, sans-serif; color: #c9c7c6; font-size:18px; font-weight:bold; } .sign_up_text { position:relative; bottom:170px; left:30px; } #hr { position:relative; right:60px; width:380px; }
-
Sorry got it! my apologizes
-
Here's the register page:
<?php include ("database.php"); include ("class.register.php"); echo '<html> <title>Register</title> <body> </body> <form method="post" action=""> Username: <input type="username" name="username" size="15" /><br /> Password: <input type="password" name="password" size="15" /><br /> <div align="center"> <p><input type="submit" name = "submit" value="Login" /></p> </div> </form> </html>'; if(isset($_POST['submit'])) { $reg = new register($_POST['username'], $_POST['password']); $reg->checkEmpty(); } ?>
Here's the class im working on
<?php class register{ //Setting up Variables, you can add more, for example EMAIL. private $_username; private $_password; //Giving the variables values function __construct($u_name, $p_word) { $this->_username = $u_name; $this->_password = $p_word; } //If you want to do some error checking or whatever public function getUsername() { return $this->_username; } //checks to make sure fields are set public function checkEmpty() { if(empty($u_name) || empty($p_word)){ echo "All fields are required to continue!"; } else { $this->_mysql_check(); } } private function _mysql_check() { $query = mysql_query("SELECT username FROM acc WHERE username = '$u_name'") . mysql_error(); if (mysql_num_rows($query) != 0) { echo "Username already exists!"; } else { $this->_msql_insert(); } } private function _mysql_insert() { $query = mysql_query("INSERT INTO acc ('username', 'password') VALUES ('$u_name',$p_word'") . mysql_error(); } } ?>
For some reason I keep getting All fields are required to continue! Even if I fill out both fields. Can anyone help?
-
How do I echo u_name that I set up from the construct?
Ah, hey thanks.
-
I'm fairly new to OOP, could you help me fix this? Thanks!
class register{ //Setting up Variables, you can add more, for example EMAIL. private $_username; private $_password; //Giving the variables values function __construct($u_name, $p_word) { $this->_username = $u_name; $this->_password = $p_word; }
if(isset($_POST['submit'])) { $reg = new register($_POST['username'], $_POST['password']); echo $reg->u_name; }
Notice: Undefined property: register::$u_name in C:\wamp\www\register.php on line 23
-
Here's the class
<?php session_start(); class Train { private $_clicked; private $_name; function __construct() { $this->_name = (string) $_SESSION['nrpgusername']; $this->_clicked = (int) $_SESSION['clicked']; } public function CheckLogged() { if(isset($this->_name)) {} else{die("you must be logged in!");} } public function CheckClicked() { if(isset($_POST['go'])) { $this->MysqlUpdate(); $this->_clicked = 1; session_set_cookie_params(84600); } } public function Clicked() { if(isset($this->_clicked)) { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"> <span id="click">' . $this->_name. ' has gained 7 experience,<br /> and cannot train anymore today. </span><form method ="post" name="train" action=""> </div>'; } else { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"><span id="click">Click here to train your shinobi!</span> <form method ="post" name="train" action=""><input type="submit" name="go" value="train" /></div>';} } private function MysqlUpdate() { include("database.php"); $query = "UPDATE account_info SET experience = experience + 7 WHERE username = '$this->name'"; $result = mysql_query($query) or die(mysql_error()); } } ?>
For some reason, it's showing 1 has gained 7 experience,
and cannot train anymore today.
Instead of Tony has gained 7 experience,
and cannot train anymore today.
-
You can't.
Your host should have provided a way of upgrading your account to php5, either through a control panel choice or through a setting in a .htaccess file.
Ok thanks, I'll open a ticket.
-
You are still using php4. The end of life of php4 was nearly 4 years ago. Time to upgrade.
It's my host, how can I make them private with php4?
-
This is my first class, go easy on me.
<?php session_start(); class Train { private $_clicked; private $_name; function __construct() { $this->_name = $_SESSION['name']; $this->_clicked = $_SESSION['clicked']; } public function CheckLogged() { $this->_name == true ? "" : die("You must be logged in!)"; } public function CheckClicked() { if(isset($_POST['go'])) { $this->MysqlUpdate(); $this->_clicked = 1; } } public function Clicked() { if(isset($this->_clicked)) { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"> <span id="click">' . ucfirst($this->name). ' has gained 7 experience,<br /> and cannot train anymore today. </span><form method ="post" name="train" action=""> </div>'; } else { echo' <div id="train"><img src="images/train.jpg" alt="train image"/></div> <div id="text"><span id="click">Click here to train your shinobi!</span> <form method ="post" name="train" action=""><input type="submit" name="go" value="train" /></div>';} } private function MysqlUpdate() { $query = "UPDATE account_info SET experience = experience + 7 WHERE username = '$this->name'"; $result = mysql_query($query) or die(mysql_error()); } } ?>
getting this error
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home2/producy2/public_html/arzania/train.class.php on line 6
-
Mind posting the HTML?
-
If you actually look at the line where the error is being reported, you will see it is the following code, where you have a $ in front of the die() statement -
$die("Your avatar is uploaded. <a href = 'character.php'> home </a>");
It always helps to post actual errors, like someone had to ask you to do.
Oh i see, I'll do that from now on, thanks
-
I posted too soon, it goes into the avatars folder, but doesn't store in the database.
<?php session_start(); include "functions.php"; include "database.php"; if(($_POST['upload'])){ $uploadname = $_FILES['avatar']['name']; $tmp_name = $_FILES['avatar']['tmp_name']; if($uploadname){ echo "..."; } else{ die("Please select a file numb nuts!"); } if($uploadname) { [b]$location = "avatars/$uploadname";[/b] move_uploaded_file($tmp_name,"$location"); $query = mysql_query("UPDATE narutorpg SET imagelocation = '$location' WHERE username = '$name'") . mysql_error(); $die("Your avatar is uploaded. <a href = 'character.php'> home </a>"); } } echo " <form action = '' method = 'POST' enctype = 'multipart/form-data'> File:<input type = 'file' name = 'avatar'> <input type = 'submit' name = 'upload' Value = 'upload'> </form>"; ?>
This was the change I made:$location = "avatars/$uploadname";
-
It works, yet I get a "fatal error" that's weird..
-
php info is fine, no disabled functions.
and I'll rewrite it..
edit:
Still getting
Fatal error: Call to undefined function: () in /home2/producy2/public_html/arzania/upload.php on line 24
-
Still nothing
-
maybe no help, but could you post the error as it appears?
it's just the normal php call to undefined function and says the line
-
Your host may have file uploads disabled. Check phpinfo.
Yeah it's on, I don't know what could be the problem.
-
I get an error saying call to undefined function. Shouldn't move_uploaded_file() work?
(I know I didn't set the size and etc, it's just a practice test) Also, my host's php version is 4.4.9 could that be a problem?
<?php session_start(); include "functions.php"; include "database.php"; if(($_POST['upload'])){ $uploadname = $_FILES['avatar']['name']; $tmp_name = $_FILES['avatar']['tmp_name']; if($uploadname){ echo "..."; } else{ die("Please select a file numb nuts!"); } if($uploadname) { $location = "avatars/$name"; move_uploaded_file($tmp_name,"$location"); $query = mysql_query("UPDATE narutorpg SET imagelocation = '$location' WHERE username = '$name'"); $die("Your avatar is uploaded. <a href = 'character.php'> home </a>"); } } echo " <form action = '' method = 'POST' enctype = 'multipart/form-data'> File:<input type = 'file' name = 'avatar'> <input type = 'submit' name = 'upload' Value = 'upload'> </form>"; ?>
-
"I spent 27 hours on this" Haha.
Is there a function to check the name of the current page?
in PHP Coding Help
Posted
Thanks a lot, I really appreciate it.