-
Posts
2,000 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Andy-H
-
You would also need to use stripslashes(), sorry about the 3 replies for one answer I'm just testing it on my db lol
-
So basically use htmlspecialchars and annotate the variable before displaying it.
-
Just tested it, <?php $var = htmlspecialchars($_POST['var']); if ($_POST['submit']){ echo ''.$var.''; } ?> <html> <head> </head> <body> <form method="post"> <textarea name="var" rows="5" cols="30"></textarea><br /> <input type="submit" name="submit" /> </form> </body> </html> That works fine for me.
-
[SOLVED] How do I go about making a site without frames???
Andy-H replied to Andy-H's topic in Application Design
thanks -
[SOLVED] How do I go about making a site without frames???
Andy-H replied to Andy-H's topic in Application Design
Also, I have VERY little knowledge of JavaScript and no knowledge of HTTP REQUESTS/AJAX :S -
[SOLVED] How do I go about making a site without frames???
Andy-H replied to Andy-H's topic in Application Design
Thanks for the advice, obsidian loving the avatar but FFVII and FFX rule, VIII and IX are top games too -
[SOLVED] How do I go about making a site without frames???
Andy-H replied to Andy-H's topic in Application Design
By that do you mean make the basic page layout in tables, then have a central index like: <?php $page = htmlspecialchars($_GET['page']); if ($page == "Online"){ require("online.php"); }elseif ($page == "Kill"){ require("kill.php"); }etc{ } ?> ??? -
Well earlier in the script I have the mysql_real_escape_string to all variables that are going into queries and in this case the login-name and password are encrypted using md5(); then the username is fetched from the database to start the session. Also I am not familiar with the proper functionality of sprintf(); what does it do exactly. Also thanks for the help guys
-
And is that the best / safest way to do it?
-
HI all, I am a self taught PHP / MySQL programmer and I learned from trial and error (editing scripts) then went on to writing them. Anyway I wont give you my life story but the point I am getting at is when I make scripts I don't know why I am putting code their, I just know to do it. I have just started a new project and I have been using PHP variables in queries as shown below: $query_string = "SELECT `username` , `password` FROM `accounts` WHERE `loginname` = '".$user."' LIMIT 1"; $query = mysql_query($query_string)or die("Error: ".mysql_error()."<br /><br />In File: ".__FILE__."<br /><br />On Line: ".__LINE__); I was just wondering is this really necessary as it is quite annoying to do to be honest. If not what is the best way to do this? Thankyou for all replies.
-
I am making a text based game and have been advised(in HTML help) not to use frames, I have only ever made a website with frames before and was wondering how to go about this. I already know I will have a header file with the banner and menu then program the main page before requiring a footer. Is the best way to go about this to make a page-sized table dividing the page into banner, menu, main page and footer between the require files or does anyone know of a better/more efficient way? Thank you for any replies.
-
[SOLVED] Calling PHP / MySQL inside a javascript function
Andy-H replied to Andy-H's topic in PHP Coding Help
I fixed it without AJAX as I cant see the point in learning it just for this. I figured since I have two files that are required in every single file at the top I just added: mysql_query("UPDATE `players` SET `pageat` = '' WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); In my require files and added: mysql_query("UPDATE `players` SET `pageat` = '$topicid' WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); After the file require in my viewtopic.php and: <tr> <td colspan=2><div align="center">Users Viewing This Topic:<br> <br> <?php $lol = mysql_query("SELECT * FROM `players` WHERE `pageat` = '$topicid' ORDER BY `rank` DESC")or die(mysql_error()); while($ass = mysql_fetch_assoc($lol)){ $viewer = $ass['playername']; echo "<a href=\"profile.php?viewuser=".$viewer."\">".$viewer."</a> , "; } ?> </div></td> </tr> To show whose viewing the topic. Thanks for the help guys. -
[SOLVED] Calling PHP / MySQL inside a javascript function
Andy-H replied to Andy-H's topic in PHP Coding Help
Thanks -
I am trying to make a "who's viewing topic" feature for a forum using this code: <script type="text/javascript"> <!-- function loadingUp() { <?php mysql_query("UPDATE `players` SET `pageat` = '$topicid' WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); ?> } function loadingDown() { <?php mysql_query("UPDATE `players` SET `pageat` = '' WHERE `playername` = '$player' LIMIT 1")or die(mysql_error()); ?> } //--> </script> <body onLoad="loadingUp();" onUnLoad="loadingDown();"> However instead of processing the PHP on the page load/unload it just reads through it and updates the field to the topic id, then updates it back to blank as the script loads, is there a way I can do this?
-
Just thaught I'd share it incase anyone wanted to use it or maybe someone could give a few pointers to stop me from getting bad habbits as I learn? <html> <head> <title>Test</title> </head> <body> The current date and time is - <span id="id"></span><br /><br /> </body> </html> <script type="text/javascript"> <!-- function display() { var countdown = document.all ? document.all["id"] : document.getElementById ? document.getElementById("id") : ""; var currentTime = new Date() var day = currentTime.getDate() var month = currentTime.getMonth() + 1 var year = currentTime.getFullYear() var hours = currentTime.getHours() var minutes = currentTime.getMinutes() var secs = currentTime.getSeconds() if(hours > 11){ hours = hours - 12 var ap = "PM" } else { var ap = "AM" } if (secs < 10) secs = "0" + secs if (minutes < 10) minutes = "0" + minutes if (hours < 10) hours = "0" + hours if (day < 10) day = "0" + day if (month < 10) month = "0" + month var today = day + "/" + month + "/" + year var time = hours + ":" + minutes + ":" + secs var timeCount = today + " " + time + " " + ap if (countdown) { countdown.innerHTML = timeCount + " "; setTimeout('display()',1000); } } display(); //--> </script>
-
Today is: 2008-07-20 Next month is: 2008-08-20 Thanks :-D
-
Today is: 2008-07-20 Next month is: 1970-01-31 lol :S
-
Thankyou, also do you know of any way I can add a month to the date from date('Y-m-d'); without having to explode it and go through if statements to make it add years instead of going to 13 etc. ???
-
How can I find the difference in days, months and years between two given timestamps (yyyy-mm-dd hh:mm:ss). Ty for any help
-
<?php $ymd = date('Y-m-d'); $time = date('H:i:s'); $exp = explode(":", $time); $hour = $exp[0] + 5; $imp = array($hour,$exp[1],$exp[2]); $his = implode(":", $imp); $today = $ymd." ".$his; echo $today; ?> Did it that way, worked anyway lol
-
I also need the date to be in the format of 0000-00-00 00:00:00
-
Can anyone please tell me how to get the correct UK date in PHP, thanks for any answers.
-
<?php require("connections/functions.php"); ?> <html> <head> <title><? echo $sitename; ?> - Admin Area</title> </head> <frameset rows="100,*" framespacing="0" border="no"> <frameset rows="100,*" framespacing="0" border="no"> <frame src="welcome.php" name="topFrame" scrolling="no" noresize="noresize" /> </frameset> <frameset cols="175,*" framespacing="0" border="no"> <frameset cols="175,*" framespacing="0" border="no"> <frame src="menu.php" name="menu" scrolling="auto" noresize="noresize" /> <frame src="custom.php" name="mainFrame" scrolling="auto" noresize="noresize" /> </frameset> </frameset> </frameset> <noframes> <body> <center><strong><font color="red"> Sorry, your browser doesn't support frames. Please download a newer version. </font></strong></center> </body> </noframes> </html> Why is that the only way my frames will work? Help please???