php-5.3

prevent double form submission on refresh

☆樱花仙子☆ 提交于 2020-01-11 08:01:28
问题 I have a simple question. I know that I can prevent a form to re-submit itself when the user reloads the page by using the Post/Redirect/Get Pattern. But my question is, will this pattern work if I'm redirecting the user back to the same page where the form was submitted? I mean, I don't want to redirect the user to another page. Any help please Thank you 回答1: yes, but you have to remember to redirect him without the GET params. so you can header('Location: same_page.php?status=done'); die();

Netbeans PHP Code completion failing me, or am I failing it?

心已入冬 提交于 2020-01-06 07:44:07
问题 First off here is some information, I am using Netbeans 7.0 with the project's php interpreter set to 5.3. The reason for this is I am working with namespaces. So the setup is thus, I have 3 folders -app Namespace App --controller --model --view ---*login.php -system Namespace Sleek -vendor Namespace Vendor --*Reform.php I am using Autoloading, however the entire project is, and this is the first instance I've run into where code completion didn't work, I find it curious... Reform.php

Call a function before the page is timeout in PHP

落爺英雄遲暮 提交于 2020-01-04 06:25:50
问题 I have a PHP script that will run for a long time. I have set the execution time limit to 5 minutes by using set_time_limit() function. I would like to ask whether I can set the script to call a function when timeout limit is reached? like the page unload script in JavaScript or viewDidUnload function in NSViewController, in iPhone SDK ? 回答1: You can use register_shutdown_function() to register a callback, that is called, when the execution finishes. You should also have a look at connection

typehinting: method should accept any $arg that is an object

眉间皱痕 提交于 2020-01-04 02:36:06
问题 I have a class 'Collection', which has an add method. The add method should only accept objects. So this is the desired behaviour: $x=5;//arbitrary non-object $obj=new Foo; //arbitrary object $collection=new Collection; $collection->add($obj); //should be acceptable arg, no matter the actual class $collection->add($x); //should throw an error because $x is not an object According to the PHP manual, one can typehint methods by prefacing the $arg with a class name. Since all PHP classes are

Issue handling dates in doctrine php

半世苍凉 提交于 2020-01-04 02:20:29
问题 I am having a issue with a date format issue. I am using mysql, doctrine2, and php 5.3. The issue is when I query the database getRepository('Entity\\Srm').findBy($id) I end up with a negative date value of: -0001-11-30 00:00:00 . The value that is currently store in the database is 0000-00-00 . The datatype of the field in mysql is date . The doctrine entity has the variable identified as a date type. I have done tons of searching with and no good leads. Any Ideas? Thanks 回答1: If you can

add a button to grid view in yii2

↘锁芯ラ 提交于 2020-01-03 20:12:52
问题 i'm a new yii2 developer ! i made a GridView and the code is shown below : <?php Pjax::begin(); ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\ActionColumn'], ['class' => 'yii\grid\CheckboxColumn'], ['class' => 'yii\grid\SerialColumn'], 'id', 'countryCode', 'countryName', 'currencyCode', ], ]); ?> <?php Pjax::end(); ?> a screenshot of output : OUTPUT now i want to have a column contain some button and that button

add a button to grid view in yii2

谁说胖子不能爱 提交于 2020-01-03 20:12:16
问题 i'm a new yii2 developer ! i made a GridView and the code is shown below : <?php Pjax::begin(); ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\ActionColumn'], ['class' => 'yii\grid\CheckboxColumn'], ['class' => 'yii\grid\SerialColumn'], 'id', 'countryCode', 'countryName', 'currencyCode', ], ]); ?> <?php Pjax::end(); ?> a screenshot of output : OUTPUT now i want to have a column contain some button and that button

MVC PHP - Sending mail from Model

倖福魔咒の 提交于 2020-01-03 10:19:19
问题 I am having problem to figure whenever I should send mail from the Model or the Controller. The thing is In the controller i use like This is regarding PHP. In Controller: if (Post::get()){ $this->model->registerUser( ... ); $this->model->mailSendUserActivation(); // assign something to view. } In Model: public function mailSendUserActivation(){ $mail = new \com\Mail(); // assign stuff to mail from API classes and other functions in model. $mail->send(); } Is this correct ? Or should the mail

What's wrong with imagecreatefromstring function?

ε祈祈猫儿з 提交于 2020-01-02 06:12:52
问题 What is wrong with this code? <?php $data = "iVBORw0KGgoAAAANSUhEUgAAAuwAAAUeCAYAAAAl3WRgAAAgAElEQVR4Xuzdz6/vCV3f8TPADIozowg1ETZ2U2Chm6oLuqkdE1clSlzVdEhXLuAPKPwB1X110ZWBpqyMGLoiAe3KRa2bshDclE0xqSDlp4woej5nPJczd+bOmTmv+2Q+d+ZxEkPC3Pfrfs/je0ye8+V7v/exn/rNL/zDhS8CBAgQIECAAAECBE4p8JhgP+Xz4kERIECAAAECBAgQuBIQ7H4QCBAgQIAAAQIECJxYQLCf+Mnx0AgQIECAAAECBAgIdj8DBAgQIECAAAECBE4sINhP

PHP PDO with Special Characters

陌路散爱 提交于 2020-01-01 11:53:32
问题 I am using PDO for MySQL database connection, selecting, updating and deleting. But I have a problem with selecting rows with special characters , for instance, I want to select a page title with 'Judge-Fürstová Mila', Table page , id title content 1 Judge-Fürstová Mila xxx SQL, SELECT * FROM page WHERE title = 'Judge-Fürstová Mila' Returns result if I query via phpmyadmin. But it return 0 with PDO, $sql = ' SELECT * FROM page WHERE title = ?'; $items = $connection->fetch_assoc($sql,'Judge