Let's say I have a big RSS feed full of Twitter posts, and they are all plain text. Lots of the posts contain URLs, and I'd like those URLs to be turned into links.
So I've got a variable that is equal to:
Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW4z
And I'd like it to turn into:
Visualization of layoffs by industry, number and date. Looking forward to seeing similar for hiring trends. http://bit.ly/XBW4z
How could I do that? I am useless when it comes to regex and its ilk, so help is much appreciated!
Hello. How could I make an image graph from values in a database? The idea came from "Steam", which uses a graph to show how many users are online. How could I do the same thing? It seems like the graph is one whole image; not made up of parts. Here's an image of the graph from Steam:
Thanks.
Hi Guys,
I was wondering about which way i should do the following. I am using the tiny MCE wysiwyg editor which formats the users data with the right html tags. Now, i need to save this data entered into the editor into a database table.
Should i encode the html tags to their corresponding entities when inserting into the DB, then when i get the data back from the table, not have the encode it for XSS purposes but i'd still have to use eval for the html tags to format the text.
OR
Do i save the html tags into the database, then when i get the data back from the database encode the html tags to their entities, but then as the tags will appear to the user, i'd have to use the eval function to actually format the data as it was entered.
My thoughts are with the first option, i just wondered on what you guys thought.
Thanks
M
I've been trying to use SimpleXML, but it doesn't seem to like XML that looks like this:
<xhtml:div>sample <xhtml:em>italic</xhtml:em> text</xhtml:div>
So what library will handle tags that look like that (have a colon in them)?
I think if I granted the apache user appropriate privileges and used the ident authentication method, that would make the connection more secure because then the password wouldn't need to be stored in a connection string.
Also, that way the security of the connection would depend on how secure the host system is. I disabled root login over ssh and only permit public key authentication so I think it is pretty secure.
Does this have any significant security benefits or is it just wishful thinking? Is it necessary at all?
I'm working on a Facebook app for book sharing, reviewing, and recommendations. I've scoured the web, searched Google using every search phrase I could think of, but I could not find any tutorials on how to access the Amazon.com API for book information.
I signed up for an AWS account, but even the tutorials on their website didn't help me one bit. They're all geared toward using cloud computing for file storage and processing, but that's not what I want.
I just want to access their API to search info on books. Kind of like how http://openlibrary.org/ does it, where it's a simple URL call to get information on a book (but their databases aren't nearly as populated as Amazon's).
Why is it so damned hard to find the information I need on Amazon's AWS site? If anybody could help, I would greatly appreciate it.
I've been googling around for a really simple way of making what is, in effect, nothing more than an enhanced phpMySql.
In a mysql database, I have:
Name, address, phone, website etc, plus 2 or 3 custom fields. This data is pulled out to make a website.
All I want is to be able to make a freeform form, a bit like Access, but for the web, and the only thing I want to do over and above normal field editing would be to have a list of when I contact them, what was said, and perhaps a reminder when the next action is due.
I've looked at so many CRMs my mind is boggling, and they all do WAY more than I need. I don't have leads or accounts, all I have is the need to make sure than when I update the person's details, and for that data to be in the same DB as my site is generate from.
I'm happy to learn if I can get pointed in the right direction, and I have a feeling that something like what I want might lie in the direction of jquery. It's just that there's so much good jquery stuff about, I can't see the wood for the trees!
Thanks.
I am running following code, getAccount() is a static function,
$ac_info = AccountClass::getAccount($ac_code);
print_r($ac_info);
and getting following output
AccountClass Object ( [account_code] => [email protected] [username] => XYZ [email] => [first_name] => [last_name] => [company_name] => [id] => [email protected] [balance_in_cents] => 0 [created_at] => 1271333048 [state] => active )
But I want to access the value of "account_code" shown above, how to access it, and AccountClass Object what is this, this is array or what? I am not getting it properly.
Please explain what is AccountClass Object and how to access value of properties account_code, first_name inside this array.
Thanks
I have pasted the example of what I need here : http://pastie.org/1005178
I have a xml file with say the following info
<state>
<info>
<name>hello</name>
<zip>51678</zip>
</info>
<info>
<name>world</name>
<zip>54678</zip>
</info>
</state>
Now I need to create a new xml file which has the following
<state>
<info>
<name>hello</name>
<zip>51678</zip>
<lat>17.89</lat>
<lon>78.90</lon>
</info>
<info>
<name>world</name>
<zip>54678</zip>
<lat>16.89</lat>
<lon>83.45</lon>
</info>
</state>
So, basically I need to add lat and lon nodes to each info element.
these lat and lon correspond to the zip code which are stored in a mysql file which contains 3 fields - pin, lat and lon
How do i do this recursively. I have say 1000 info elements in a file
Please give me a sample code because I have already tried using simplexml and read the documentation but doesn't see to understand it properly
I try to get some insights from the pages I am administrator on Facebook. What my code does, it gets the IDs of the pages I want to work with through mySQL. I did not include that part though.After this, I get the page_id, name and fan_count of each of those facebook IDs and are saved in fancounts[].
Using the IDs ( pages[] ) I get two messages max from each page. There may be no messages, there may be 1 or 2 messages max. Possibly I will increase it later. messages[] holds the messages of each page.
I have two problems with it.
It has a very slow performance
I can't find a way to echo the data like this:
ID - Name of the page - Fan Count
Here goes the first message
Here goes the second one
//here is a break
ID - Name of the page 2 - Fan Count
Here goes the first message of page 2
Here goes the second one of page 2
My questions are, how can the code be modified to increase performance and show the data as above? I read about fql.multiquery. Can it be used here?
Please provide me with code examples. Thank you
$pages = array(); // I get the IDs I want to work with
$pagesIds = implode(',', $pages);
// fancounts[] holds the page_id, name and fan_count of the Ids I work with
$fancounts = array();
$pagesFanCounts = $facebook->api("/fql", array(
"q" => "SELECT page_id, name, fan_count FROM page WHERE page_id IN ({$pagesIds})"
));
foreach ($pagesFanCounts['data'] as $page){
$fancounts[] = $page['page_id']."-".$page['name']."-".$page['fan_count'];
}
//messages[] holds from 0 to 2 messages from each of the above pages
$messages = array();
foreach( $pages as $id) {
$getMessages = $facebook->api("/fql", array(
"q" => "SELECT message FROM stream WHERE source_id = '$id' LIMIT 2"
));
$messages[] = $getMessages['data'];
}
// this is how I print them now but it does not give me the best output. ( thanks goes to Mark for providing me this code )
$count = min(count($fancounts),count($messages));
for($i=0; $i<$count; ++$i) {
echo $fancounts[$i],'<br>';
foreach($messages[$i] as $msg) {
echo $msg['message'],'<br>';
}
}
1) This issue involves just one html webpage, lets call it "ajax.html".2) I have AJAX functions in this webpage that work in both Firefox and IE8.3) I now attempt generating just the option values of a dropdown list of dates using my ajax functions, and it works in Firefox & Opera, but not IE8.4) The surrounding html code for the dropdown looks like this:<select name="entry_7_single" id="entry_7" onChange="Ajax_PhpResultsWithVar('./secure/db/SummaryCls.php','entry_8','dateval',this.value)"></select>The onchange call refers to an ajax function that successfully(both Firefox & IE8) populates a textarea(entry_8) with a description of an event associated with the date selected in this dropdown. 5) An onload call initiates the ajax function to generate the dropdown list values:<body class="ss-base-body" onLoad="OnLoadWebPage()">6) The js script that calls the ajax function is as follows:function OnLoadWebPage(){ Ajax_PhpResults('./secure/db/GenDateListCls.php','entry_7');}7) Since it works in Firefox, but not IE8, I throw the output of the ajax function into a Firefox large textbox and I get the following:<option selected value="8 JUN 2010">8 JUN 2010</option> <option value="9 JUN 2010">9 JUN 2010</option> <option value="10 JUN 2010">10 JUN 2010</option> <option value="11 JUN 2010">11 JUN 2010</option> 8 ) There are over a hundred generated but you get the gist of what the ajax function generates. Next I will list the PHP function that outputs the above dropdown values://///////////////////////////////////////////////////////////////////////////////////////////////////////<?phpinclude_once 'SPSQLite.class.php';include_once 'misc_funcs.php';class GenDateListCls { var $dbName; var $sqlite; function GenDateListCls() { $this->dbName = 'accrsc.db'; $this->ConstructEventDates(); } function ConstructEventDates() { $this->sqlite = new SPSQLite($this->dbName); $todayarr = getdate(); $today = $todayarr[mday] . " " . substr($todayarr[month],0,3) . " " . $todayarr[year]; $ICalDate = ChangeToICalDate($today); $dateQuery = "SELECT dtstart from events where substr(dtstart,1,8) >= '" . $ICalDate . "';"; $this->sqlite->query($dateQuery); $datesResult = $this->sqlite->returnRows(); foreach (array_reverse($datesResult) as $indx => $row) { $normDate = NormalizeICalDate(substr($row[dtstart],0,8)); if ($indx==0) { ?> <option selected value=<?php echo('"' . $normDate . '"'); ?>><?php echo $normDate; ?></option><?php } else {?> <option value=<?php echo('"' . $normDate . '"'); ?>><?php echo $normDate; ?></option><?php } } $this->sqlite->close(); }}$dateList = new GenDateListCls(); ?>/////////////////////////////////////////////////////////////////////////////////////////////////////////////<<< I appreciate any assistance on this matter. Aipragma >>>
My Background:
To let you all know, I am a complete newbie to PHP, Ajax, & javascript, and learning it all on my own, no classes. My background is in Linux, Windows, C++, Java, VB,VBA,MS XML, & some html.
Hola usando estas funciones, que riesgo corro en tener problemas de seguridad, es necesesario usar extract() o hay alguna manera mejor de convertir las variables superglobales (array) en trozos de variables.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes( $_GET );
$_POST =stripslashes( $_POST );
}
function vars_globals($value = '') {
if (is_array ( $value ))
$r = &$value;
else
parse_str ( $value, $r );
return $r;
}
$r = vars_globals( $_GET );
extract($r, EXTR_SKIP);
The agavi framework uses the PUT request for create and POST for updating information. Usually in REST this is used the other way around (often referring to POST adding information while PUT replacing the whole data record).
If I understand it correctly, the important issue is that PUT must be idempotent, while POST does not have this requirement. Therefore, I wounder how creating a new record can be idempotent (i.e. multiple request do not lead to multiple creations of a record) in particular when usually the ORM uses an id as a primary key and the id of a new record would not be known to the client (since it is autocreated in the database), hence cannot be part of the request. How does agavi maintain the requirement of idempotence in light of this for the PUT request.
Thanks.
Let's say I want to find all sets of 5 single-digit, non-repeating numbers that add up to 30... I'd end up with [9,8,7,5,1], [9,8,7,4,2], [9,8,6,4,3], [9,8,6,5,2], [9,7,6,5,3], and [8,7,6,5,4]. Each of those sets contains 5 non-repeating digits that add up to 30, the given sum.
Any help would be greatly appreciated. Even just a starting point for me to use would be awesome.
I came up with one method, which seems like a long way of going about it: get all unique 5-digit numbers (12345, 12346, 12347, etc.), add up the digits, and see if it equals the given sum (e.g. 30). If it does, add it to the list of possible matching sets.
I'm doing this for a personal project, which will help me in solving Kakuro puzzles without actually solving the whole thing at once. Yeah, it may be cheating, but it's... it's not THAT bad... :P
Hello. Can anyone tell me how to get and display the biggest values from a database? I have multiple values in my database with the heading "gmd", but how would I get only the first 3 biggest ones to be displayed? How would I do it in this example:
$query = "SELECT gmd FROM account";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
}
Thanks.
Does anyone know of one? I need to test some upload/download scripts and need some really large files generated. I was going to integrate the test utility with my debug script.
I have a select box that is part of a form. It is currently querying the addresses table and displaying the addresses into the select box. I plan on having up to 100 addresses.
I'm looking for a solution where I can show all the states if the user clicks on the select box. Then if the user hovers over a state it will show all the addresses for that specific state. Then if the user clicks on an address, it will show that as the picked option in the select box. This is like a dropdown menu within a select box.
Does anyone know where I can find a solution as this?
I am planning on creating my database table for users of an offline site that use as a kiosk.. Those kiosk are not connected on a network nor to each other, they have a separate webserver and database.. what Is the best thing that I can use to have these users on every kiosk to have their different unique id? I am planning using hash so that when we combine all the data's in every machine on single server we can accommodate each unique ids.
For example, take this code:
$ch = curl_init($resultSet['url']."?get0=get0&get1=".$get1."&get2=".$get2."&get3=".$get3);
This of course, looks very ugly, and kind of a pain in the ass to read. So my question is, would I be able to use something like this:
$allgets ="?act=phptools&host=".$host."&time=".$duration."&port=".$port;
$ch = curl_init($resultSet['url'] . $allgets);
Very simple question I suppose, but my server is undergoing maintenance, so I can't upload it and test it myself. I suppose a yes or no answer will suffice, but if you have a more efficient way of doing this, that would be even better. :)
What is a good way to represent a collection of bits?
I have a set of various on/off toggles (thousands of them) and need to store and retrieve their state. The naïve implementation would be an array of booleans, but I'm wondering if there's a better way (better in terms of access speed and/or memory requirements).
I've found this BitArray implementation, but it's limited to 32 bits, which is not enough for this case.
Hello. How can I remove the first number in a string? Say if I had these 48 numbers seperated with a ',' (comma):
8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35,8,5,8,10,15,20,27,25,60,31,25,39,25,31,26,28,80,28,27,31,27,29,26,35
How would I remove the "8," from the string? Thanks.
I would like to add 24 hours to the timestamp for now. How do I find the unix timestamp number for 24 hours so I can add it to the timestamp for right now?
I also would like to know how to add 48 hours or multiple days to the current timestamp.
How can I go best about doing this?
I know I'm probably missing something easy, but I have a foreach loop and I'm trying to modify the values of the first array, and output a new array with the modifications as the new values.
Basically I'm starting with an array:
0 = A:B
1 = B:C
2 = C:D
And I'm using explode() to strip out the :'s and second letters, so I want to be left with an array:
0 = A
1 = B
2 = C
The explode() part of my function works fine, but I only seem to get single string outputs. A, B, and C.
I have an array that has keys and values. For eg:
Array (
[name] => aalaap
[age] => 29
[location] => mumbai
)
I want to convert the keys from this into values, but I want the values to apear right after the keys. For eg:
Array (
[0] => name
[1] => aalaap
[2] => age
[3] => 29
[4] => location
[5] => mumbai
)
I can easily write an iteration function that will do this... for eg:
array_flatten($arr) {
foreach ($arr as $arrkey => $arrval) {
$arr_new[] = $arrkey;
$arr_new[] = $arrval;
}
return $arr_new;
}
...but I'm trying to find out if there's any way this can be accomplished using array_combine, array_keys, array_values and/or array_merge, preferably in one, so i don't need to use a custom function.
Is there?