Using The Function Prevents Accessing The Result Of The Match.
I don't know if this is possible, but it should be. However, it doesn't seem to be working for me. how I can get it to work:
I use :||: for my delimiter for str_replace, etc.
When replying, the new PM is appended in front of the existing chain of replies, thus the same table entry is used and updated each time. Problem is in storing the sent date, and providing time zone and format adjustments:
$string='This is the message that was sent on :|1161850848|:'
$newString=preg_replace('/([0-9]*)/',format_time(adjust_time('${1}')),$string);
// the result of this is as if ${1} = 0
$newString=preg_replace('/([0-9]*)/','${1}',$string);
// returns 'This is the message that was sent on 1161850848'
It seems that using the function prevents accessing the result of the match.
View Complete Forum Thread with Replies
Related Forum Messages:
Prevents Spam
The higher ups want it bascially so that a user can type in their email address, their friend's email address and a brief note. This will then send an email (which should look like it comes from the user's email address) to their friend with the brief note and a link to the page. Problem is that this sounds like a great toy for spammers.
View Replies !
Accessing Function Arguments
i have the following code: function some_function($argument) { validate_arg(); //more code } function validate_arg() { //this function validates the argument of some_function() } is it possible for validate_args() to automatically read the argument of some_function() or do i have to note the argument in the brackets in any case?
View Replies !
Accessing Variables Outside A Function
Can someone tell me if the following is possible? I have a file containing some STATIC variables, and some functions e.g. $ARCHIVE_INPUT_FILES = false; $ARCHIVE_OUTPUT_FILES = false; $ARCHIVE_CONFIG_FILES = false; $HTML_BODY_BACKGROUND = "gfx/gradient.gif"; function firstOne { // Do something e.g. echo $HTML_BODY_BACKGROUND; } The functions CANNOT see the variables I have declared at the top, so is there anything I can do make the functions see the variables i.e. declare them differently?
View Replies !
Include Prevents Submission
I have a form which when the submit button is pressed it should go to a different page.... but when i have an include to do with absolutely nothing relating to the page other than to display how much money the user has.. and what level they are it just refreshes the page rather than doing the relocation. If i remove the include how ever it works . Would any one know what sorta thing causes this so i can check it out ?
View Replies !
Max Size That Prevents Thumbnails (Using GD)
Does anyone know if there is a size limit that would prevent a thumbnail from being created with GDlib? I am creating thumbnails on the fly If I load a 600 by 600 image it works but say I load a large image 2288x1712 I dont get the thumb - just a broken image. Just wondering if there would be setting that blocks this.
View Replies !
Mysql_real_escape_string Prevents SQL Injections?
Recently I have been using mysql_real_escape_string, which prevents SQL Injections. There is only one problem, it add a to any quote. Although this is HOW it prevents database attacks, it gets pretty annoying. Is there a way to remove that slash when you output (display) the data?
View Replies !
Creating A Function - Preg Match Pattern
so i made it so it strips out all html and php code using strip_tags and have htmlspecialchars so it will print html. also i have a function in place the checks and strips the comment variable of all XSS patterns in place. however im still getting posts like how would i make it so you cannot even copy and paste links? even without doing it in html? i know you would have to do a preg match pattern but i couldnt find any patterns on google.
View Replies !
Warning: Preg_match() [function.preg-match]: Compilation Failed: Unmatched Parentheses
I'm making a newsletter script, this problem is beyond me. The error is: Warning: preg_match() [function.preg-match]: Compilation failed: unmatched parentheses at offset 123 in /newsletter.php on line 16 Line 16 - if(preg_match('/A(?:[a-zA-Z0-9]!#$%&'*+/=?^_`{|}~-])+(?:.[a-zA-Z0-9]!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-z0-9])?.))+(?:[a-zA-Z]{2}|com|org|net)/i',$email)) return true;
View Replies !
How To Add Function Result To Array?
The way I'd like to set up a particular set of functions is to have them either return TRUE or, for example: $errors[type] = "Sorry, the file type is not allowed. Allowed types are ".print_array_inline($acceptedTypes).". "; Then later, I have a foreach loop that echos each array element. However, when I echo each array element is doesn't output the whatever the print_array_inline function does. Any suggestions?
View Replies !
Query Result Navigator Function
I've just updated this, and I thought I'd also say that not only can this provide a page navigation for MySQL or other database results, but can be used to navigate other lists.. such as a file list. PHP Code:
View Replies !
Adding Result Row To Mail Function
I have an email script that will pull the addreses from my club membership database. That part works fine. the problem I am having is being able to include row results inside of the actual email message. My message variable is something like this: Code:
View Replies !
Saving Result Of Function Without Being Echoed
I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying: $randomnumber = rand(1, 1000000); it is executing it right ahead while when i try $randomnumber = "rand(1, 1000000)"; or $randomnumber = 'rand(1, 1000000)' It is saving rand(1, 1000000) as variable. But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either. Any ideas how I would do this?
View Replies !
Storing The Result Of Javascript Function
how do I store the result of a javascript function into a PHP variable? I have a div that is hidden or shown based on whether or not a checkbox is clicked. Initially the div needs to be hidden. So how do i make sure that it will be hidden in all browsers when the page loads. The code for hiding and unhiding it works in the different browsers i have tried, but not initially being hidden. attached is what I currently have.
View Replies !
MySQL Result To Real Array In Function
I'd like to create a function which input is the result of a mySQL query. The output should be exactly the same, only not a mySQL result array, but a 'real' array. So it should also get the fieldnames returned by mySQL and use those as keys. I can't get things to work properly: it should return a multidimensional array, like $result_array[1] = array( [field1] => field1 value, [field2] => field2 value, etc. ) somehow my result is (with code below) $result_array[1] = array( [0] => field1 value, [field1] => field1 value, [1] => field2 value, [field2] => field2 value, etc. ) +++++ code ++++++ $get_res= mysql_query(QUERY); if( $res = mysql_fetch_array( $get_res ) ) { do{ $result[] = $res; }while( $res = mysql_fetch_array( $get_res ) ); }; foreach( $result as $key => $value ){ print_r($value); };
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
Chmode With Mkidir Function, The Result Isn't As Expected
I've tried to create a directory with the php function mkdir(). I've used a "0777" mode , so that owner,group and other can read,write and exectue files in this directory. There's no problem creating the directory, but after it has been created, its mode is "0755". Where did I commit a mistake ?
View Replies !
Search Function That Highlight Result Instead Of Filtering It Out
I am trying to create a search function that will jump to the page containing the result and highlight it instead of filtering it out. To more clearly illustrate what I mean take a look at this link: I would like to search for eg. "bruce wayne" (its record number 30) and just have that row highlighted. Anybody who could steer me in the right direction would be a massive help as I've spent the last 2 days trying to work this out with no joy.
View Replies !
Function To Test If Mysql_fetch_array($result) Pointing Last Record?
I try to perform multiple insert statment, but the problem is in the below codes, the last sql concatenation ends with ",". I wonder if there is any php function to test if the $result set contains the last record. ------------------ //Get topic id of vote_topic from last insert record $sql_topic_id = "SELECT topic_id FROM vote_topic ORDER BY topic_id DESC LIMIT 1"; $result = mysql_query($sql_topic_id,$conn); $row = mysql_fetch_array($result); //Get all student info from stuinfo $sql_strn = "SELECT strn from stuinfo"; $result1 = mysql_query($sql_strn,$conn); //Dump all student strn into vote_status. //Multiple insert statement? How? $sql2 = "INSERT INTO vote_status (strn,topic_id) VALUES "; while ($row1 = mysql_fetch_array($result1)){ $sql2 .= "VALUES ('".$row1[strn]."','".$row[topic_id]."'),";} mysql_query($sql2,$conn); ---------------------
View Replies !
Refreshing Cache Through Php Header Function Yields No Result?
I am building a website for a client. He wants a login page with a "Your account" page for his clients. I am using a combination of javascript and php. Upon succesful login $_SESSION variables are set to 1. example: $_SESSION['logged']= 1; If the client logs out due to idle time or pressing 'logout' these values are set to zero. example: $_SESSION['logged']= 0; Upon loading of "your account" and any of its sub-pages, that page checks $_SESSION['logged']. If the value is zero it redirects automatically back to the login page. Providing oppertunity to log in again if you wish. The checking of $_SESSION['logged'] is supposed to redirect even if the client has logged out, but has pressed "back" on the browser to try and see a login page. The page does not do this. Pressing "back" reveals the page. Interacting with the page or pressing "refresh" THEN causes it to redirect. I need the page to auto-redirect, not show. I am aware that it is the page being cached and keeping those values until you interact with it. I have fully tested the header function in php. Using 'must-revalidate' & 'no-cache' and other version! (most info from php.net). I get no errors when testing the pages, so my code is correctly spelled! But there is simply no reaction by the page, it just does what it does, which is not what it is supposed to do? I ask for experience! Is there a specific way of doing the header functions? Perhaps it must be placed in a specific place in the page? And how can i check that the page is actually using the functions and not just moving over them with no action taken?
View Replies !
Warning: Mysql_result() [function.mysql-result]: Unable To Jump To Row 0
i want to grab the value of a sql entry. but the thing is, sometimes this value is <NULL>. i thought, no biggy, i'll just have an if statement: if (is_numeric(mysql_result($query, 0))) { //do something } else { //do something else using mysql_result($category_id_query, 0); } however, this doe not work. i get this error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 is there a way to check to see if mysql_result() is <NULL> without throwing an error.
View Replies !
Match Array Key To Query Match
I have an array that I output through a loop. It's a list of states. Now I need to run a query ona table and if I find any results associated with this state in db mark this table with, say <strong>State</strong> tags. Having difficulties figuring it out. I'd hate to run a query 50 times to get the results. There's gotta be a better way.
View Replies !
Preg_match - Warning: Preg_match() [function.preg-match]: Delimiter Must Not Be Alphanumeric Or Backslash.
I am trying to match this this line 8f89c2f9-6939-4bff-b800-a6f46e2d0f24 it is a random number everypage load the full string is this MyToken=8f89c2f9-6939-4bff-b800-a6f46e2d0f24 I am connecting to the page with curl so the code is curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); $page = curl_exec($ch); preg_match('MyToken=([0-9a-f-]*)', $page, $mytoken, PREG_OFFSET_CAPTURE, 3); echo $mytoken; echo $page; curl_close($ch); but it keeps giving me an error Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash.
View Replies !
Preg Match To Match A Url
Trying to use preg_match to match the following form http://www.example.com/user-45...what am i doing wrong? preg_match("/^http[://]+[www]+.[a-z0-9-_]+.[a-z.]{2,6}+[/a-z0-9-_]$/i",$_POST['url'])
View Replies !
Displaying Result 1-8, Then Result 9-17 Etc.
I dispaly the results from the database like this. <? while ($row = mysql_fetch_array($prod_result)) { $small = $row[0]; echo"<td align=center><img src="produkter/hardware/decks/$small"></strong></td>";}?> But if there are more than 8 results, I wnat to dispaly the first 8 on one page, then the next 8 on the next page...How can this be done?
View Replies !
PDF Mix & Match
I was wondering if anyone had any experience of splitting & appending PDF's? A client has a huge pdf, and he wants to give the user the ability to mix and match the chapters that they want to download. The final final will be 1 pdf, but may consist of various different chapters chosen from a list. The chapters will be ripped from 1 master pdf. Oh, and the PDF is not just text it contains all manner of images,links & the like! And that is what is required. I was wondering if anyone had any pointers regarding this? I'm thinking PDFLib, but I haven't fully looked into it yet.
View Replies !
Match Only Three
I have this code: $numbers = array("04","13","18","21","30","46","(05)"); foreach($data as $key => $value) { if($data[$key][5] == $numbers[0] && $data[$key][6] == $numbers[1] && $data[$key][7] == $numbers[2] && $data[$key][8] == $numbers[3] && $data[$key][9] == $numbers[4] && $data[$key][10] == $numbers[5] && $data[$key][11] == $numbers[6] )//did they win the jackpot? { echo "You have Won!<br /><br />"; } else { echo "You did not win this time :(<br /><br />"; } } The above code will check the $data[$key] array and match the values against the values in the $number array. That is fine. However what if I wanted to see if only 3 values in the $numbers array matched the numbers in the $data[$key] array. How would I do that?
View Replies !
Where Match () Against ()
i would like to change the following line WHERE MATCH (artists.artist) AGAINST ('$id') to WHERE DOESN'T MATCH (artists.artist) AGAINST ('$id') ie i would like to show all results where $id does not occure.
View Replies !
Match Against
I want use a match against in search engine on multiple tables. In other term I want to create an index and fulltext across 2 tables.
View Replies !
Accessing PHP
I've just installed PHP 4 (current stable release) on our server with IIS4. PHP seems to work and typical testing script (<? PHPInfo(); ?>) works fine. But I am able to run it only if I am sitting at the server computer (I run http://localhost/test.php). How can I run it from computers attached to the server from our company network? I tried ------- http://<ip address>/test.php ------- but no luck. I think that access rights are correctly set.
View Replies !
Accessing DOM
I want to access the DOM. Can something like this be done with PHP or a combination of PHP/JAVASCRIPT? not tested! <html><head><title>DOM test</title> <?php $inFileName = 'test.js' $outFileName = 'jk.js' function doIt() { $dd = getElementById('first'); $dd.innerText=$outFileName; } ?> </head> <body> <p id="first" onclick="doIt()">ClickMe<br> <p onclick="first.innerText=$inFileName">ClickMe<br> </body></html>
View Replies !
Accessing Php.ini
So I just switched to a hosting server and noticed a few different settings. I wanted to change them in php.ini but couldn't find the file, so I asked them about it and they don't know where it is or how I can access it. Aren't there local settings that I can change? Does anyone know of a good tutorial that explains this? I've looked through php.net but none of it really makes sense to me. I really only have access to phpMyAdmin through my server so I have trouble understanding some of the console commands. Basically the things I need to change/check at the moment are display_errors and anything to do with the mail function,
View Replies !
PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES! &[^;]; <[^>]*> Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:
View Replies !
Run SQL With Value Match To $array
I wonder if it is possible to do "select" in mySQL database with value matching to an $array. For example, $array = array("shanghai", "beijing"); I want to select cities whose names match the values in $array. Instead of using foreach(), is it possible to do the select with the array itself. I know some languages support this function. For example: SELECT fieldname FROM cities WHERE city_name in '$array' Is it possible in PHP with MySQL?
View Replies !
Regex: How Do I Match A Dot?
I am trying to match the dot, so that it actually matches "a dot" and not "everything". How do I write that? Example: the word "st." I have tried '/st./i' '/st./i' Sorry if this question is noobish. I have not been able to find the answer searching the net.
View Replies !
While Query Only Does First Match
I'm generating letters based on the date a lead was entered into the database. I've tried moving the } into several places. If I move it before the 2nd query I get all the letters but no dealers. If I move it to the bottom (as it now) I get 1 letter with the dealers. I can't figure out what to do to make the query generate all the letters with their associated dealers. PHP Code:
View Replies !
Trying To Match Date..
I am trying to make an Order History Lookup page for an E-commerce site. Now.. when an order is submitted the dateinserted is formated as date("U") and stored in the Db table. Now.. when I create the lookup date formfields I have them as such: Month (02) Day (25) Year (02) How would I go about getting these values so that I can compare exactly against the date("U") string that is stored in the DB?
View Replies !
Regex - How To Match Until Something
How do you replace an occurence until a certain point: You can see my example code below and the output: $string1 = 'Hello world today' $string2 = 'Hello blahblah' $string1 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string1 ); $string2 = preg_replace ( '/Hello.*(?!today)/', 'Hello ***' , $string2 ); echo "$string1 - This should be Hello *** today "; echo "$string2 - This is correct "; Outputs: ====== Hello *** - This should be Hello *** today Hello *** - This is correct
View Replies !
Match Any Character But
Can I use any reg exp(mainly for mod rewrite) where I can match any character but a fixed list? I need to match a string that does not contain any /'s but I don't want to have to use a character search string. (I don't see any need to have to hardcode it) that is, .. matches any single charactr and (.*) matches any string what I want to do is use something like % that means ..%/ which means match any character but /. Of course it would need to be valid and I know I can't make up semantics for the reg ex. My point is is that, is that I don't want to have to use [a-z0-9-%&^$#@!etc...] to mean . but not /. Surely there is a way to exclude a few characters from . without having to increase the complexity of the expression 1000 fold? If you don't get that, then a simple example would be that I have an arbitrary string and I want to match only if that string does not contain an a. Sure I can so something like [bcdefghijklmnopqrstuv1234567890!@#$%^&*()_+]['/.,<>?:"{}+-=~`..........................] but surely reg exp has an easier way??? (again, this is specifically for mod rewrite)
View Replies !
Regex: Before And After The Match
I want to match a table and also capture the parts before and after the table: preg_match_all("|(.*)(<table.*table>)(.*)|",$text, $parts); But of course it doesn't work, presumably because the first .* is greedy. I tried adding an ? but that doesn't work either. How do I do this ?
View Replies !
Php Emails Do Not Match ??
i have created a registration script for my website and i have added a new featurer that makes you enter your email address twice and then it is supposed to check if they are the same and then if they are submit the form but if not show an error but even if the email addresses are the same it still shows the error below is the code for the email checking Code:
View Replies !
Match Title
I am trying to get a the title out of a html page, I have the html code loaded into a variable. The only thing is sometimes the title is not on the same line. <title>need this text</title> $title = preg_match(/<title>s</title>/i, $html); help me with this match syntax?
View Replies !
Match Number
below is my code it is no working as I thought it would though, I get no errors but when I try to echo out $arr_chk_privacy to see what it says it just shows "array" PHP Code: $arr_chk_privacy = $_POST['chk_privacy']; $cnt_chk_privacy = count($arr_chk_privacy); if ($cnt_chk_privacy > 0) { if (in_array(3, $arr_chk_privacy, true)) { $_SESSION['hideonline'] = 1; //hide online status $sql_delete="DELETE FROM friend_online WHERE userid='$info[auto_id]'";//delete from online table executeQuery($sql_delete); }else{ $_SESSION['hideonline'] = 0; //show online status } $chk_privacy_ids = implode(",", $arr_chk_privacy); }
View Replies !
Pattern Match
Where can I find infi or doc on "pattern match" used within WHERE clause (mysql). As I need to matche with PHP variables I'd prfer something adapted to PHP. In "PHP&MySQL Web Devlpt" (Luke Welling) I can't see much.
View Replies !
FULLTEXT Match Against
I have a fulltext column that contains many word, I am passing $search to it which has 3 words in it currently it finds all entries containing the 3 words but lists entries that also have one or 2 of the words here is my mysql request mysql_query("SELECT * FROM addresses WHERE MATCH(title) AGAINST('$search')") How do I get it ot only show entries which contain all 3 words only?
View Replies !
MySQL WHERE MATCH
I have the following table CREATE TABLE `fulltext_sample` ( `copy` text, FULLTEXT KEY `copy` (`copy`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `fulltext_sample` VALUES ('This is a test to see how mysql works'); Now I do a search for SELECT * FROM fulltext_sample WHERE MATCH(copy) AGAINST('mysql'); and it return 0 results. Can someone please help me with this?
View Replies !
Events Match
I have events recorder in db with the following type date format: 2005-05-31. How do I select the ones that are of this month?
View Replies !
Match An Array
i have this array $ary = array( "Today date is 1, our breakfast is 2 eggs and salad", "Today date is 13, our breakfast is 3 breads and beff", "Today date is 18, our breakfast is 2 toasts with egg", "Today date is 21, our breakfast is 5 wafels with honey", "Today date is 30, our breakfast is a bowl of sereal" ); i need to search and match the date (that i have bolded it) and then compare it to today date using this fuction date("j"); to find the date in the string i'm using this regex ([1-3][0-9]?)(?=, our). i have try everything but i cannot solve it so in the end, if today date is 18 i want to display only this string. Today date is 18, our breakfast is 2 toasts with egg can i do this?
View Replies !
|