Hi,
I am using a simple script on my PHP webpage to decode and output JSON as text. However, what ever I try I can't get it to wordwrap the output.
$file = file_get_contents('sample.txt');
$out = (json_decode($file));
echo $out->mainText;
How can I get this script to wordwrap at 600 characters without chopping words in half?
If possi...
I want to have multiple scripts running from cron at the same time. They will all update, say, 500 rows with a unique status ID for that particular script to use.
If each script grabs the same type of rows to update, and the scripts run at once, will there be interference between the queries run at the same time? For example, using this...
Hi there!
In my Facebook application, I have one Facebook wrapper class to encapsulates some call to Facebook API. I want to to write a unit test for this wrapper class, but since it depends on a so called "access token", which we should get from Facebook dynamically, I'm not sure if it's possible to write one.
But apparently the Faceb...
My configuration - Windows 7 x64, Php 5.3, Apache 2.2.15, latest Mysql.
When loading pages from localhost, the response time shown by firebug is more 530ms for the main 'index.php' file, sometimes the connection is reset. It's painfully slow.
I googled the problem and found a workaround - switch off and on again a win service called BF...
I have tested this on my development computer, but now I have uploaded everything to the production server and I cant read out the value of the cookie.
I think the problem lies in the Serialization and Unserialization.
if (isset($_COOKIE['watched_ads'])){
$expir = time()+1728000; //20 days
$ad_arr = unserialize($_COOKIE['watche...
I have a database application (or search engine) which is called Solr.
I connect to it via port 8983.
I do this from php code, so I add and remove records from it via php.
On my server I have a firewall.
I have set this firewall to only allow connections to and from this port (8983) from the ip adress of my own server. In other words...
Even on max quality GD just wasn't good enough quality, so i'm pretty sure i'm going to have to go down the ImageMagick route... I've heard stories....!
What kind of things no i need to be careful about/aware of when using/installing ImageMagick?
...
function sanitizeString($var)
{
$var = stripslashes($var);
$var = htmlentities($var);
$var = strip_tags($var);
return $var;
}
function sanitizeMySQL($var)
{
$var = mysql_real_escape_string($var);
$var = sanitizeString($var);
return $var;
}
I got these two functions from a book and the author says that by us...
I'm not sure what to call this, so I'll give an example.
In PHP
1==2 || 2 returns 1 or true
In Ruby
1==2 || 2 returns 2 (The second statement if the first evaluates to false).
Is there any short way to implement similar thing in PHP?
...
I have been learning php for sometime now. Besides reading books and doing tutorials i also like to sometimes read other programmers code. I have came across this:
<?php
// authentication.
include_once($sys_root."/inc/authenticate_check.php");
I understand the use for $sys_root, but what i dont understand is, how is $sys_r...
I came up with this:
<?php
$dir = $_GET['dir'];
header('Content-type: image/jpeg');
$create = imagecreatetruecolor(150, 150);
$img = imagecreatefromjpeg($dir);
imagecopyresampled($create, $img, 0, 0, 0, 0, 150, 150, 150, 150);
imagejpeg($create, null, 100);
?>
It works by accessing:
http://domain.com/image.php?dir=thisi...
hi all,
<td align="center" bgcolor="#FFFFFF"><?php echo '<label onclick="window.open('profilephp.php?member=$row['MemberID']','mywindow')">'.{$row['MemberName']}.'</label>';?><br />
<?php echo "<p align='center'><img width='100' height='100' src={$row['MemberImg']} alt='' /></p>";?></td></tr>
Parse error: syntax error, unexpected T_S...
I came upon Smarty which is a template engine. But there are also the Zend, CakePHP frameworks. Is Smarty like Zend, or are they completely different? Smarty just separates logic from display - is this similar to a framework like Zend?
...
I'm using Shadowbox a jquery overlay and I wanted to count how many people are actually using the overlay. Thus, I would need a function that would write a counter to a file or sending a query through a php api...
has to be a a php url api because I cant use php on the server where the overlay is.
So I need help with executing a javasc...
This is very similar to a question I asked the other day but my page code has become significantly more complicated and I need to revisit it. I've been using the following code:
$('#myLink').click(function() {
$('#myImg').attr('src', 'newImg.jpg');
setTimeout(function() { $('#myImg').attr('src', 'oldImg.jpg'); }, 15000);
});
To re...
Is it possible to make all function's vars global without typing all of them like global $a, $b, $c...?
...
I have a mysql table with over 4 million of data; well the problem is that SOME queries WORK and SOME DON'T it depends on the search term, if the search term has a big volume of data in the table than I get the following error:
Fatal error: Allowed memory size of 1048576000 bytes exhausted (tried to allocate 75 bytes) in /home/****/pu...
Hey again... to those that may have read my previous question that got solved a couple minutes ago >.<
The on-the-fly php script works perfectly, but when I went to upload new images into a gallery which I made myself, the images are resized to 150 x 150 for what I wanted... however, when it comes to new images being added it is all bla...
i have a phone number in following format +923334173333 and now i want to validate this number exactly in the given format and length with php
...
In a url like the one below, I'd like to get the value of ProdId. The URL format will always be consistent, as will the parameter name, but the length of the value may change. It will always be numeric.
http://www.example.com/page.php?ProdId=2683322&xpage=2
Using PHP what's the fastest way to get it (I'll be processing 10,000's so...