Jump to content

wwfc_barmy_army

Members
  • Posts

    320
  • Joined

  • Last visited

    Never

Everything posted by wwfc_barmy_army

  1. I'm looking to make it so after clicking on an external link through my site it waits 10 seconds with a message then forwards them using the header fuction.
  2. Hello. I am looking for some visual countdown for 10 seconds before some php code is run. Although i'm not sure how i can go about it. Any ideas? Thanks.
  3. Hello. I'm looking for a 10 second countdown before an event happens. I'm not quite sure how to do it. Can anyone offer any advice? Thanks.
  4. Hello everyone, i have this code: $result = mysql_query("SELECT * FROM user WHERE user_id = $user_id") or die(mysql_error()); while ($qry = mysql_fetch_array($result)) { while ($i <= $rowcount){ $result3 = mysql_query("SELECT * FROM type WHERE type_id = $i") or die(mysql_error()); $qry3 = mysql_fetch_array($result3); $isvalue = $qry[$i]; echo $isvalue; if (isset($isvalue) || $isvalue != "" || $isvalue != " "){ echo "<img src='images/" . $qry3['imgurl'] . "'/> " . $qry[$i] . "<br/>"; } else { echo "nothing"; } $i = $i + 1; } } When run it echos the "<img... etc", although for some reason if there isn't a value for one record in the database it will still print it, any ideas? thanks.
  5. Ah. Yeah. Thats great. I've got one more problem to solve: How can i add this part of the code into the loop: var queryString = "?1=" + 1 + "&2=" + 2; etc? Any ideas? Thanks.
  6. Well the whole code i have is: <?php if ($sql = mysql_query("SELECT name FROM type")) { if (mysql_num_rows($sql)) { while ($array = mysql_fetch_array($sql)) { $a[] = $array; } } } for($i = 0; $i < sizeof($a); $i++){ echo "var " . $a[$i] . "= document.getElementById('" . $a[$i] ."').value;"; } ?> It is currently just outputting 'Array' into each of the outputs. Any ideas? Thanks.
  7. Hey, i have this code: $sql = mysql_query("SELECT name FROM type") or die(0); while ($array = mysql_fetch_array($sql)) { //what goes here? } How do i get the values into an array now? something like $myarray[] = $array[]; ? Thanks for any help?
  8. Hello. I have the following code for part of an ajax fuction: var a1 = document.getElementById('1').value; var b2 = document.getElementById('2').value; var queryString = "?a1=" + a1 + "&b2=" + b2; ajaxRequest.open("GET", "updatedetails.php" + queryString, true); ajaxRequest.send(null); } //--> </script> Although the problem is that i need to be able to change the variables. for example i have 1, 2, 3 fields in my database. For example this code would work in php: while ($i <= $rowcount){ $result = mysql_query("SELECT * FROM type WHERE type_id = $i") or die(mysql_error()); $qry = mysql_fetch_array($result); echo "the variable put here"; $i = $i + 1; } Something like that, but i don't know how to get it into the javascript file. Any ideas? Thanks. P.s. The full ajax code is here: <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var MSN = document.getElementById('MSN').value; var Yahoo = document.getElementById('Yahoo').value; var queryString = "?MSN=" + MSN + "&Yahoo=" + Yahoo; ajaxRequest.open("GET", "updatedetails.php" + queryString, true); ajaxRequest.send(null); } //--> </script>
  9. Doesn't matter. I sorted it Thanks.
  10. Ah thanks. I've tried that but i'm still getting an error: Any ideas? Thanks.
  11. UPDATE user SET 1 = mymsn@hotmail.com WHERE user_id =123 MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 = mymsn@hotmail.com WHERE user_id = 123' at line 2 Any ideas why i'm getting this error? Thanks.
  12. The rest of the ajax code is: <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('ajaxDiv'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var MSN = document.getElementById('MSN').value; var Yahoo = document.getElementById('Yahoo').value; var queryString = "?MSN=" + MSN + "&Yahoo=" + Yahoo; ajaxRequest.open("GET", "updatedetails.php" + queryString, true); ajaxRequest.send(null); } //--> </script> This is run from a submit button. Thanks for any help.
  13. Hello. I have the following code for an ajax fuction: var a1 = document.getElementById('1').value; var b2 = document.getElementById('2').value; var queryString = "?a1=" + a1 + "&b2=" + b2; ajaxRequest.open("GET", "updatedetails.php" + queryString, true); ajaxRequest.send(null); } //--> </script> Although the problem is that i need to be able to change the variables. for example i have 1, 2, 3 fields in my database. For example this code would work in php: while ($i <= $rowcount){ $result = mysql_query("SELECT * FROM type WHERE type_id = $i") or die(mysql_error()); $qry = mysql_fetch_array($result); echo "the variable put here"; $i = $i + 1; } Something like that, but i don't know how to get it into the javascript file. Any ideas? Thanks.
  14. Try creating a javascript file and including it in each file using: <script type="text/javascript" src="external.js"></script> ?
  15. Hello. I am trying to get values from a database and make them into variables at the moment i have this code: $result = mysql_query("SELECT * FROM type") or die(mysql_error()); while ($qry = mysql_fetch_array($result)) { $name = $qry['name']; $$name = $_GET['$name']; } But it doesn't seem to be creating the variables with the $_GET, any ideas or advice? Thanks.
  16. Hello. I am still reasonably new to php, I have this code to create an image from certain text: <?php /* Dynamic Heading Generator By Stewart Rosenberger http://www.stewartspeak.com/headings/ This script generates PNG images of text, written in the font/size that you specify. These PNG images are passed back to the browser. Optionally, they can be cached for later use. If a cached image is found, a new image will not be generated, and the existing copy will be sent to the browser. Additional documentation on PHP's image handling capabilities can be found at http://www.php.net/image/ */ $font_file = 'font.ttf' ; $font_size = 20 ; $font_color = '#000000' ; $background_color = '#ffffff' ; $transparent_background = true ; $cache_images = true ; $cache_folder = 'cache' ; /* --------------------------------------------------------------------------- For basic usage, you should not need to edit anything below this comment. If you need to further customize this script's abilities, make sure you are familiar with PHP and its image handling capabilities. --------------------------------------------------------------------------- */ $mime_type = 'image/png' ; $extension = '.png' ; $send_buffer_size = 4096 ; // check for GD support if(!function_exists('ImageCreate')) fatal_error('Error: Server does not support PHP image generation') ; // clean up text $text = lol ; if(get_magic_quotes_gpc()) $text = stripslashes($text) ; $text = javascript_to_html($text) ; // look for cached copy, send if it exists $hash = md5(basename($font_file) . $font_size . $font_color . $background_color . $transparent_background . $text) ; $cache_filename = $cache_folder . '/' . $hash . $extension ; if($cache_images && ($file = @fopen($cache_filename,'rb'))) { header('Content-type: ' . $mime_type) ; while(!feof($file)) print(($buffer = fread($file,$send_buffer_size))) ; fclose($file) ; exit ; } // check font availability $font_found = is_readable($font_file) ; if(!$font_found) { fatal_error('Error: The server is missing the specified font.') ; } // create image $background_rgb = hex_to_rgb($background_color) ; $font_rgb = hex_to_rgb($font_color) ; $dip = get_dip($font_file,$font_size) ; $box = @ImageTTFBBox($font_size,0,$font_file,$text) ; $image = @ImageCreate(abs($box[2]-$box[0]),abs($box[5]-$dip)) ; if(!$image || !$box) { fatal_error('Error: The server could not create this heading image.') ; } // allocate colors and draw text $background_color = @ImageColorAllocate($image,$background_rgb['red'], $background_rgb['green'],$background_rgb['blue']) ; $font_color = ImageColorAllocate($image,$font_rgb['red'], $font_rgb['green'],$font_rgb['blue']) ; ImageTTFText($image,$font_size,0,-$box[0],abs($box[5]-$box[3])-$box[1], $font_color,$font_file,$text) ; // set transparency if($transparent_background) ImageColorTransparent($image,$background_color) ; header('Content-type: ' . $mime_type) ; ImagePNG($image) ; // save copy of image for cache if($cache_images) { @ImagePNG($image,$cache_filename) ; } ImageDestroy($image) ; exit ; /* try to determine the "dip" (pixels dropped below baseline) of this font for this size. */ function get_dip($font,$size) { $test_chars = 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . '1234567890' . '!@#$%^&*()\'"\\/;.,`~<>[]{}-+_-=' ; $box = @ImageTTFBBox($size,0,$font,$test_chars) ; return $box[3] ; } /* attempt to create an image containing the error message given. if this works, the image is sent to the browser. if not, an error is logged, and passed back to the browser as a 500 code instead. */ function fatal_error($message) { // send an image if(function_exists('ImageCreate')) { $width = ImageFontWidth(5) * strlen($message) + 10 ; $height = ImageFontHeight(5) + 10 ; if($image = ImageCreate($width,$height)) { $background = ImageColorAllocate($image,255,255,255) ; $text_color = ImageColorAllocate($image,0,0,0) ; ImageString($image,5,5,5,$message,$text_color) ; header('Content-type: image/png') ; ImagePNG($image) ; ImageDestroy($image) ; exit ; } } // send 500 code header("HTTP/1.0 500 Internal Server Error") ; print($message) ; exit ; } /* decode an HTML hex-code into an array of R,G, and B values. accepts these formats: (case insensitive) #ffffff, ffffff, #fff, fff */ function hex_to_rgb($hex) { // remove '#' if(substr($hex,0,1) == '#') $hex = substr($hex,1) ; // expand short form ('fff') color if(strlen($hex) == 3) { $hex = substr($hex,0,1) . substr($hex,0,1) . substr($hex,1,1) . substr($hex,1,1) . substr($hex,2,1) . substr($hex,2,1) ; } if(strlen($hex) != 6) fatal_error('Error: Invalid color "'.$hex.'"') ; // convert $rgb['red'] = hexdec(substr($hex,0,2)) ; $rgb['green'] = hexdec(substr($hex,2,2)) ; $rgb['blue'] = hexdec(substr($hex,4,2)) ; return $rgb ; } /* convert embedded, javascript unicode characters into embedded HTML entities. (e.g. '%u2018' => '&#8216;'). returns the converted string. */ function javascript_to_html($text) { $matches = null ; preg_match_all('/%u([0-9A-F]{4})/i',$text,$matches) ; if(!empty($matches)) for($i=0;$i<sizeof($matches[0]);$i++) $text = str_replace($matches[0][$i], '&#'.hexdec($matches[1][$i]).';',$text) ; return $text ; } ?> Now my question is, how can i turn this into some kind of fuction? So i can do something like converttopic(text here). Or something like that? Thanks for any advice.
  17. Hello. I have the following code for an ajax fuction: var a1 = document.getElementById('1').value; var b2 = document.getElementById('2').value; var queryString = "?a1=" + a1 + "&b2=" + b2; ajaxRequest.open("GET", "updatedetails.php" + queryString, true); ajaxRequest.send(null); } //--> </script> Although the problem is that i need to be able to change the variables. So for example, i could need a1-j10 or something like that, but this is got from the database, my question is how could i update it from my mysql database? Thanks.
  18. Hello. Right, i'm not sure how i'm going design this database and i'm looking for some advice. Basically what it needs to store are users (userid) and their contact details, eg msn, icq, aim, yahoo etc, but each one can be active or inactive for each user. Although i could just have set fields for each contact method but i want to be able to add/delete contact methods. Any suggestions/Ideas? Thanks.
  19. Ah, so it can't be included into the index.php page in any way? Thanks.
  20. fulllistxml.php: <?php header("Content-type: text/xml"); $host = "localhost"; $user = "root"; $pass = "****"; $database = "***"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT * FROM ****"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output = "<?xml-stylesheet type=\"text/xsl\" href=\"style.xsl\"?>\n"; $xml_output .= "<hotellist>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<hotel>\n"; ...etc.... index.php beginning code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Hotel Booking System</title> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" /> <script src="livesearch.js"></script> <?php include("dbconnect.php"); ?> </head> <body> <div id="header"> It is included like: <?php include("fulllistxml.php"); ?> Thanks.
×
×
  • 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.