PHP - Forcing Title Of Output Files In Uppercase...
Hi
I have this script that saves data to a file, I was wondering how I can make the script write the title of the files in uppercase letters? I am new to coding mind I think is the relevent code: Code: [Select] foreach(array('daily','weekly','monthly') as $value) { $fp = fopen(DIR.$value.'_'.strtolower(str_replace('/', '', $data[$ccyValue][0])).'.csv', 'w'); if($fp) { $raw_data = array(${$value.'Pivot'}, ${$value.'_s1'}, ${$value.'_s2'}, ${$value.'_s3'}, ${$value.'_r1'}, ${$value.'_r2'}, ${$value.'_r3'}); $write_data = "Pivot, S1, S2, S3, R1, R2, R3\n"; $write_data .= implode(',', $raw_data); fwrite($fp,$write_data); fclose($fp); } else { die('Please make sure result folder is present or writable!'); } } } Thanks Antony Similar TutorialsI have the two files below and want to separate php and html. How do I output forum.html with forum_post.html in it? I want to post as many forum_post.html as mysql_num_rows() says. Code: [Select] forum.html ====== <div> <form method="post"> <textarea name="text"></textarea> <input type="submit" /> </form> </div> <div> [b]???[/b] </div> Code: [Select] forum_post.html ====== <div> <h1>Title</h1> <p>Text</p> </div> Hi, how do I output the total files in a given directory? Here is code I cannot get to work: Code: [Select] <?php $file=fopen('C:\\dir\\folder\\proj_ath\\', 'a+'); for($i=0;$i<count($file);$i++) { print "tot files so far: $i <br />"; } ?> Any help much appreciated! trying to create a simpleprogram that will read a text file and output information and calculations using the data in the text file. I have 4 radio buttons which represent an item Number. when one is selected the output form should print to a table the ID,Part,Count, Price, and the inventory Value= ($count * $price), can anyone tell me what i am doing wrong? This is what the .txt file looks like: AC1000:Hammers:122:12.50 AC1001:Wrenches:5:5.00 AC1002:Handsaws:10:10.00 AC1003:Screwdrivers:222:3.00 Here's what i have so far: Code: [Select] <?php $inf = 'infile.txt'; $FILEH = fopen($inf, 'r') or die ("Cannot open $inf"); $inline = fgets($FILEH,4096); $found = 0; //$ptno = //if (isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000']) || isset($_POST['AC1000'])) { while (!feof($FILEH) && !($found)){ list($ptno,$ptname,$num,$price) = split (':', $inline); if ($ptno == $id) { print '<table border=1>'; print '<th> ID <th> Part <th> Count <th> Price'; print "<tr><td> $ptno </td><td>$ptname</td>"; print "<td> $num </td><td> \$price</td><tr>"; print '</table>'; $found = 1; } $inline = fgets($FILEH,4096); } if ($found !=1) { print "Error: PartNo=$id not found"; } fclose ($FILEH); ?> Problem - application produces MD5 PWs which are uppercase, code checks lowercase. Question- How to use uppercase check? Code: [Select] function checkPwd($x,$y) { //Checks if strings are empty if(empty($x) || empty($y) ) { //Strings were empty return false; } else if(strlen($x) < 4 || strlen($y) < 4) { //String length too short return false; } else if(strcmp($x,$y) != 0) { //Strings do not match return false; } else { //Password Determined valid return true; } } Question 2: Do I have to change it anywhere else, like PW generation? Code: [Select] function GenPwd($length = 7) { $password = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; //no vowels $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function GenKey($length = 7) { $password = ""; $possible = "0123456789abcdefghijkmnopqrstuvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } Thank you for reading Hi Friends, I am Anes I want to ensure all surnames are uppercase in php I use $surname = ucfirst(strtolower($dataField)); How do I ensure that any names such as O'Brien, don't result in O'brien thanks Hello: I have this little bit of code to pull all the towns and zip codes from a mySQL database: Code: [Select] <?php $result = mysql_query("SELECT zip_id,city,abbr_state,full_state,zip FROM zip_codes WHERE abbr_state = '" . mysql_real_escape_string ( $_GET['abbr_state'] ) . "' ORDER BY `city` ASC"); while($row = mysql_fetch_array($result)) { echo "<a href=\"Stores.php?zip_id=".$row['zip_id']."\" title=\"My Products ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']." | My Items ". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."\">". $row['city']. ", ". $row['abbr_state']." ". $row['zip']."</a>"; echo "<div style=\"clear: both; margin-bottom: 15px;\"></div>"; } ?> Works fine (unless some can offer a way to "improve" the code). However, all of the City Names ($row['city']) were put into the database as ALL CAPITALS, which is a bit harder on the eyes to read. Is there a "PHP way" - working with the code I posted - that will transform the ALL CAPITALS to a more readable Capitalize (in other words, Capitalize just the first letter of each town). I know that CSS offers "text-transform" and if that is a solution I'm fine with that. I just need it to display that way, not re-write it in the database. Ideas? Solution? Thanks! Our professor in PHP Programming is very choosy that he requires us to verify if the user enter the UPPERCASE format of the user name registered the program will show an invalid user. What he's trying to say is the user must enter a 100% identical to the username he registered. If the username registered is LOWERCASE he must enter a LOWERCASE username if the username registered is UPPERCASE he must enter an UPPERCASE username to LOGIN. Okay so after echoing awardType it says Match which would mean it would go to the else part of the statement but it doesn't. It still shows the dropdown for the characters and don't know why? Code: [Select] <?php require ('php/awardsshowNom.php'); ?> <script type="text/javascript" src="forms/edit/js/awardsshowNom.js"></script> <!-- Form --> <form action="#" id="awardsshowNomForm" > <fieldset> <legend>Edit Award Nominations</legend> <?php echo $awardType; ?> <?php if ($awardType = 'Singular') { ?> <div class="field required"> <label for="nominees">Nominees</label> <select class="dropdown" name="charactersDrop" id="charactersDrop" title="Characters Drop"> <option value="">- Select -</option> <?php while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { print "<option value=\"".$row['ID']."\">".$row['characterName']."</option>\r"; } ?> </select> <input type="button" value="Add Character" class="" onclick="HandlerCharacters()"/> <ul id="characterList"> </ul> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <? } else { ?> <div class="field required"> <label for="nominees">Nominees</label> <select class="dropdown" name="events" id="events" title="Events for <?php echo date("Y") ?>"> <option value="">- Select -</option> <?php while ( $row = mysqli_fetch_array ( $matchResult, MYSQL_ASSOC ) ) { print "<option value=\"".$row['ID']."\">".$row['segmentTitle']."</option>\r"; } ?> </select> <input type="button" value="Add Match" class="" onclick="AddMatch()"/> <ul id="matchList"> </ul> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <?php } ?> <input type="hidden" name="awardID" id="awardID" value="<?php echo $awardID; ?>" /> <input type="hidden" name="awardShowID" id="awardShowID" value="<?php echo $awardShowID; ?>" /> <input type="hidden" name="awardName" id="awardName" value="<?php echo $awardName; ?>" /> <input type="submit" class="submit" name="editAwardNom" id="editAwardNom" title="Edit Award Nominees" value="Edit Awards Nominees"/> </fieldset> </form> <!-- /Form --> <!-- Messages --> <div class="message message-error"> <h6>Required field missing</h6> <p>Please fill in all required fields. </p> </div> <div class="message message-success"> <h6>Operation succesful</h6> <p>Arena was added to the database.</p> </div> <!-- /Messages --> Hey there, I currently have a banning system on my site that doesn't allow users to login with the banned account. But the cookies are set to remember them for a year. How can I destroy their cookie, so that they don't stay logged in and continue to use the site? Hi, I have a video site with a lot of content hosted. I recently shifted to a CDN solution. The problem now is that I cannot force user to download the file. The files just open in the browser window. When the user clicks on download, I just use header ("location: http://cndserver/file.mov"); What can I do to force download a file stored on a remote server? Any help is appreciated. Thanks in advance. Well I have a script that executes a scan on a system set to run infinitely, and I need it to echo out a message each time it loops through, but I don't want it to echo out the message with the next loop message below it, and the next one below that etc... I've tried using the flush(); function and been messing around with that with no luck. For security reasons I don't want to release any of the processing code, but here is the basic construction of the script: <?PHP ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $RepeatIt = -1; for($g=1; $g!=$RepeatIt+1; $g++) { ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** $ScanMessage = ":.:.: SCANNING THE HITLIST FOR MOBSTER: ".$MobName." (SCAN #$g) :.:.:"."<br/><br/>"; echo $ScanMessage; ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** ***PROCESSING AND SCAN CODE*** } ?> At the moment it's returning: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #1) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #2) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #3) :.:.: :.:.: SCANNING THE HITLIST FOR MOBSTER: DEUS EX DESTROYER (SCAN #4) :.:.: So what I want it to do is just delete the scanning message and replace it with the next scan message so while running this script you would see just the number increment on the same line. Any suggestions? Thanks. Hello I have a simple question about file handling... Is it possible to list all files in directories / subdirectories, and then read ALL files in those dirs, and put the content of their file into an array? Like this: array: [SomePath/test.php] = "All In this php file is being read by a new smart function!"; [SomePath/Weird/hello.txt = "Hello world. This is me and im just trying to get some help!";and so on, until no further files exists in that rootdir. All my attempts went totally crazy and none of them works... therefore i need to ask you for help. Do you have any ideas how to do this? If so, how can I be able to do it? Thanks in Advance, pros So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png fileĀ which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? Good evening -- My script takes a while to execute as it processes records from the db. I'd like to have it print out to the screen the record id # as it processess each record, just to let me know where it is. Currently, the program waits till the end and then prints out the record numbers, which is no help. How can I enable PHP to print out each record number as it goes along? Thanks! I am using WPSQT plugin in my blog site .I code some files in PHP also.how to add that files in plugin files.
I've tried mysql_error(), yet nothing is displayed, but I'm pretty sure it may be something wrong with my query. After someone inputs their new information, site title in the database is changed to 0, and description isn't updated at all.., but it's still the same data as before and isn't changed. if(!$_POST['title'] || !$_POST['description']) { echo " <table><form action='account.php' method='POST'> <input type='hidden' name='edit' value='1'> <tr><td>Site Name</td><td><input type='text' name='title' value='". $grab['title'] ."'></td></tr> <tr><td>Site Description</td><td><textarea name='description' rows='18' cols='40' maxlength='550'>". $grab['description'] ."</textarea></td></tr> <tr><td>Finished?</td><td><input type='submit' value='Update Information'></td></tr> </form></table>"; } else { $title = mysql_real_escape_string(strip_tags($_POST['title'])); $description = mysql_real_escape_string($_POST['description']); $to_censor = array("fag", "ass", "asshole", "douchebag", "dumbass"); $new = str_replace($to_censor, "****", $description); $description = strip_tags($new, "<b><i><a>"); mysql_query("UPDATE sites SET title = '$title' AND description = '$description' WHERE username = '". $_SESSION['user'] ."'") or die(mysql_error()); echo "Updated information successfully. <a href='account.php'>Back to My Account</a>"; } Hi guys, this is my problem. I use wordpress and i have diffrent titles for every post. The php code for the title is <?php the_title(); ?> I want to add my title after this url: http://search.msn.com/results.aspx?format=rss&FORM=RSRE&q= That means if i have a post with this title: php tutorials The url should be like this: http://search.msn.com/results.aspx?format=rss&FORM=RSRE&q=php+tutorials This is the part of my php code that contains the url: <?php $url="http://search.msn.com/results.aspx?format=rss&FORM=RSRE&q=php+tutorials"; $rss=new rssFeed($url); I tried this already but it is not working: <?php $url="http://search.msn.com/results.aspx?format=rss&FORM=RSRE&q=<?php the_title(); ?>"; $rss=new rssFeed($url); Sorry, i hope you understand what i mean. Code: [Select] Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."'title='.info['username']'"."' width='50' height='50'>"; im trying display the user's, username in the title when the mouse hovers over the img it displays the username of that image. no errors just displays .info as title thanks [/code] Hello, I am assigned a task to make alterations on a client website. The header is an include on all pages. Inside the header is the title tag which propogate to all pages. I want title different to each page, I will also add description and keyword. Is there a way to do this with PHP or should I have different header for each page. thank you |