Hi,
Is it possible to have Javascript compute a timestamp returned from php's time() function and present it in a readable format such as "Sun, 18th April 2010 at 4:00 pm"?
Thanks:)
Is there a way to write the PHP file_exists function so that it searches a directory for a file with an arbitrary extension. For instance, suppose I knew that a file were called "hello", but I didn't know the extension, how would I write a function that searched for a file called hello.* and returned the name of this file? As far as I can tell, file_exists will only search for a string.
Thanks.
Hi,
I'm sending email with PHP's mail function.
It works just as it should except all email clients show blank From-field.
Here's how i'm using the function:
mail( '[email protected]', "Example subject", $msg,
implode( "\r\n", array( Content-Type: text/html; charset=UTF-8', 'From: [email protected]') ) );
As i said everything works fine except From field is all blank when the message arrives.
Any ideas why this is happening?
Hi Everyone,
I am doing a newsletter Management in php. I need to track the visitors who opens our newsletter, I have inserted the tracking image in newsletter thats seems to work little.
Using Shift mailer there is option to embed an inline image to newsletter. Is it possible to track using this inline image?
Is there any other techniques for tracking email.
How to validate a substring is true in PHP for example if user1 is in the string it should be true?
textfile:
user1 : pass1
user2 : pass2
user3 : pass3
if(in_array($_SERVER['user1'] . "\r\n", $textfile)){ //not the way want this to be true
printf("Ok user1 is in this row somewhere");
}
I was wondering whether there is a simple PHP library to test the loading speed of a web page or a single resource similar to Google Page Speed and Yahoo! YSlow.
The reason is that I'd like to build a web based alternative.
Hi,
I'm trying to shorten a wordpress title to just the first word. For a page named "John Doe" I want to have a sub title somewhere on the page that says "About John" so I want to just get the first word from the title.
Is there a way to do this with PHP?
Thanks!
how to connect more then one DB in php... but the DB servers are same . but the DB is different. same single page i need to fetch the result from all the 3 db to display. Thank you
I have trouble reading Postgresql arrays in PHP. I have tried explode(), but this breaks arrays containing commas in strings, and str_getcsv() but it's also no good as PostgreSQL doesn't quote the Japanese strings.
Not working:
explode(',', trim($pgArray, '{}'));
str_getcsv( trim($pgArray, '{}') );
Can anyone please explain a recursive function to me in PHP (without using Fibonacci) in layman language and using examples? i was looking at an example but the Fibonacci totally lost me!
Thank you in advance ;-)
Also how often do you use them in web development?
Hi, I wanted to ask:
when I am using php.net/bzopen, does I need to bzwrite() already compressed by bzcompress() string or it being compressed automatically while writing?
hi, can any body help me on separating this example of data that i need to parse and seperate text just like PHPDoc. It is PHP source code.
The example string :
function one_to_tree() {
//bla bla bla
return FALSE;
}
function two_to_tree() {
//bla bla bla
return FALSE;
}
function three_to_tree() {
if ($sample){ //bla bla bla }
return FALSE;
}
can anybody help me how to seperate above string based on "function" word and create and array. Thank you
Hi, I'm looking for a grid control for a project I'm doing in PHP.
Are there any good recommendations?
Ideally, it'd have a data entry mode similar to a spreadsheet where the user could enter row after row after row, without needing to click new/edit buttons or links.
Somebody must have come up with a solution for this by now. We are using PHP5.2. (Don't ask me why.) I wrote a PHP class to display a recordset as an HTML table/datagrid, and I wish to expand it so that we can sort the datagrid by whichever column the user selects. In the below example data, we may need to sort the recordset array by Name, Shirt, Assign, or Age fields. I will take care of the display part, I just need help with sorting the data array.
As usual, I query a database to get a result, iterate throught he result, and put the records into an assciateiave array. So, we end up with an array of arrays. (See below.) I need to be able to sort by any column in the dataset. However, I will not know the column names at design time, nor will I know if the colums will be string or numeric values.
I have seen a ton of solutions to this, but I have not seen a GOOD and GENERIC solution Can somebody please suggest a way that I can sort the recordset array that is GENERIC, and will work on any recordset? Again, I will not know the fields names or datatypes at design time. The array presented below is ONLY an example.
UPDATE: Yes, I would love to have the database do the sorting, but that is just not going to happen. The queries that we are running are very complex. (I am not really querying a table of Star Trek characters.) They include joins, limits, and complex WHERE clauses. Writing a function to pick apart the SQL statement to add an ORDER BY is really not an option. Besides, sometimes we already have the array that is a result of the query, rather than the ability to run a new query.
Array
(
[0] => Array
(
[name] => Kirk
[shrit] => Gold
[assign] => Bridge
)
[1] => Array
(
[name] => Spock
[shrit] => Blue
[assign] => Bridge
)
[2] => Array
(
[name] => Uhura
[shrit] => Red
[assign] => Bridge
)
[3] => Array
(
[name] => Scotty
[shrit] => Red
[assign] => Engineering
)
[4] => Array
(
[name] => McCoy
[shrit] => Blue
[assign] => Sick Bay
)
)
I have two classes that work seperate from another, but they extend the same class. Is it possible to have them work the same instance of the extended class. I'm wanting the constructor of the extended class to run only once.
I know this isn't right but something like this:
<?php
$oApp = new app;
class a extends $oApp {}
class b extends $oApp {}
Hello.
I want to fetch all my emails available in different online accounts eg:(gmail, yahoo, hotmail, aol, etc..) using PHP such that if necessary to reply any email then I could reply.
How it is possible?
Does anybody have a PHP (or other language) script for drawing a spiral. A simple (Archimedean spiral) would be just fine. Of course the principle is simple but coding it in SVG or GD would take some time, so I wonder if somebody has one ready :-)
I have multiple inheritance like this one: http://stackoverflow.com/questions/356128/can-i-extend-a-class-using-more-than-1-class-in-php (let's not discuss this approach itself please) and want my IDE to know about inherited class methods and properties. Is there a way to do it with PhpDoc?
Hi
I'm trying to initialize a session but i get this error:
Warning: session_start() [function.session-start]: open(/tmp/sess_7af3ee9ec1350680bedcf63833d160bd, O_RDWR) failed: Permission denied (13)
The session.path is set to /tmp with 777 perms.
I try to edit the session.path to "0;777;/tmp" but the session files are created with the wrong permissions(only write).
I'm using PHP5.2 on apache2 and ubuntu 9.10.
Any ideas?
I'm trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it's coming out wrong.
17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969)
This is the code I'm using:
<?= date("c", $post[3]) ?>
$post[3] is the datetime (CURRENT_TIMESTAMP) from my MySQL database.
Any ideas what's going wrong?
Hi ALL~
I'm getting this error while I was implementing and testing PHP webservice using Zend Soap.
I'm testing the same codes under 2 different protocols(http & https) in 2 different web servers.
http site works just fine, but I get "SoapFault exception: [VersionMismatch]..." error in https.
The two web servers almost have the same specs.
Is there anyone who can help me with this?
Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example:
keys my %or_cache = @in;
@out = sort {
($or_cache{$a} ||= KEY($a))
cmp
($or_cache{$b} ||= KEY($b))
} @in;
Is this operator available in PHP and Javascript?
And if not, do these two languages allow user defined operators?
hello I integrated the membership subscription in the website,
but I fail to insert data to the database.
checking out all the function I make a txt file with php with data and generates me correctly.
but I can not verify any data and less insert.
<?php
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// Post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
// Assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$user_id = $_POST['custom'];
//Here i make the txt file and it works correctly
//but after this does not work or make a txt file
//Insert and update data
if (!$fp)
{
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
//Verificamos el estado del pedido
if ($payment_status == 'Completed')
{
$txn_id_check = mysql_query("SELECT Transaction_ID FROM ".$db_table_prefix."Users_Payments WHERE Transaction_ID='".$txn_id."'");
if (mysql_num_rows($txn_id_check) !=1)
{
//Si el pago se ha realizado al dueño especificado y coincide con el dueño
if ($receiver_email == $website_Payment_Email)
{
//Tipo de cuenta segun pagado
if ($payment_amount == '10.00' && $payment_currency == 'EUR')
{
//add txn_id to database
$log_query = mysql_query("INSERT INTO `".$db_table_prefix."Users_Payments` VALUES ('','".$txn_id."','".$payer_email."')");
//update premium to 3
$update_premium = mysql_query("UPDATE ".$db_table_prefix."Users SET Group_ID='3' WHERE User_ID='".$user_id."'");
}
}
}
}
}
else if (strcmp ($res, "INVALID") == 0)
{
// log for manual investigation
}
}
fclose ($fp);
}
?>
I call this file with require_once () with the connection to the database
any ideas?
thanks
I am trying to use an update query to change values held in a database, the new values I am trying to store are held in php variables. I'm not sure what it is I'm doing wrong.
mysql_query("UPDATE user SET
status='full' WHERE user_id =
'$user_id'")or die(mysql_error());
thanks in advance