Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. Open the page via Javascript, ie window.open ("myPHPscript.php", "mywindow","menubar=1,resizable=1,width=350,height=250") then the script will get the random location..
  2. I decided to test it, and had a problem anyways I have written a little example of sending and loading data from flash to PHP, Example you should be able to use this, enter text in top box and click send, and Sigh in ahhhokay it a very basic example, but using the PHP code in the previous post should help with what this lacks Source = Flash & PHP Hope that helps
  3. okay can you also post config.php lines 17-22 you could try moving session_start(); up two lines <?php session_start(); //new include_once ('../classes/config.php'); include_once ('../classes/functions.inc.php'); //session_start();//old
  4. As for creating a array for languages then break them up into files, (so you only load the required one) ie <?php $lang = array( "Hello" => "Hello", "bye" => "Good Bye" ); ?> <?php $lang = array( "Hello" => "Hallo", "bye" => "Auf Wiedersehen" ); ?> then you can include the desired language ie <?php $langID = "en"; include $langID.".php"; echo $lang['Hello']; ?> or <?php $langID = "de"; include $langID.".php"; echo $lang['Hello']; ?> Hope that help, as for the forum i agree with Mchl, that sqllite is a good option
  5. The part "headers already sent" means you have output before the command, whats the first 5 lines of paypal_success.php ?
  6. Try this, it basically checks the file type and if its not jpeg it stops the script <?php //This is the directory where images will be saved if ($_FILES['photo']['size'] > 0){ $fileName = ($_FILES['photo']['name']); $ext = substr(strrchr($fileName, "."), 1); $target = "uploads/"; $randName = md5(rand() * time()); $target = $target . $randName . '.' . $ext; } //Added $allowedType = array("image/pjpeg","image/jpeg"); if(!in_array($_FILES["photo"]["type"],$allowedType)){ echo "Invalid file type"; exit; } //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)){ //Tells you if its all ok echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; ResizeJPEG($target, 200, 200); }else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } //Example #2 Resampling an image proportionally function ResizeJPEG($filename, $width, $height){ list($width_orig, $height_orig) = getimagesize($filename); $ratio_orig = $width_orig/$height_orig; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); //JPEG imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); return imagejpeg($image_p, $filename, 100); //JPEG } ?>
  7. As this is more Flash/AS then PHP, I'll give a quick work-flow (if you need more detail on one of them just ask) PHP 1. Create a PHP script that pulls data from the database and displaying it to the page. <?php // Connect $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') OR die(mysql_error()); $userID = 10; // Query $query = sprintf("SELECT Username FROM users WHERE ID=%d LIMIT 1", $userID); $result = mysql_query($query); //Display if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so am exiting"; exit; } $row = mysql_fetch_assoc($result); echo $row["Username"]; ?> 2. Update that script to accept a GET/POST parameter (using $_GET or $_POST) //$userID = 10; //remove $userID = (int)$_POST['ID'];//add 2.1 you can create a simple HTML form to test this for POST or edit the URL for testing GET), or use GET to test then simplely change $_GET to $_POST after testing Flash 3. in your flash app create a action script to load the PHP page. using the parameter (ie 10) for POST use userData = new LoadVars(); userData.ID = "10"; returnedData = userData.send("example.php", 0, "POST"); you can change POST to GET (if you want) returnedData will contain the data from the page. you can set that to whatever you need. Hope that helps
  8. <?php $file = 'saved/Archive.tar.gz'; $newfile = '/New.tar.gz'; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?>
  9. I would recommend using an array instead of 4 variables BUT, if you wanted to to be more dynamic you could do this <?php $orange[0]['my_id'] = 1; $red[0]['my_id'] = 2; $blue[0]['my_id'] = 3; $green[0]['my_id'] = 4; $nocolorsset = ''; $color = array('orange','red','blue','green'); foreach($color as $value) { $val = $$value; //this is the key behind it all (a variable variable) if (empty($val[0]['my_id'])) { $nocolorsset = 'none of the colors are set'; } } print $nocolorsset; more info here http://www.php.net/manual/en/language.variables.variable.php
  10. Yes you can do it in PHP, it basically forms with JS/PHP verification
  11. if your using a percentage then the code is simple <?php $items = array( array('lint',100), array('copper coin',75), array('silver coin',50), array('gold coin',10) ); function getItem(){ global $items; $rand = rand(0,100); $new_items = array(); foreach($items as $i => $item){ if($item[1] >= $rand) $new_items[] = $i; } $ID = array_rand($new_items); return $ID; } $array = array(0,0,0,0); for($n=0;$n<=500;$n++){ $ID = getItem(); $array[$ID]++; //echo $items[$ID][0]." - ".$items[$ID][1]."\n"; } foreach($array as $K => $arr){ echo $items[$K][0]."->".round($arr/500*100)."%\n"; } ?>
  12. here's a output from 1 to 10, with 2 random numbers here 3 random numbers Feel free to play with it, it was written for a little fun. EDIT: oh the reason i used $X[] = rand(1,$ID); twice is so you could play with ideas, for example $X[] = rand(1,$ID); //if $something is true then only set to highest number so in effect only using 1 random number instead of 2 $X[] = ($something == true)?$ID:rand(1,$ID); //if $somethingelse is true then set the highest number to 5 $X[] = ($somethingelse == true)?rand(5,$ID):rand(1,$ID); I hope you get the idea I assumed this was for a game or something..
  13. Okay i wrote this cod for a bit of fun.. Its just an idea, theirs probably better ways but this will only be 5 if X(current 2) random number hit 5. other than that will always be the lowest of all random numbers generated (so the more numbers generated the less chance of a high number) <?php $items = array( 1 => 'item 1', 2 => 'item 2', 3 => 'item 3', 4 => 'item 4', 5 => 'item 5' ); $X = array(); $ID = count($items); //The more of these the higher the chance of a lower number $X[] = rand(1,$ID); $X[] = rand(1,$ID); foreach($X as $Y) if($Y<$ID) $ID= $Y; echo $items[$ID]; ?> another option is to create a larger array with the rare items appearing once and the common items appear lots of times ie <?php $items = array( array(1 => 'item 1'), array(1 => 'item 1'), array(1 => 'item 1'), array(1 => 'item 1'), array(1 => 'item 1'), array(1 => 'item 1'), array(1 => 'item 1'), array(2 => 'item 2'), array(2 => 'item 2'), array(3 => 'item 3'), array(4 => 'item 4'), array(4 => 'item 4'), array(5 => 'item 5'), ); $Item = $items[array_rand($items)]; $Key = current(array_keys($Item)); $Value = current($Item); echo "$Key -> $Value"; ?>
  14. The RegEx converts the html tags to upper case. for example <?php $html_body = "<body><P>Hello World</P></body>"; $html_body = preg_replace("/(<\/?)(\w+)([^>]*>)/e", "'\\1'.strtoupper('\\2').'\\3'", $html_body); echo $html_body; ?> returns note that body becomes BODY
  15. I have marked this as solved, (you could do this itself by clicking "Mark Solved") or "Mark Unsolved" to unsolved it.
  16. On first glance I missed it too, (PS: I know it was a typo, as your coding is normally a high standard)
  17. use imagettftext with a bold font would be the best route, i guess you could do this, but its not very pretty header('Content-type: image/png'); $img_handle = imagecreatetruecolor(400, 30); $color = imagecolorallocate($img_handle, 255, 0, 0); $sum = 'Testing...'; $_x = array(1, 0, 1, 0, -1, -1, 1, 0, -1); $_y = array(0, -1, -1, 0, 0, -1, 1, 1, 1); for($n=0;$n<=8;$n++){ imagestring ($img_handle, 20, $x_cord+$_x[$n], $y_cord+$_y[$n], $sum, $color); } imagepng($img_handle); imagedestroy($img_handle);
  18. slight typo in salathe code, it should be $result = 'No match'; if (isset($array[$search])) { $result = $array[$search]; }
  19. try this <?php $string = '[pm]user1,user2[/pm] message of pm follows from '; //$string = 'message of pm follows from '; if (preg_match('%(?:\[PM\]([^[]*)\[/PM\])?(.*?$)%sim', $string, $regs)) { $Users = $regs[1]; $Message = $regs[2]; } echo "$Users - $Message";
  20. You can't use the same key for different values '1-2-3' => 'Dog Black' is replacing '1-2-3' => 'Dog Brown', so 'Dog Brown' doesn't exist,
  21. That code doesn't make much sense, you need to set the session after checking it, not before or it will never expire try <?php $expiretime = 900; if ($_SESSION['last_active']+$expiretime >= time()){ session_start(); $_SESSION = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); } header('Location: login.php?error=1'); }else{ $_SESSION['last_active'] = time(); } ?>
  22. change o to Y $timestamp = date("d/m/Y g:i:s A"); echo $timestamp ;
  23. The MySQL problem is down to wrong username and/or password, how are you accessing the database ?
  24. This may help http://www.sebastiansulinski.co.uk/web_design_tutorials/tutorial/7/install_apache_php_and_mysql_on_windows_vista
  25. Could be a few things, 1. problem in the script (ie inf. loop), (check scripts) 2. OS/PHP issue (ie vista/win7 get latest update (php+apache) 3. Network controller (check settings/firewall/controller etc) 4. could security settings (AV/Firewall/OS etc) I would probably get the latest PHP+apache, reboot and try again Let me guess your on Windows Vista right ?
×
×
  • 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.