PHP - A Strange Issue With String Length..
Similar TutorialsHowdy, I have a page on my site that displays events I have uploaded. Below is the code that displays the event title. I want to know if there is a simple way to limit the characters of the title that a view will see. For example, limiting the title to 10 characters. So, if I had an event titled "My awesome new event". You would see "My awesome..." Hope this makes sense. I'm not sure if you will need to see more of the code to help me, thank you! <a href ="event-description.php?eid=<?php echo $data->EventId?>"<span class="events-title"><?php echo $data->EventTitle ?> Hi all,
The output of the following line of code where user is Jack1234
$user = filter_input(INPUT_POST, 'user', FILTER_SANITIZE_STRING);using var_dump is string 'Jack1234' (length=8)I would like to know if there is someway we can use/retrieve the length value of the string that is displayed in the output or verify the string length against it. Thanks. I have a string in the form of "word1-word2-word3-word4-word5-word-6-word7", but I want to shorten it to 5 words only. Hi, I have a Flash contact form that sends its name, e-mail, and message variables to a PHP script. The script works fine if the message is under ~700 characters, but anything more and the script won't post the message at all. An e-mail with just the name and e-mail address will come through to my inbox (which is embarrassing as a potential client sent me a contact form e-mail about a development job ). Is there some way to check the maximum character length for a string variable? Or to set its length to something higher? This is my php. Thank you!! <? $senderName = $_POST['userName']; $senderEmail = $_POST['userEmail']; $senderMessage = $_POST['userMsg']; $senderName = stripslashes($senderName); $senderMessage = stripslashes($senderMessage); $senderMessage = strip_tags($senderMessage, '<p><br>'); $to = "kevin@kevinburkeportfolio.com"; $from = "email@kevinburkeportfolio.com"; $subject = "E-mail from $senderName"; $message = "<p><font size='2.5' face='Helvetica Neue, Helvetica, Sans Serif'><b>FROM:</b> $senderName <br><br> <b>E-MAIL:</b> <a href='mailto:$senderEmail'>$senderEmail</a> <br><br> <b>MESSAGE:</b> $senderMessage</p>"; $headers = "From: $from\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = "$to"; mail($to, $subject, $message, $headers); $my_msg = "Thanks $senderName, your message has been sent."; print "return_msg=$my_msg"; exit(); ?> Folks, I am not able to find any function that will sort an array elements by its element's length. Does such function exist? im trying to update a GPS table for example: UPDATE markers SET lat = '38.40907441955112' AND lng = '14.943452775478363' WHERE ApID = '35911' i tried with float 20,18 it isnt updatng correctly Can anyone help? the date is pulling through without a value shown in bold below. `Timesheet_start_date` >= '2011-02-10 00:00:00' AND `Timesheet_end_date` <= '1970-01-01 00:00:00' ORDER BY id DESC here is my code: Code: [Select] $smalldate = $_POST['small']; $largedate = $_POST['large']; $types[] = (isset($_POST['small']) && strlen(trim($_POST['small'])) > 0) ? "`Timesheet_start_date` >= '".date('Y-m-d',strtotime($smalldate))." 00:00:00'" : ''; $types[] = (isset($_POST['large']) && strlen(trim($_POST['large'])) > 0) ? "`Timesheet_end_date` <= '".date('Y-m-d',strtotime($largedate))." 00:00:00'" : ''; i've echo the $largedate and there is a value in there? I have been using arrays and classes for awhile. However, I am having an issue I have never had before. I am using Codeignitor. I am getting a set of results. These results are returned as a class. Then I am looking through them and displaying them in a complex set. I am having to get some additional data and add it to it. Is there a way to add an array into a class as a class? For example. I have a class: Class->0->allthedata Class->1->allthedata Class->2->allthedata Class->3->allthedata Then I get my array Array[0][allthedata] Array[1][allthedata] Array[2][allthedata] I want to add that to the class Class->4->allthedata Class->5->allthedata Class->6->allthedata I am not sure if that makes sense. Is this possible? To just add some records at te end of the class with autonumbering. So I have a simple query that adds a text record into a MySQL database table. It works great with exception of one thing. I noticed that if I have "&" symbol in my paragraph, the text after that symbol won't be inserted into the table. The text before that symbol will insert fine. It seems to be doing that only with & symbol; other symbols insert and show up fine. can anyone tell me why this is happening? Good morning, I have a wordpress theme I am using and I thought all was working well. I've noticed that when I'm not logged into admin, it doesn't show any pages for me, only white pages. When I switched back to the default TwentyTwelve theme, it worked all ok for me. Has anyone had this problem before? Thanks for your time. Kind regards, L2c Hello I am facing a rare issue while uploading videos, now the test is on .flv 7 mega and .wmv 5 mega Not Only the file is not getting uploaded, I cannot even see the tmp_name and ize is 0 I have included: ini_set("post_max_size", "10M"); ini_set("upload_max_filesize", "10M"); and <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> This is all locally on the localhost, nothing allows for uploading the video Many Thanks I know the default length of a tiny int is less than an int, but if I put in the same length for both, are they essentially the same type? having issues with Code: [Select] echo curl_setopt($ch, CURLOPT_POSTFIELDS,"name='. $name .'&email='. $email .'&macs='.$mac_addresses.'&serial=".$serialnumber); the thing is $mac_addresses is a serialized array that should look like this Code: [Select] 4a:4:{i:0;s:14:"98340234820384";i:1;s:16:"0980342883408230";i:2;s:11:"72843729374";i:3;s:16:"4209384082304980";} but when I unserilize $mac_addressed and echo it I get Code: [Select] \'.a:4:{i:0;s:14:\"98340234820384\";i:1;s:16:\"0980342883408230\";i:2;s:11:\"72843729374\";i:3;s:16:\"4209384082304980\";}.\' can anyone see what my issue is? Hi, Sorry, me again! Ok, so i've got my url: http://www.mydomain.com/?ec3_after=2010-08-01&ec3_before=2010-08-07 I've then got the following code to get the values: $afterDateParts = split("-", $_GET['ec3_after']); $after = $afterDateParts[2] . " " . $afterDateParts[1] . " " . $afterDateParts[0]; echo $after; which returns: 01 08 2010 (correct for this demo) I've then got this to convert the above into a nicer format: $convertMe = strtotime($after); echo date('d-M-Y', $convertMe); But it always returns: 01 Jan 1970 For the love of god, I cannot work out why. Is it really not that simple? Please someone put me out my misery. I'm loosing hair by the minute! Lol TIA For this example, $row2['author'] = "1" $user = 'user'.$row2['author']; if (!isset($$user)){ $result = $connector->query('SELECT * FROM users WHERE ID = '.$row2['author']); $$user = $connector->fetchArray($result); } echo '<a href="user.php?user='.($$user['ID']).'">'.$$user.'</a></p>'; The problem is it is a weird variable that also has an array, but when i use echo $$user['ID']; It errors out saying Notice: Quote Undefined variable: u So I am wondering how to word it to set the variable up properly, and how to call items in the array. Thanks in advance I've got an enormous page for a pretty complex process. I just posted some changes, and it stopped functioning. Through multiple tests, I determined there was no problem with the code; it was just becomes too large at a certain point. I've read about changing settings in the php.ini file, but I'm not exactly sure what to change or what to bump it up to to allow for this huge page. Here are some current settings that I'm guessing control this problem: Code: [Select] max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) ; Maximum size of POST data that PHP will accept. post_max_size = 8M ; Maximum allowed size for uploaded files. upload_max_filesize = 2M Does anyone have any insight into what to change or what settings might allow for a larger page? Not sure which one of these settings controls my problem. Thanks, as always, for any help. Is 40 characters long enough for an E-mail field? Debbie Hi, I am trying to make some adjustments to uploadify.php which comes with the latest version of uploadify (3.0 beta), so that it works with a session variable that stores the login username and adds it to the path for uploads. Here is uploadify.php as it currently looks: Code: [Select] <?php session_name("MyLogin"); session_start(); $targetFolder = '/songs/' . $_SESSION['name']; // Relative to the root if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath,'/') .'/'. $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('m4a','mp3','flac','ogg'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } } echo $targetFolder; ?> I added Code: [Select] echo $targetFolder; at the bottom so that I could make sure that the string returned was correct, and it is, i.e. '/songs/nick'. For some reason though, uploads are not going to the correct folder, i.e. the username folder, but instead are going to the parent folder 'songs'. The folder for username exists, with correct permissions, and when I manually enter Code: [Select] $targetFolder = '/songs/nick';all works fine. Which strikes me as rather strange. I have limited experience of using php, but wonder how if the correct string is returned by the session variable, the upload works differently than with the manually entered string. Any help would be much appreciated. It's the last issue with a website that was due to go live 2 days ago! Thanks, Nick Hey there, need some help badly. I'm trying to get the size of the BLOB data in mysql. Did a search and there are like no tutorial on this. Only relevant info was from this page, at the far bottom, it just wrote this (below code). But the writer did not explain how to use it. SELECT OCTET_LENGTH(content) FROM BloBTest WHERE filename='myimage.png' I just give it a trial an error, wrote this, but did not work. $LENGTH = mysql_query("SELECT OCTET_LENGTH(blobdata) FROM thedatabase WHERE id = 'selected_id'"); echo $LENGTH; Please help.... |