Hi,
I need to integrate the Web cam to the application. I need to take the user profile picture using the web cam. How can i do that. any one can help me?
Thanks in advance,
I'm running the following code over a set of 5,000 results. It's failing due to the memory being exhausted.
foreach ($data as $key => $report) {
$data[$key]['data'] = unserialize($report['serialized_values']);
}
I know I can up the memory limit, but I'd like to run this without a problem instead. I'm not going to be able to keep upping the memory forever.
EDIT
The $data is in this format:
[1] => Array
(
[0] => 127654619178790249
[report_id] => 127654619178790249
[1] => 1
[user_id] => 1
[2] => 2010-12-31 19:43:24
[sent_on] => 2010-12-31 19:43:24
[3] =>
[fax_trans_id] =>
[4] => 1234567890
[fax_to_nums] => 1234567890
[5] => ' long html string here',
[html_content] => 'long html string here',
[6] => 'serialization_string_here',
[serialized_values] => 'serialization_string_here',
[7] => 70
[id] => 70
)
Hi,
I'm trying to make a Tag cloud for every user in own page, I'm using PHP5 and Mysql, My table named "tags" and I want to make a array but in short way. The table like below,
The array can be like
for user1 array={[car,1],[cat,null],[pen,1],[dvd,1],[cd,null]}
Username totaltag tag1 tag2 tag3 tag4 tag5
admin 5 car cat pen dvd cd
user1 1 1 1
user2 1 2 12 1
user3 3 2 10 1
I've a simple question about multi-dim array, I want to remove any redundent element let's say in my case, [serviceMethod] => PL is coming 2 times, I want to search 'PL' with respect of [APIPriceTax] if an element has a lower price I want to keep it and remove the other one in array
Array (
[0] => Array (
[carrierIDs] => 150
[serviceMethod] => CP
[APIPriceTax] => 30.63
[APIPriceWithOutTax] 28.32
[APIServiceName] => Xpresspost USA
[APIExpectedTransitDay] => 2
)
[1] => Array (
[carrierIDs] => 155
[serviceMethod] => PL
[APIPriceTax] => 84.13
[APIPriceWithOutTax] => 73.8
[APIServiceName] => PurolatorExpressU.S.
[APIExpectedTransitDay] => 1
)
[2] => Array (
[carrierIDs] => 164
[serviceMethod] => PL
[APIPriceTax] => 25.48
[APIPriceWithOutTax] => 22.35
[APIServiceName] => PurolatorGroundU.S.
[APIExpectedTransitDay] => 3
)
)
This is my pseudo code: Where $carrierAddedToList is the actual array
$newCarrierAry = function($carrierAddedToList)
{
$newArray = array();
foreach($carrierAddedToList as $cV => $cK)
{
if( !in_array($cK['serviceMethod'],$newArray) )
{
array_push($newArray, $cK['serviceMethod']);
}
}
return $newArray;
} ;
print_r($newCarrierAry($carrierAddedToList));
Alright, I may just need a terminology update, but I have been playing in Magento and Joomla, and they do references like
$mage = new Mage;
$mage->block('blockname');
where class Mage through some process I am failing to figure out is calling:
class blockname extends something{
}
Don't quote me on that code, however I am looking to do something like that where I have a file that I can do $myscript-block('blockname'); and it will load and call the file with class blockname.
I hope that is not too confusing, but any help is appreciated.
Thanks in advance!
Does anyone know how to do this? I know how to display a single feed as a simple list, but it gets more complicated. I want to display a list but have multiple sources, with each source having the list-style-image be specific.
Example:
(img1) This is data from rss feed 1
(img2) This is data from rss feed 2
Thanks so much for the help!
I designed my code to put all important functions in a single PHP file that's now 1800 lines long.
I call it in other PHP files--AJAX processors, for example--with a simple "require_once("codeBank.php")".
I'm discovering that it takes about 10 seconds to load up all those functions, even though I have nothing more than a few global arrays and a bunch of other functions involved. The main AJAX processor code, for example, is taking 8 seconds just to do a simple syntax verification (whose operational function is stored in codeBank.php).
When I comment out the require_once, my AJAX response time speeds up from 10sec to 40ms, so it's pretty clear that PHP's trying to do something with those 1800 lines of functions. That's even with APC installed, which is surprising.
What should I do to get my code speed back to the sub-100ms level? Am I failing to get the cache's benefit somehow? Do I need to cut that single function bank file into different pieces? Are there other subtle things that I could be doing to screw up my response time?
Or barring all that, what are some tools to dig further into which PHP operations are hitting speed bumps?
Hi all,
I have a report page that deals with ~700k records from a database table. I can display this on a webpage using paging to break up the results. However, my export to PDF/CSV functions rely on processing the entire data set at once and I'm hitting my 256MB memory limit at around 250k rows.
I don't feel comfortable increasing the memory limit and I haven't got the ability to use MySQL's save into outfile to just serve a pre-generated CSV. However, I can't really see a way of serving up large data sets with Drupal using something like:
$form = array();
$table_headers = array();
$table_rows = array();
$data = db_query("a query to get the whole dataset");
while ($row = db_fetch_object($data)) {
$table_rows[] = $row->some attribute;
}
$form['report'] = array('#value' => theme('table', $table_headers, $table_rows);
return $form;
Is there a way of getting around what is essentially appending to a giant array of arrays? At the moment I don't see how I can offer any meaningful report pages with Drupal due to this.
Thanks
Hello,
I have a news site containing an archive with more than 1 million news.
I created a word definitions database with about 3000 entries, consisting of word-definition pairs.
What I want to do is adding a definition next to every occurence of these words in the news.
I cant make a static change as I can add a new keyword everyday, so i can make it realtime or cached.
The question is, a str_replace or a preg_replace would be very slow for searching 3 thousand keywords in a text and replacing them.
Are there any fast alternatives?
I have a multi-dimensional array that looks like this:
The base array is indexed based on category ids from my catalog.
$categories[category_id]
Each base array has two underlying elements:
['parent_category_id']
['sort_order']
I want to create a function that allows us to create a list of categories for a given parent_category_id in the correct sort order. Is this possible? Technically it is the same information, but the array is constructed in a weird way to extract that information.
I'm now working on a project and I have one class that implements the ArrayAccess interface.
Howewer, I'm getting an error that says that my implementation:
must be compatible with that of ArrayAccess::offsetSet().
My implementation looks like this:
public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("...");
}
$this->params[$offset] = $value;
}
So, to me it looks like my implementation is correct. Any idea what is wrong? Thanks very much!
The class look like this:
class HttpRequest implements \ArrayAccess {
// tons of private variables, methods for working
// with current http request etc. Really nothing that
// could interfere with that interface.
// ArrayAccess implementation
public function offsetExists($offset) {
return isset ($this->params[$offset]);
}
public function offsetGet($offset) {
return isset ($this->params[$offset]) ? $this->params[$offset] : NULL;
}
public function offsetSet($offset, $value) {
if (!is_string($offset)) {
throw new \LogicException("You can only assing to params using specified key.");
}
$this->params[$offset] = $value;
}
public function offsetUnset($offset) {
unset ($this->params[$offset]);
}
}
hi guys,
echo $path; //working
function createList($retval) {
echo $path; //not working
print "<form method='POST' action='' enctype='multipart/form-data'>";
foreach ($retval as $value) {
print "<input type='checkbox' name='deletefiles[]' id='$value' value='$value'>$value<br>";
}
print "<input class='submit' name='deleteBtn' type='submit' value='Datei(en) löschen'>";
print "</form>";
}
what am I doing wrong? why is $path printed corretly outside of the createlist function, but it's not inside of the function?
I have a script that goes through a directory that has 3 images
$imglist='';
$img_folder = "path to my image";
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, checks if are images and ads them to a list
while ($file = $imgs->read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";
}
closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
//display image
foreach($imglist as $image) {
echo '<img src="'.$img_folder.$image.'">';
}
but the problem that I am having is it display a 4th img with no image.. yet I only have 3 image in that folder.
Hi all - this is a bit of a newbie question but hoping I can get some guidance. I've been playing around with Eclipse for a couple months yet I'm still not completely comfortable with my setup and it seems like every time I install it to a new system I end up with different results.
What I'm hoping to achieve is (I think) fairly standard.
In my environment I'd like SVN (currently using Subclipse), FTP support (currently using Aptana plugin), debugging (going to use XDebug) and all the usual bells and whistles of development (code completion, refactoring, etc.)
My biggest current issue is how to set up my environment to support both a 'development' and 'production' server. Optimally I would be able to work directly against the dev server (Eclipse on my Vista desktop against the VM Ubuntu dev server) and then push to production server (shared hosting). I'd prefer to work directly against the dev server (with no local project files, just using the Connections provided by Aptana) but I'm guessing this won't allow for code-completoin or all the other bells and whistles provided for development. Any thoughts?
Kind of an open ended question, but maybe this could be an opportunity for some of you with a great deal of experience using Eclipse to describe your setups so people like me can get some insight into good ways to get set up.
Will this code be 'stressful' for a server?
Or is it easy to bcdiv/sub/add to 10000 decimal places?
I'm thinking of looping it afew times...
Not Sure...
$s2 = (bcdiv('1', $test, 10000));
$s = bcsub($s, $s2, 10000);
$test += 2;
$s3 = (bcdiv('1', $test, 10000));
$s = bcadd($s, $s3, 10000);
$test += 2;
Any advice? :)
I create a directory listing and came across this issue.
what value does mysql_query($query1) return if there is no value
My script received this message from $result, would it be alright to pass array(0)?
Warning: mysql_fetch_array($result) expects parameter 1 to be resource, array given in
I have an endpoint that takes GET requests to collect data from any source that wants to send data.
Is there a way to run some validation that the data is in fact coming from the sources we allowed? They enter the website url that they will be sending the data from and we generate an api key.
The data is sent via a javascript file that they install onto their website.
I have the Access-Control-Allow-Origin set to * as it doesn't necessarily scale to add in hundreds or more websites to that header and that in itself is a security risk as it shows anyone who wants to look at the headers who uses the script.
Currently I am thinking of using the http_origin / origin referrer, but obviously that doesn't do too much
I'd think there was a question on this already, but I can't find one. Maybe the solution is too easy... Anyway, I have a csv and want to let the user change the values based on a name. I've already sorted out creating new name+value-pairs using the fopen('a') mode, using jQuery to send the AJAX call with newValue and newName. But say the content looks like this:
host|http:www.stackoverflow.com
folder|/questions/
folder2|/users/
And now I want to change the folder value. So I'll send in folder as oldName and /tags/ as newValue. What's the best way to overwrite the value? The order in the list doesn't matter, and the name will always be on the left, followed by a |(pipe), the value and then a new-line.
My first thought was to read the list, store it in an array, search all the [0]'s for oldName, then change the [1] that belongs to it, and then write it back to a file. But I feel there is a better way around this? Any ideas? Maybe regex?
Hi,
I'm new to doctrine: I have a problem with the sorting of joined records.
A sample.
I've got an Article model which is associated with a Source model in 1 <- n. The source model has a property called 'position' with an integer value.
Now I want to fetch an article with it's sources orderes by the position. My DQL looks like this:
$q = Doctrine_Query::create()
->select('a.title, s.content')
->from('Article a')
->leftJoin('a.Source s')
->where('a.id = ?')
->orderBy('s.position');
The result doesn't change if I edit the position.
Best regards,
Sebastian
I want to output my sql rows on each side of a line, without breaking the line.
Forexample the html/css code i would like to end up with is something like this:
<div id='container'>
<div style='float:left;'>
Even loops here..
</div>
<div id='line' style='float:left;'>
</div>
<div style='float:right;'>
Uneven loops here..
</div>
<div style='clear:both;'></div>
</div>
Is there a way to output the sql rows in two diffrent divs?
I want to open a word document and edit it
I am opening the word document from the server and at that time it's opening with garbage values (perhaps it's not being properly converted to UTF-8).
When I delete those garbage values and insert something from a textarea to that file it is going to insert and from then on it opens properly.
I would like the document to open with the English words in the document instead of garbage value - it's only the first opening that's broken at present.
<?
$filename = 'test.doc';
if(isset($_REQUEST['Submit'])){
$somecontent = stripslashes($_POST['somecontent']);
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'w')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened fi<form action="" method="get"></form>le.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename) <a href=".$_SERVER['PHP_SELF']."> - Continue - ";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
} else {
// get contents of a file into a string
$handle = fopen($filename, 'r');
$somecontent = fread($handle, filesize($filename));
?>
<h1>Edit file <? echo $filename ;?></h1>
<form name="form1" method="post" action="">
<p>
<textarea name="somecontent" cols="80" rows="10"><? echo $somecontent ;?></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<?
fclose($handle);
}
?>
I get a file path to a user file and I want to make sure that this path is to a valid existing user file and not to something bogus or a system file or something like that.
I know I can use file_exists to check that it exists, but I'm not sure how I should make sure that the file is in a certain sub-directory...
I have a class like this
class someclass{
public function somemethod(){}
}
Now I have an array:
$somearray['someclass'] = new someclass();
$somearray['somemethod'] = 'somemethod';
How can I fire them, I tried the following:
$somearray['someclass']->$somearray['somemethod']();
usign this I get the following error:
Fatal error: Method name must be a string in ......................
Anyone have an idea on how to do this?