天道酬勤,学无止境

php

Sending email through PHP mail function not working for long emails

I am trying to use the php mail function to send emails from my site. Users on the site type their emails in an html form. I have tested the mail functionality and it works when the email text is small such as: this is an email However, when I type a long email, the mail() function returns 1 but no email is actually received. The code to dispatch email is simply: $email_message = $_POST['email_mssg_from_form']; $ret = mail($to, $subject, $email_message); I have tried to regularize contents of $email_message using: $email_message = wordwrap($email_message, 70, "\r\n"); $email_message =

2022-01-19 02:30:27    分类:问答    php

Execute concurrent SSH commands?

I want to write a little PHP script using the ssh2_* functions to deploy some code to several servers concurrently and run a few tasks. Is this possible in PHP, or do I have to wait for each request to complete? I can use a different language, but we're a PHP shop so I thought I'd stick with the familiar.

2022-01-19 02:28:44    分类:问答    php   ssh

Header location not working properly

My URL is http://www.website.ro/index.php?subiect=10046&pag=1#1006, and i have a form here with no action (<form action="" method="post">). After submit I'm checking some input fields and if there is any error, I want to redirect. I use this code: header('Location: /index.php?subiect='.$_GET['subiect'].'&pag='.$_GET['pag']); exit(); But the redirect includes #1006 so my page becomes http://www.website.ro/index.php?subiect=10046&pag=1#1006 I tried to change location in the header with: header('Location: http://www.google.com'); exit(); The page where takes me is : http://www.google.com#1006 Why

2022-01-19 02:27:45    分类:问答    php   header

PHP Excel style formatting using col & row index

we can apply a style on a range of cells like this $objPHPExcel->getActiveSheet()->duplicateStyleArray($array_of_style,"A1:D1"); But I want to apply same style to a range of cells on their column and row reference like (3,4,7,7); Please help me on this. I am not a newbie on phpexcel but could not find any method to apply a style on range given in col & row index.

2022-01-19 02:25:00    分类:问答    php   phpexcel

user add records to database PDO

I wish to let a user add records to an empty database table. As a matter of fact I have a database and an empty table which has to be filled using a form the first file handles the db connection (I use PDO)returns an empty page and a link named add which goes to a form <?php error_reporting(-1); ini_set('display_errors', 'On'); ?> <?php $servername = "localhost"; $username = "xxx"; $password = "xxx"; $dbname = "xxxx"; try { $dbh = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE

2022-01-19 02:21:10    分类:问答    php   mysql   pdo

Drupal Imagfield/Filefield in custom form

i have created a module with this among others this function in it: <?php function ils_ladda_upp_form() { $form['upload'] = array( '#method' => 'post', '#attributes' => array( 'enctype' => 'multipart/form-data', ) ); $form['upload']['album_name'] = array( '#type' => 'textfield', '#title' => t('Albumnamn'), '#required' => 1 ); $form['upload']['album_location'] = array( '#type' => 'textfield', '#title' => t('Plats'), ); $form['upload']['album_date'] = array( '#type' => 'date', '#title' => t('Datum'), '#required' => 1, '#suffix' => '(då bilderna togs)' ); $form['upload']['album_description'] =

2022-01-19 02:19:27    分类:问答    php   drupal   imagefield

git post-receive hook in php

I want to be able to execute a php hook on post-receive hook, to copy files from the git repo to web folder on the same server and only run if it was pushed was made on a master branch ignoring other branches. Below is what I've got so far. !/usr/bin/php <?php exec("git archive master | tar -x -C /var/www/", $output); ?> Basically, im not sure how to access git arguments using php.

2022-01-19 02:18:29    分类:问答    php   git   githooks

Is there a PHP function to fix this? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question "“Excuse me, I hope this isn’t weird or anything," How can I fix the encoding on this?

2022-01-19 02:15:12    分类:问答    php   encoding

PHP: mPDF / pdf library / is it possible to create multiple pdf files in a loop?

I'm using mPDF library and I'm trying to write a code which will create multiple PDF files at one call (with one opening of: test.php). Problem: always only the first file is downloaded. I know that the question may seems stupid, I've tried to dive deep into google but I can't figure out how to solve this. Maybe someone could lead me on the right path? My logic is: - I have one array with all of orders; for each order I would like to create PDF. - I loop the array and each time call the MPDF library test.php $myorders = [ 0 => array ( 'FirstName' => 'Asia', 'LastName' => 'Basia', 'OrderNr' =>

2022-01-19 02:11:59    分类:问答    php   pdf   mpdf

how to foreach an array variable created with recursive function in Smarty

I have an array which I created in php with a recursive function, I do not know how many dimensions, how can I use in Smarty ? I trying use this code : {foreach $myArr as $items} <li> {$items.title} {if $item.submenu} <ul> {foreach $items.submenu as $items2} <li>{$items2.title}</li> {/foreach} </ul> {/if} </li> {/foreach} But this code is for just 2 levels, may be my array have 3 or 4 or ... levels. UPDATE: I found the solution, in my solution I use Smarty functions : {function name=menu level=0} <ul> {foreach $data as $items} <li> <a href="{$items.url}"> {$items.title} </a> {if is_array(

2022-01-19 02:11:55    分类:问答    php   recursion   foreach   smarty