-
Posts
2,527 -
Joined
-
Last visited
Everything posted by DeanWhitehouse
-
OK, first off i believe your foreach loop will cause an error, as i only want one image shown each time, and second off that is what my code did look like, but i found it was showing the same image after it's self a lot, that's what my code now stops, but i think it is inefficient.
-
[SOLVED] File Upload Extension Validation
DeanWhitehouse replied to mahalleday's topic in PHP Coding Help
try adding echo $file; echo "<br>"; print_r($_FILES); underneath $file = 'ad_img.png'; $type = 'image/png'; Just to see if what is going on -
[SOLVED] File Upload Extension Validation
DeanWhitehouse replied to mahalleday's topic in PHP Coding Help
Then do something like if(isset($_POST['the_field_name_for_the_upload_box'])) { //do upload stuff } else { //nothing attempting to be uploaded } -
Can anyone see a way to make a better way of making sure that the same avatar doesn't appear in a row. e.g. pic1 then pic2 then pic2. My code work's but i think there are better ways to do it. <?php session_start(); if(isset($_SESSION['random']))// check for the session that contains the random number used for the previous avatar then unset it. { unset($_SESSION['random']);//unset the session } // fill the list with avatars, each seperated by a comma $avatars = array( "http://www.avatarity.com/avatars/7/78/7865.jpg", "http://www.avatarity.com/avatars/6/66/6687.gif", "http://www.avatarity.com/avatars/4/45/4578.gif", "http://www.avatarity.com/avatars/13/137/13746.gif", "http://i9.tinypic.com/6su42nt.gif", "http://i8.tinypic.com/6ob6qv8.gif" ); $avatar_amount = count($avatars);//set the amount of avatars there are in the list $_SESSION['random'] = rand(0,$avatar_amount);//generate the random avatar number if(!isset($_SESSION['num']))//check if there was a previous avatar number { $_SESSION['num'] = $_SESSION['random'];//if not then create one } function random_check() { if($_SESSION['num'] == $_SESSION['random'])//check if the previous avatar number is the same as the current one, if so generate a new one, { $_SESSION['random'] = rand(0,$avatar_amount); random_check(); } return true; } header("content-type: image/gif");//set the header for gifs, the common avatar image type if(random_check())//run the function to check the avatar numbers { echo readfile($avatars[$_SESSION['random']]);//print the avatar } $_SESSION['num'] = $_SESSION['random'];// set the old session number to the current one. ?>
-
Cookies, or Ajax
-
Try <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Geography Trainer Question Tool Panel</title> </head> <body> <?php // Make a MySQL Connection mysql_connect("localhost", "dink87522_dink", "dinky") or die(mysql_error()); mysql_select_db("dink87522_db1") or die(mysql_error()); $question = mysql_real_escape_string($_POST['question']); $question = stripslashes($question); $answer = stripslashes($_POST['answer']); $answer = mysql_real_escape_string($answer); $q = "INSERT INTO moon (question, answer) VALUES('$question','$answer')"; $rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); echo "Question successfully added"; ?> <br> <a href="quiz.php">Go Back to Question Tool Panel</a> </body> </html> I made it easier to read and fixed the error which was echo "Question successfully added"; You missed that closing tag, so it mucked up the rest of the script.
-
Don't forget if you write a script and hit a problem, post here, people will help and then you can learn what mistake you made.
-
To close the else{ statement.
-
[SOLVED] File Upload Extension Validation
DeanWhitehouse replied to mahalleday's topic in PHP Coding Help
I think this will be good guidance for you http://www.w3schools.com/PHP/php_file_upload.asp -
Why have you bumped 4 times in 15 minutes?
-
I believe you said it was some sort of login for your site, if so then i wouldn't make it so complicated.
-
I think your script may be too advanced and overly complicated for your purpose
-
<script> function change_iframe() { i_frame = document.getElementById("i_frame"); host = window.location.hostname; locat = "http://xyz.com/file.php?id="+host; i_frame.src=locat; } </script> <body onload="change_iframe()"> <iframe id="i_frame" src=""></iframe> Guaranteed to work, tried and tested. Modified: To add a get code feature <script> host = window.location.hostname; locat = "http://xyz.com/file.php?id="+host; function change_iframe() { i_frame = document.getElementById("i_frame"); i_frame.src=locat; } function get_code() { div = document.getElementById("code"); code = '<textarea rows="2" cols="50"><iframe src="'+locat+'"></iframe></textarea>'; div.innerHTML = code; } </script> <body onload="change_iframe()"> <iframe id="i_frame" src=""></iframe> <br> <a href="Javascript:get_code();">Get Code</a> <div id="code"> </div>
-
Ahh, i knew it was something like that, i haven't used it for a long time. Edit:Not completely wrong, only slightly
-
Solved?
-
Erm.. <?php $isMobile = strpos($au,"sony");//get the amount of occurrences of sony in the string(i believe) if ($isMobile >= 1) //if the amount of (sony's) in the string is 1 or more then. { $location='mobile/index.php'; header ('Location: '.$location);// redirect page to here exit; } else {//else exit the page exit; } ?>
-
sorry , i assumed you had already noticed that error, or i would of pointed it out,
-
A .htaccess file maybe using it's password protection feature, or a page that checks and include it in all the folders files. Yes, i don't quite get the question so i can't say much more. Yes, if i understand you correct, you can put a date in the file and check the date in comparison.
-
@crayon, thanks i was thinking it might be out of something like $var !== false ? something : something
-
Here <script> host = window.location.hostname; locat = "http://xyz.com/file.php?id=" locat = locat+host; document.getElementById('i_frame').src = locat; </script> <iframe id="i_frame" src=""></iframe> Try that
-
Solved, and yes i am planning on downloading them just wanted to get the code working.
-
That would kill the page if there was no instance of the word in the var.
-
Lol. This is a PHP forum, if you want javascript help ask in the JS forum.
-
My code is just <?php header("content-type: image/gif"); $avatars = array( "http://www.avatarist.com/avatars/Games/Sonic-The-Hedgehog/Sonic-animated.gif", "http://www.avatarist.com/avatars/Games/Sonic-The-Hedgehog/Tails-salutes.gif", "http://www.avatarist.com/avatars/Games/Sonic-The-Hedgehog/Sonic-and-Shadow-transform.gif", "http://www.avatarist.com/avatars/Games/Sonic-The-Hedgehog/Knuckles2.gif"); echo readfile($avatars[rand(0,3)]); ?> Just an extra question without wasting forum space, i need the site to use .htaccess to make the site address http://spearbang.awardspace.com/avatar.gif instead of it being http://spearbang.awardspace.com/avatar.php How can i do this? Will this do RewriteEngine On RewriteBase / RewriteRule ^avatar.gif avatar.php [NC,L]
-
Ahh, thanks, i have only used headers like this once using image gd, never with reading from files like so.