PHP - Using Strings In Cookies?
Hi
I am having troubles using a string in a cookie.. This doesnt work: setcookie("background", "$image_name", $expire, "/", ".gedoo.com"); Neither does this: setcookie("background", "" . $image_name . "", $expire, "/", ".gedoo.com"); If I write something before $image_name like: setcookie("background", "hello" . $image_name . "", $expire, "/", ".gedoo.com"); It will save "hello" in the cookie.. So in other words, $image_name doesnt look like it is defined.. But the funny thing is that this works on the same page: echo "File Uploaded Successfully!<br><img src='images/$image_name'>"; Anyone have any idea on what I am doing wrong? Similar Tutorialshello, here is what i have, obviosly it doesnt work. Code: [Select] $year=$_POST['y']; $yr=substr($year,-2); $mth=$_POST['m']; $init=$_POST['initial']; $jobnumber=$yr$mth2343$init; echo "$jobnumber"; P.S. thanks to everybody for their help lately! I was thinking how can I make a script that will build strings incrementing through each letter starting with "a" and ending with "zzzzzz" or what ever ending length I want such as 12. So if your were to output everything, you could find the words: "dog" "spider" "superman" "hippo" etc What would be the best way to do this, so I don't have to have a loop that is 500 blocks deep to show a word that is 500 letters example Quote a ... z aa ab ac ... az ba bb bc ... ... aaa aab aac Hey guys!! So basically what I am doing here is pulling the directory out of a url. URL ex: http://www.xxx.com/T...IS_WHAT_I_WANT/ Hello, I was wondering if someone could help me to "get" the webaddress of a current webpage and then pull off pieces of the page. All of my pages look like: http://localhost:8888/algebra_book/Chapters/Quadratic_Functions/introductory_problem.php BUT, the stuff to the left of Quadratic Functions WILL change in the future. So all will look like: *Quadratic_Functions/introductory_problem.php Then, I'd like to pull off a $chapter variable, which in this case is Quadratic_Functions and a $page_name variable which in this case will be introductory_problem. Thanks so much. Not sure if there is a better way to do this, but I want to check whether the value in a Sticky Field is the same as what is in the Database. If what is in the Sticky Field is *exactly* what is in the Database, then the User didn't update that field, and so I would NOT do an UPDATE. Seem reasonable? Here is where I grab the value out of the Form... Code: [Select] // **************************** // Process Each Form Field. * // **************************** foreach($_POST['answerArray'] as $questionID => $response){ // Copy trimmed Form array to PHP array. $answerArray[$questionID] = trim($response); And here is where I grab the existing value in the Database... Code: [Select] // ******************** // Check for Answer. * // ******************** // Build query. $q1 = "SELECT response FROM bio_answer WHERE member_id=? AND question_id=?"; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variable to query. mysqli_stmt_bind_param($stmt1, 'ii', $memberID, $questionID); // Execute query. mysqli_stmt_execute($stmt1); // Store results. mysqli_stmt_store_result($stmt1); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt1)==1){ // Answer Found. // Bind result-set to variable. mysqli_stmt_bind_result($stmt1, $currResponse); // Fetch record. mysqli_stmt_fetch($stmt1); So I guess I want to compare $answerArray[$questionID] against $currResponse and see if there are any differences?! What is the best way to do that? Any better ideas of how to check to see if the User made any changes to a field so I only do an UPDATE if there was actually a change? Thanks, Debbie is there a way I can make something like a ticket in pdf format that can have $name or the likes echo in it? if you could help get me started, that would be great! How can i break down strings for example i have a simple search database for products where as a user searches a term this can be one, two three words and so on. I'm using a wildcard; but i want the best way to get the possible search so i would like to break down the string into separate words and then use that to search the database using wildcards is this possible? Thanks for reading. I am trying to make a little script that allows a user to search for blocks of text within strings. The user enters data into form fields and he or she can enter text into another form field (needle) to search the data fields (haystack). When the search string matches something in the data fields the associated data fields are highlighted in a yellow background color. Right now the search string is acting funny. When I enter a search string I get no highlighting unless if the first character(s) of the search string are the same as the first character(s) for the items. For instance, If I search for the text "at" in the word "bat" I will not get any yellow highlighting. But I would get highlighting for "bat" if I search for "ba." How would I change the code so that any data field is highlighted if the search string exists anywhere in the text for the data field? Also, I figured out how to stop the form fields from being yellow if they and the search field are empty/NULL, but I did this part in another file (as an IF statement) and can't seem to get it to work in the other file. How would I make it do the highlighting if and only if there is a search string in the search field (i. e. only highlighting when the search field is not NULL/empty). The code from my 2 files is here...: http://pastie.org/1095526 , http://pastie.org/1095528 Thanks very much to anyone who can help me. I have a php page which is ran after a form is posted from the previous page. I am having trouble getting the SQL strings to work. When the page is ran online there is no WSOD or error message but the tables in my database are not being updated. Any help with this would be greatly appreciated.
Attached Files
payment.php 1.79KB
4 downloads Hmm, not quite sure how to do this one... If i have lots of strings saved in a mysql table and one was... "A man and a dog took a nice walk in the park" If a user then wanted to input another string into the table, but i wanted to check the new string was at least 5% different to all other in the table, how would i about doing this? Is it possible to do this via mysql, or would i have to pull out all the strings into a php array and process it that way... somehow? Hi there, In my attached PHP script, I extract text between two strings in the input file and write the extracted text to an output file. Everything seems to work fine, except I can't figure out how to include the row that says "Richland" (after the row that says "Creighton") in the extracted text. If someone could guide me how to do this, I'd greatly appreciate it. The PHP script is attached. The input file is in htm format and I can't attach that here so I will provide a link to the file I'm calling: http://www.afws.net/data/pa/savedata/109/06/2009060920.pa.htm Many thanks!!! how do i limit this textfield to three strings? Code: [Select] <input type='text' size='40' name='search' style='font-size:16px; font-family:Arial;font-weight:bold;' /> is this php or javascript? i want only three strings to be allowed entered. This is the full error: Fatal error: [] operator not supported for strings in D:\Programs\AppServ\www\test\test.php on line 19 I have comented on the error line. function structure(){ $argNum = func_get_args(); $temp = $argNum; (int)$pointer = -1; $xmlStructure = array(); foreach ($temp as $key => $value) { if ($value == 'in') { if ($pointer == -1) { $pointer = 0; } else{ $pointer = $pointer + 1; } }elseif ($value == 'out') { $pointer = $pointer - 1; }; if($pointer != -1){ $xmlStructure[$pointer][] = $value; //THIS is the 19'th line. }else{ $xmlStructure[] = $value; } } return $xmlStructure; } function test_print($item2, $key) { echo "$key. $item2<br />\n"; } $a = structure('0','in','00','01','02'); array_walk($a,'test_print'); I've got a file with some strings that have both types of quotes in them. And I seem to have managed to get the data, display it in my html, store it in a js array (using a json_encode in php and then simply inserting it into my js) but I cannot seem to pass the string as a parameter form an onclick function call to js.
For most strings the addslashes makes it work in the function call. But for those with both sets of quotes it won't work. My console tells me there are "unterminated string constants..". I've experimented with many silly changes but none make it work.
Ex. of the strings:
What do you mean "It's crooked"?
Of course I could remove the contraction and that would probably work, but that would be a hack, would not it?
Good day all.
I am trying to get strings from txt file with a start and an end.
$file = "/var/www/html/sataxicrm/custom/include/language/lang.en_us.lists.php"; $content = file_get_contents($file); $pos = strpos($content,"query_complaint_type_list"); $end = strpos($content,"status_0"); $string = substr($content,$pos,($end- $pos)); $array = nl2br($string); //print $content; echo "Database Value:Label Value <br>"; print $array;
The above code works well if you knowwhat your end string is, but in my case i do not know. i only know the start. As you can see i know it starts with account_type_dom but i do not know that it will end before industry_dom. so i need to stop before industry_dom. how do i do this? Quote
account_type_dom
Hello, I'm working on a script for my chat software that will convert an array into a string and then can easily later on be put back into an array, I've already done this but when I did it I didn't think of sub-arrays. For example of an array: Code: [Select] $user_info = array( 'username' => 'test', 'other_info' => array( 'var' => 'value', 'var2' => 'value2' ) ); and that would change into something like this: user_info:{username:test, other_info:{var:value,var2:value2}} I do not care what the string looks like, above was just an example, any separators can be used. I just can't have it messed up by user input (a username with a character of a separator or something). The code I have works for this: Code: [Select] $user_info = array('id' => 1, 'username' => 2); and it outputs this as the string id=1&username=2& The code I use is: Code: [Select] function strtoarray($str) { $info = explode("&", $str); if (is_array($info)) foreach ($info as $data) { $data = explode("=", $data); if (is_array($data)) { if (!empty($data[0])) { if ($array[$data[0]]) { if (!is_array($array[$data[0]])) { $array[$data[0]] = array($array[$data[0]]); } $array[$data[0]][] = stripslashes(urldecode($data[1])); } else { $array[$data[0]] = stripslashes(urldecode($data[1])); } } } } return $array; } function arraytostr($array) { foreach ($array as $key => $value) { $str .= $key . "=" . addslashes(urlencode($value)) . "&"; } return $str; } I'm really not sure if regex is the way to go with this or what and that's really why I'm asking for help. I know I could do this with more explodes and what not but I feel as if there's probably a better way to do this and I'm just over complicating it. Thank you in advance. how do I put a get id into this form, or use $myvar?: Code: [Select] <form action='read2.php?id=' method="post" name='myForm' id="myForm"></form> Hi Guys Again, another noob question that I can't seem to find a concise answer to. What is the best way to append a query string to a url? I've tried using the Header() function but this didn't seem to work - i.e. Code: [Select] Header("Location: enc.php?ID=test"); My goal is to change the query string depending on the output of various if else statements. For instance if $test isset then execute some code. The script will be self contained so it'll be posting back to itself with the query string and reacting differently depending on the query string. Any ideas? PS sorry if i am asking too many questions. Eager to learn and struggling to find answers to some things. What I basically want to do (and not sure if this is possible) is to append a different query string based on How can I make it so that $year-$month-$day is the value of $shutoff. So when it posts to database, it will be in date format..........so something like $shutoff = $_POST['$year-$month-$day'] or [year-month-day]. Those are dashes not minuses.........is that correct format also? How do I do something like this? |