PHP - Printf Issues?
Hello, Well let me explain my problem to you guys.
I am using a printf function with an array, a custom function which i got off php.net Anyways, Everytime I use it, It seems to leave random numbers at the end of the string for no reason at all. Here is the result in source: Code: [Select] <td><a href="?page=download&name=DarkRP">DarkRP</a></td> <td>08:10:17 AM 07/08/2010</td> <td>Updated DarkRP from revision: 670 to revision: 67150</td> Array ( [Name] => DarkRP [TimeStamp] => 1281186617 [Revision1] => 670 [Revision2] => 671 ) </tr>It is mean't to show Code: [Select] Updated DarkRP from revision: 670 to revision 671but instead it has the random number 50 at the end for no reason... Anyways heres the echoing code: <?php foreach($Logs as $Log){ $Time = TimeToDate($Log['TimeStamp']); if($Log['Revision1']&$Log['Revision2']){ $Message = 'Updated %1$s from revision: %3$s to revision: %4$d'; }else{ $Message = 'Freshly downloaded: %1$s revision: %3$d'; } ?> <tr> <td><?php echo '<a href="?page=download&name='. $Log['Name'] .'">'. $Log['Name'] .'</a>'; ?></td> <td><?php echo $Time['Time'] .' '. $Time['Date']; ?></td> <td><?php echo printf_array($Message, $Log); ?></td> <?php print_r($Log); ?> </tr> <?php } ?> </table> <br /> Functions: function MySQLGetLogs(){ global $Connection; if($Connection){ $Query = sprintf('SELECT name, timestamp, revision1, revision2 FROM update_logs ORDER BY timestamp DESC;'); if($Result = mysql_query($Query)){ $Array = array(); while($Row = mysql_fetch_array($Result)){ $Array2 = array(array( 'Name' => $Row['name'], 'TimeStamp' => $Row['timestamp'], 'Revision1' => $Row['revision1'], 'Revision2' => $Row['revision2'] ) ); $Array = array_merge($Array, $Array2); } mysql_free_result($Result); return $Array; } } } function printf_array($Format, $Array) { return call_user_func_array('printf', array_merge((array)$Format, $Array)); } Also, I got the same issue with printf alone instead of the custom array function above. Similar TutorialsHi there. I am working on a calculator kind of deal. I just don't know what the printf syntax is doing to (populate) the variable(s). Also, 'how' is it doing this in the below script>? <!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=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(isset($_POST["quantity"])) $quantity = settype($_POST["quantity"], "integer"); else $quantity = 1; $item_price = 5.99; printf("%d x item = $%.2f", $quantity, $quantity * $item_price); ?> <FORM ACTION="buy.php" METHOD=POST> Update quantity: <INPUT NAME="quantity" SIZE=2 VALUE="<?php echo $quantity;?>"> <INPUT TYPE=SUBMIT VALUE="Change quantity"> </FORM> </body> </html> Quick question regarding the printf function. I understand that printf will print a formatted string for example: Code: [Select] $mystring = printf('%.1f', 1.2); //Will output 1.2 However I don't understand why if I then print $mystring the result is 3 Example: Code: [Select] $mystring = printf('%.1f', 1.2); //prints 1.2 echo "<br><br>"; echo $mystring //Prints 3 Please could someone explain how this works? Hi All,
I'm trying to return HTML page contains the Russian characters sent as POST variables and also static data as part of HTML result.
I'm not able to put it work together.
If I set windows-1251 - the static data displayed incorrectly.
If I set UTF-8 - the dynamic (POST) data displayed incorrectly
Any thoughts?
Thank you very much in advance,
Evgeny
Following is the simple HTML example and also Fiddler request example
<?php i am trying to sort out a session now, i normally use the folllowing code to check if someone is logged in and if they are not to forward them to the login page, but i am getting this message: Notice: Undefined index: username in code: Code: [Select] if ($_SESSION['username']) { }else{ include 'login.php'; die(""); } can someone help please. Issue # 1 How can i send the values come from $_POST['name'],$_POST['number'] to an email address xyz@radiations3.com??? Issue # 2 I am trying to display data from four different tables with the following sql query: (The problem is that the data is getting displayed fine but i don't know why some of the (same )data gets repeated two or three times where as i checked in all four tables and all the data exists one time not twice) If anything wrong with my query kindly help SELECT distinct * FROM applicant,applicant_info_nic,room,student WHERE applicant_info_nic.status='Available' and applicant.appNIC=applicant_info_nic.appNIC and applicant.roomID=room.roomID and applicant.appNIC=student.appNIC ORDER BY applicant.roomID Hello, I'm having troubles parsing text properly. Whenever I submit data into a mysql db, and then call that specific data, in the text, I get this symbol, �. Does anybody know what it is or how to remove it? I believe it's with utf-8 and me using a function that corrupts the string but I'm not sure. Anybody have any clues? Thanks in advance. Hey all, I can not get utf-8 working properly. I'm having issues with special characters, such as bullets, e with an accent over it, etc. The data is being stored in my mssql database properly, and I can see everything there fine. It's when I grab it from the database and display it on my php page. The page it set up to utf-8, if I go to Tools>Page Info, it says encoding is utf-8. I have it in my headers, I just can not figure out why it will not display on the page. Any thoughts? Hello, I have the following code Code: [Select] class Uploads extends Controller { public function __construct() { parent::__construct(); if (empty($_FILES)) { log_message('error', 'Uploads - files empty'); exit('No files uploaded'); } ini_set('memory_limit', '128M'); $this->load->helper('file'); $this->load->helper('helpers'); $this->load->model('uploads_model'); } public function font_handler() { $this->uploads_model->font_handler(); } } class Uploads_model extends Model { public function font_handler() { $config = array( 'max_size' => '8388', 'allowed_types' => 'ttf', 'upload_path' => 'assets/fonts/' ); $this->load->library('upload', $config); if ($this->upload->do_upload('Filedata')) { $file = $this->upload->data(); $jsFile = $file['raw_name'].'.js'; $query = $this->db->where('location', 'menuFont')->get('fonts')->row(); if ($query->customFile != '' && file_exists('assets/fonts/'.$query->customFile)) { unlink('assets/fonts/'.$query->customFile); } $path = getcwd() . '/assets/fonts/cufon/convert.php'; $command = 'php ' . $path . ' -u "U+??" ' . $file['full_path'] . ' 1> ' . getcwd() . '/assets/fonts/' . $jsFile; system($command); } } } Ok so, the ttf file is uploaded correctly and I can run $command from the command promt in putty and it works perfect, but when I try to run the same command from system() the js file just contains (from the controller) "No files uploaded" I have no idea why this is happening? Anyone have any ideas? Also one thing i'm not sure about is if it should be 1> or > when creating the js file?!? Thanks guys! Hi, I am having some major issues. My site provides sheet music available for downloading for free. When a user clicks on a sheet to download, a new window opens up. This user views our sponsor's website for 30 seconds. Once the time is up, they can download the free sheet. Now for the issues: I found a download script that I'm putting to the test. When clicking download, it asks where you want to save the file and downloads the file just fine. After some testing, i found that if the user tries to download the sheet again, my entire php/html code displays on the page, as well as a bunch of nonreadable characters (I'm guessing this is from the .pdf file that is supposed to be downloaded). I need to modify my code to stop this from happening. I've tried to exit() the code or die() after the sheet downloads, but I must be doing it wrong because nothing seems to work. I also tried a redirect to send them to a different page once they download the file. That doesn't work either. The next issue is the bottom page is supposed to display our sponsor's website, which it does. However, the frame that contains the website is not 100% in height as it is specified to be. Something in my code is causing it to stop extending all the way. If you would like to see exactly what is happening for yourself, you can go he http://www.sheetmusichaven.com/download.php?sheet=98%20Degrees-I%20Do%20Cherish%20You-SheetMusicHaven.pdf&artist=98%20Degrees&title=I%20Do%20Cherish%20You I'm using the latest version of Firefox, PHP 5. And for the code. I warn you it is ugly >< <?php session_start(); include_once('inc/connect.php'); $sheet = $_GET['sheet']; $artist = stripslashes($_GET['artist']); $title = stripslashes($_GET['title']); $hyphen = " - "; $url = "http://www.youtube.com"; $timetodownload = $_POST['timetodownload']; $todayquery = mysql_query("SELECT `todayviews` FROM `websites` WHERE `active`='yes'"); $todayresult = mysql_fetch_assoc($todayquery); $todayviews = $todayresult['todayviews']; $result = mysql_query("SELECT `url` FROM `websites` WHERE `active`='yes' && `dailyviews`>'$todayviews' && `credits`>0"); $i = 0; while($row = mysql_fetch_array($result)) { while($i<1){ $url = $row['url']; $i++; } } if(strlen($artist)+strlen($title)>80){ $artist = ""; $hyphen = ""; } $ip = $_SERVER['REMOTE_ADDR']; // Time Goes Here // $ipcheck = mysql_query("SELECT ip FROM downloading WHERE ip='$ip'"); // $ipcount = mysql_num_rows($ipcheck); // if ($ipcount!=0) // { // $error1 = "<div id='regerror'>Username already taken!</div>"; // } // $ipquery = "INSERT INTO downloading VALUES ('','$ip','$time')"; // mysql_query($ipquery); $timesdownloaded = 0; if(isset($timetodownload)&&$timesdownloaded<1){ ############################################################### # File Download 1.31 ############################################################### # Visit http://www.zubrag.com/scripts/ for updates ############################################################### # Sample call: # download.php?f=phptutorial.zip # # Sample call (browser will try to save with new file name): # download.php?f=phptutorial.zip&fc=php123tutorial.zip ############################################################### // Allow direct file download (hotlinking)? // Empty - allow hotlinking // If set to nonempty value (Example: example.com) will only allow downloads when referrer contains this text define('ALLOWED_REFERRER', ''); // Download folder, i.e. folder where you keep all files for download. // MUST end with slash (i.e. "/" ) define('BASE_DIR','admin/uploads/'); // log downloads? true/false define('LOG_DOWNLOADS',true); // log file name define('LOG_FILE','downloads.log'); // Allowed extensions list in format 'extension' => 'mime type' // If myme type is set to empty string then script will try to detect mime type // itself, which would only work if you have Mimetype or Fileinfo extensions // installed on server. $allowed_ext = array ( // archives 'zip' => 'application/zip', // documents 'pdf' => 'application/pdf', 'doc' => 'application/msword', // images 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', ); #################################################################### ### DO NOT CHANGE BELOW #################################################################### // If hotlinking not allowed then make hackers think there are some server problems if (ALLOWED_REFERRER !== '' && (!isset($_SERVER['HTTP_REFERER']) || strpos(strtoupper($_SERVER['HTTP_REFERER']),strtoupper(ALLOWED_REFERRER)) === false) ) { die("Internal server error. Please contact system administrator."); } // Make sure program execution doesn't time out // Set maximum script execution time in seconds (0 means no limit) set_time_limit(0); if (!isset($sheet) || empty($sheet)) { die("Please specify file name for download."); } // Nullbyte hack fix if (strpos($sheet, "\0") !== FALSE) die(''); // Get real file name. // Remove any path info to avoid hacking by adding relative path, etc. $fname = basename($sheet); // Check if the file exists // Check in subfolders too function find_file ($dirname, $fname, &$file_path) { $dir = opendir($dirname); while ($file = readdir($dir)) { if (empty($file_path) && $file != '.' && $file != '..') { if (is_dir($dirname.'/'.$file)) { find_file($dirname.'/'.$file, $fname, $file_path); } else { if (file_exists($dirname.'/'.$fname)) { $file_path = $dirname.'/'.$fname; return; } } } } } // find_file // get full file path (including subfolders) $file_path = ''; find_file(BASE_DIR, $fname, $file_path); if (!is_file($file_path)) { die("File does not exist. Make sure you specified correct file name."); } // file size in bytes $fsize = filesize($file_path); // file extension $fext = strtolower(substr(strrchr($fname,"."),1)); // check if allowed extension if (!array_key_exists($fext, $allowed_ext)) { die("Not allowed file type."); } // get mime type if ($allowed_ext[$fext] == '') { $mtype = ''; // mime type is not set, get from server settings if (function_exists('mime_content_type')) { $mtype = mime_content_type($file_path); } else if (function_exists('finfo_file')) { $finfo = finfo_open(FILEINFO_MIME); // return mime type $mtype = finfo_file($finfo, $file_path); finfo_close($finfo); } if ($mtype == '') { $mtype = "application/force-download"; } } else { // get mime type defined by admin $mtype = $allowed_ext[$fext]; } // Browser will try to save file with this filename, regardless original filename. // You can override it if needed. if (!isset($_GET['fc']) || empty($_GET['fc'])) { $asfname = $fname; } else { // remove some bad chars $asfname = str_replace(array('"',"'",'\\','/'), '', $_GET['fc']); if ($asfname === '') $asfname = 'NoName'; } // set headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: $mtype"); header("Content-Disposition: attachment; filename=\"$asfname\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); // download // @readfile($file_path); $file = @fopen($file_path,"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } // log downloads if (!LOG_DOWNLOADS) die(); $f = @fopen(LOG_FILE, 'a+'); if ($f) { @fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n"); @fclose($f); } $timesdownloaded++; if(isset($timetodownload)==($_POST['timetodownload'])){ $timetodownload = ""; echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php?letter=0\">"; } if($timesdownloaded>0){ header("Location: index.php"); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="Free Piano Sheet Music - Sheet Music Haven" /> <meta name="keywords" content="free,piano,sheet,music,download,keyboard,haven,lyrics,notes,chords,score,top,modern,popular,jazz,classical,sheetmusichaven" /> <meta name="author" content="Sheet Music Haven - Free Piano Sheet Music. Download all types of piano sheet music for free. Popular sheets are added often" /> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> <title>Downloading <?php echo $sheet; ?> - Sheet Music Haven</title> <link rel="stylesheet" type="text/css" href="styles/style.css" /> <style> iframe { padding: 0px; spacing: 0px; } body{ margin: 0px; color: #000000; } #bggreen{ width: 99%; height: 88%; background-color: #6aa504; margin-left: auto; margin-right: auto; text-align: center; } #countdown{ color: #4296ce; font-size: 18px; } .sheetbar a{color: #000000; font-family: "Arial", Helvetica, sans-serif; } #logo{ position: relative; width: 320px; height: 65px; text-align: center; float: left; top: 19px; } #timer{ position: relative; width: 65%; height: 59px; float: left; text-align: center; top: 3px; background-color: #ececec; border-style: solid; border-color: #93DB70; } </style> <script type="text/javascript"> var time = 2; function startCountdown(){ var t = setTimeout("countdown()", 1000); } function countdown(){ var sHeet = "<?php echo $sheet;?>"; var artist = "<?php echo $artist;?>"; var tItle = "<?php echo $title;?>"; --time; if(time == 0){ document.getElementById("countdown").innerHTML = "<form action='download.php?sheet=<?php echo $sheet; ?>' method='POST'><input type='image' src='img/download.png' alt='Download' name='timetodownload' value='Download'><\/form>"; }else{ document.getElementById("countdown").innerHTML = time; var t = setTimeout('countdown()', 1000); } } </script> </head> <body onload="startCountdown();" bgcolor="#343331"> <table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"> <?php echo "<tr><td style='background:#343331;height:80px;border-bottom:#aaaaaa solid 2px;'>"; echo "<div id='bggreen' class='sheetbar'> <div id='logo'><a href='index.php'><img src='img/logosmall.png'></a><br /> <a href='suggestions.php' style='color: #ececec; font-size: 14px;'>Report Errors</a></div> <div id='timer'> It is our sponsor's that keep this website running. Please view their website while you wait for:<br /> <span style='color: #6aa504;'>".ucwords($artist).$hyphen.ucwords($title)."</span> <br /> <div id='countdown'>2</div> </div> </div>".$error; echo "</td></tr>"; ?> <tr><td> <iframe src="<?php echo $url;?>" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0"> <p>Your browser does not support iframes.</p> </iframe> </td></tr> </table> </body> </html> Hey guys, I wrote a function called isServer() so I can quickly move files from my local machine to my server without modifying too much. The function is as follows: function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() I have placed this function in a system.php file I created that is used to simply to keep things in order. That files contents a <?php session_start(); function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() include "configuration.php"; include "functions.php"; include "functions_sql.php"; include "functions_soap.php"; include "functions_mail.php"; if (isProductionServer()) { $dbhost = 'db'; $dbuser = 'db_user'; $dbpass = 'pass123'; } else { $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; } $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'my_database'; mysql_select_db($dbname) or die ('Selected database does not exist'); ?> The problem I am having is for some reason none of the include files are recognizing the function. For example, the functions_mail.php file references the function to determine which emails to send (because the different environments have different modules and such installed). I know this is something easy, but I can't seem to figure it out. Thanks for any help! Hey guys im having a real problem trying to make this string happend the problem is passing parameters on the javascript function "onmouseover" $map_array .= "<a href='map.php?planet=$address' onmouseover='ajax_popup ($picture,$detail_name,$stargate_address,$detail_owner,$time_conquered,$time_offset,$detail_siege, $alliance)'> <img src='images/star.jpg' style='position:absolute; left:".$b_x."px; top:".$b_y."px; border-style:solid; border-color: yellow;'></a>"; if I try this it works onmouseover='ajax_popup(1,2,3,4,5,6,7,8)'> So the problem is when the variables equal words. Cause of the quote issue. Is there like a way i should be using JSON to do what im trying to do? I have to keep this as a php string too. Or end as a php string Hey, I'm editting some code on an OS Commerce install, For some reason I dont get the various buttons displaying. Underneath the shopping basket, it is supposed to show a view cart button and a checkout button, but they dont show up. I'm also trying to edit it to use a layout of the stylesheet, Basically if you look at my website, you will see the categories list, these are generated by an <ul><li> code, which puts the background underneath the item name, I would like to do the same thing and limit the charactors in the name to say 50 (so they stay on one line) Can you point me in the right direction to set an <li> on each item in the cart, and change it to UCWORDS, and restrict the charactors please? Any ideas on why the images dont show up on the page? http://tinyurl.com/2f6g2lg This is my code. <?php /* $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ ?> <!-- shopping_cart //--> <?php // $info_box_contents = array(); // $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART); // new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART)); $cart_contents_string = ''; if ($cart->count_contents() > 0) { $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">'; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { $cart_contents_string .= '<span class="newItemInCart">'; } else { $cart_contents_string .= '<span class="infoBoxContents">'; } $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>'; if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) { tep_session_unregister('new_products_id_in_cart'); } } $cart_contents_string .= '</table>'; } else { $cart_contents_string .= BOX_SHOPPING_CART_EMPTY; } $info_box_contents = array(); $info_box_contents[] = array('text' => $cart_contents_string); if ($cart->count_contents() > 0) { $info_box_contents[] = array('text' => tep_draw_separator()); $info_box_contents[] = array('align' => 'right', 'text' => $currencies->format($cart->show_total()) ); //cart buttons start $info_box_contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image_button ('button_cart_view.gif', IMAGE_BUTTON_CART_VIEW) . '</a>' . '<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING) . '">' . tep_image_button ('button_cart_checkout.gif', IMAGE_BUTTON_CART_CHECKOUT) . '</a>' ); //cart buttons end } new infoBox($info_box_contents); ?> <!-- shopping_cart_eof //--> Hi, I'm trying to convert a charting app to OOP. So here I've simplified it down to just the bare bones issue of drawing a line to a png image and displaying it. Code: [Select] <?php class chart { var $im; var $backgroundColor; var $textColor; function chart() { $this->im= @ImageCreate (100, 200) or die ("Cannot Initialize new GD image stream"); $this->backgroundColor = ImageColorAllocate ($this->im, 224, 234, 234); $this->textColor = ImageColorAllocate($this->im, 233, 14, 91); } function display() { imageline ($this->im,0,0,100,200,$this->backgroundColor); imageline ($this->im,100,0,0,200,$this->textColor); ImagePng ($this->im); } } ?> Here is the code which instantiates the class. Code: [Select] <?php include "simple_draw.php"; $mychart = new chart(); $mychart->chart(); $mychart->display(); ?> Basically depending on how I rework it, one of two things happens: a)it generates a bunch of little boxes which say fffd, or b) I get a message saying the resource is invalid or nonexistent (this error isn't coming up right now so I can't be precise.) If this is run outside the OOP environment it works fine. No sure. I'm really trying to work with classes but this kind of problem is frustrating and admittedly makes it tempting to just go back to regular functions. Any ideas?? Thanks, Jeff As far as it goes for me I have the switch() working, but not to what im trying to do. This is for a "media" page where I have 3 different categories "Music", "Videos" and "Photos". I'm trying to get it so when you goto the "Media" page it will show just the 3 categories, that section works but it is also showing the sub categories for all them categories. So for what im trying to do is when viewing the "media" page, it will display the 3 categories, then when selecting the category it will display the "sub categories". and then when you select the "sub category" it will display the contents of that "sub category" should i be trying to do this a different way? or do i have something wrong here? lol here is my switch() code Code: [Select] <?php $cat = (isset($_GET["m_cat"])) ? (intval($_GET["m_cat"])) : 0; switch($_GET["b"]=="true") { default : if("/ffy/media.php"==$_SERVER['PHP_SELF']) { echo "Select a Category"; } case "false": if($_GET["m_cat"]==$cat) { echo "<font size='3'>"; $dcat = mysql_query("SELECT * FROM media_sub_cat WHERE m_cat=$cat") or die("mySQL Query Failed: " .mysql_error()); while($catrow = mysql_fetch_array($dcat)) { list($id, $m_sub_cat, $m_cat) = $catrow; echo ": <font class='myFont'><a href='media.php?b=true&cat=".$m_cat."&subcat=".$m_sub_cat."'>".$m_sub_cat."</a></font> "; } echo ":</font>"; echo "Work Damb You"; } break; case "true": if($_GET["cat"]==$cat && $_GET["subcat"]==$m_sub_cat) { echo "Weird..."; } break; } ?> i am trying to let users download images, but it seems to only be working for only a png image. i've tried .txt, word, and mp3. here is my code for getting the path of the file: // get full file path (including subfolders) $file_path = $fileName; find_file(BASE_DIR, $fname, $file_path); if (!is_file($file_path)) { die("File does not exist. Make sure you specified correct file name."); } these other files that i am getting, are in the same folder as the image. the error that i am getting, is "File does not exist. Make sure you specified correct file name." here are the allowed extensions of the files: Code: [Select] $allowed_ext = array ( // archives 'zip' => 'application/zip', // documents 'pdf' => 'application/pdf', 'doc' => 'application/msword', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', // executables 'exe' => 'application/octet-stream', // images 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', // audio 'mp3' => 'audio/mpeg', 'wav' => 'audio/x-wav', // video 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mov' => 'video/quicktime', 'avi' => 'video/x-msvideo' ); Hey I'm having issues with using strtotime(), date(), and time(). I have a couple problems. The first is: I used strtotime to get the unix of a specific date and time (worked great, even outputted the correct time using date() to return it). However when I went to post information on it (I set it up so that you can't post after the event started), it told me it already started like an hour before it was supposed to. I used Code: [Select] if (time() > $event['when']) { echo "too late."; } else { do it } to determine. That had me very confused. Then I decided instead of manually inputting the event times I would pull them from an xml file, which I had no trouble reading. I used: Code: [Select] strtotime("Next $day, $time PM") with $day = Sun, $time = 1:00- This outputted a unix timestamp but then date() returned it as being 7 pm on sunday instead. Any ideas what would be causing these strange things? Ok guys first off I am a amateur porn star and having coding issues. I am on a web-server and personally have not issues when I test my contact page. However if anyone else test the site it never comes through? The code is broken into two php pages and I have just posted the second page for review. If anyone can shed light on this I would be greatly appreciated!! I do know there are some missing stuff in the verified section but that will not affect it going through the mail.....lol <h3 align="center"><?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "info@elaysmith.com"; $email_subject = "Pick 3 Special"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['email']) || !isset($_POST['vid1']) || !isset($_POST['vid2']) || !isset($_POST['vid3'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $email_from = $_POST['email']; // required $vid1 = $_POST['vid1']; // required $vid2 = $_POST['vid2']; // required $vid3 = $_POST['vid3']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Video 1: $vid1 \n"; $email_message .= "Video 2: $vid2 \n"; $email_message .= "Video 3: $vid3 \n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for using my pick 3 Special <?php Hi all, I am desperately in need of some help here. I have been troubleshooting these codes for days, and I have posted this similar question quite a couple of times, and there is no answer from anyone... I am really in a bad shape now. Could someone please enlighten me to my problem? I have created 2 while loops...apparently the 2nd while loop overwrites the 1st while loop record. Meaning to say...1st while loop generates values of 'Math' 'Eng' 'Chi' 'Sci' AND store it in $subject_data, createLevelCheckboxes($subject_data, $level_data, 5); Apparently, the 2nd while loop takes only the last record 'Sci' from $subject_data and continues the looping. Which gives me results like Level 1 Sci Level2 Sci Level3 Sci I would like to attain something like.... Level 1 Math Level2 Eng Level3 Chi Level4 Sci Is there any reset which I need to do? while($data = mysqli_fetch_array($sql)) { if($current_level_id != $data['level_id']) { $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); $current_level_id = $data['level_id']; $subject_data = array(); } //Add the current record to the $level_data array $subject_data[] = $data; } while($data1 = mysqli_fetch_array($sql1)) //Iterate throug the DB results { $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); $level_data = array(); $level_data[] = $data1; } $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); I have an XML document that id decrypted and shown onto a table. At the bottom of the page, I'm trying to have it count up one Code: [Select] foreach($Data as $Types) // loop through book foreach($Types as $Colors) // loop through book { print_r(count($Colors->Color)); } There are 4 colors, blue, green, red, yellow. Blue is listed 7 times, green is 3, red is 8, and yellow is 4 times. What I expect it to print is: 7 3 8 4 Instead, it's printing this: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 If I was to just do the print function without count, it lists like this: blue red blue red green yellow blue red yellow red red green yellow yellow blue blue green blue yellow blue red red blue red My end-goal of this code is to get it to print this: Blue: 7 Green: 3 Red: 8 Yellow: 4 I'm trying to run this: Code: [Select] <?php ini_set('max_execution_time','3600'); ini_set('memory_limit','512M'); ini_set('upload_max_filesize','100M'); ini_set('post_max_size','100M'); phpinfo(); ?> Max execution time and memory_limit works but upload_max_filesize and post_max_size don't work. Are you allowed to set those at run time? |