smallzoo
-
Posts
21 -
Joined
-
Last visited
Posts posted by smallzoo
-
-
if(isset($_POST['defid'])) { foreach($_POST['defid'] as $did) { $conn->query($sql="INSERT INTO modified_adjustments (default_id) VALUES (:did)", $params=array(':did'=>$did)) ; } }
Made no difference ?
-
I have tried arrays and explicit i.e. defid_1,defid_2 and defid[1],defid[2] and running the modajustents.php on its own works great BUT from the ajax request nothing happens
ie modadjustments.php?defid%5B1%5D=5&defid%5B2%5D=6&defid%5B3%5D=8 works great
but using the ajax request and sending that form data doesn't !
-
..sorry made a mistake and hit send by accident
Anyway..made some alterations to the code
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
formData is "defid_1=5&defid_2=6&defid_3=8”
mod adjustments.php code is
$i=1; $conn->query($sql="DELETE FROM modified_adjustments where default_id<>''"); while (isset($_GET["defid_".$i])){ $did= $_GET["defid_".$i]; $conn->query($sql="INSERT INTO modified_adjustments (default_id) VALUES (:did)", $params=array(':did'=>$did)) ; $i++; }
If I run this using ...modadjustments.php?defid_1=5&defid_2=6&defid_3=8 the three records are inserted !! Success
BUT
If I use the ajax.request function they are not
Any Clues
-
Made some alterations to the form data so now sends distinct data:-
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
Made some alterations to the form data so now sends distinct data:-
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
ok..finally I think I m getting there
<? $c=0; foreach($adjustments as $a) { $i=0; $c++; ?> <input style="width: 20px;float: none;" type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[<?php echo $c;?>]" id="defid[<?php echo $c;?>]" /> <? } ?>
This gives me ( in debug mode )
<input style="width: 20px;float: none;" type="checkbox" checked value="5" name="defid[1]" id="defid[1]" /> ...... <input style="width: 20px;float: none;" type="checkbox" checked value="6" name="defid[2]" id="defid[2]" /> ...... <input style="width: 20px;float: none;" type="checkbox" checked value="8" name="defid[3]" id="defid[3]" />
so running the script
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); alert(formData); new Ajax.Request("/views/releases/modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
gives me
defid%5B1%5D=5&defid%5B2%5D=6&defid%5B3%5D=8
as the form data
...so how do I get these defid values in the mod adjustments php file ?
-
great thanks
is there a way of seeing wha happens at modadjustments.php
As its async I can't see what happens before it returns ?
-
Ok.. so like this
<? foreach($adjustments as $a) { $i=0; ?> <input style="width: 20px;float: none;" type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[<?=$i?>]" id="defid[<?=$i?>]" /> <? } ?>
and
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); //data = new FormData(); alert(formData); new Ajax.Request("modadjustments.php", { method:'post', data: formData, onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
-
I mean GET sorry
yes I forgot the fd=.. that was for testing
Not sure what you mean by empty post.. it posts the form data
When I use the correct function ( see below )
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); alert(formData); new Ajax.Request("/views/releases/modadjustments.php?"+formData, { method:'post', onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
and also add the [] parameter to the form variable ( see below )
‘ cut down version <form name="modadjustments" id="modadjustments" action="" onsubmit="return false;"> <? foreach($adjustments as $a) { $i=0; ?> <input type="checkbox" <?php echo ($a->active==1 ? 'checked' : '');?> value="<?php echo ($a->active==1 ? $a->default_id : 'no');?>" name="defid[]" id="defid[]" /> <? } ?> <button type="button" onclick="modifyAdjustments();">Save changes</button> </form>
the format still looks like this ( see below )
defid%5B%5D=5&defid%5B%5D=6&defid%5B%5D=8
-
Tried this.. got nothing.. what am I doing wrong ?
....../modadjustments.php?defid=5&defid=6
<?php print_r("start loop"); foreach ($_POST['defid'] as $value) { print_r($value); } print_r("end loop"); ?>
just get
start loopend loop
-
I have a function which posts data from a form ( a table.. )
function modifyAdjustments() { var formData = jQuery('#modadjustments').serialize(); new Ajax.Request("/views/releases/modadjustments.php?fd="+formData, { method:'post', onSuccess: function(transport) { jQuery('#edit_adjustnments_div').dialog('close'); }, onFailure: function(transport) { } }); }
When I look the form data it looks like this ;-
"defid=5&defid=6&defid=2"
All I want modadjustments.php to do is to parse this data and do a foreach loop so I can do something with the defid's
e.g.
e.g.
foreach...{
print_r (defid)
}
this will show of above example
5
6
7I'm going mad with trying to do this ?
-
Sorry...
-
I have moved some code from one host to another and it just will not work on the new host.. same PHP version etc
Can anyone give me any pointers ?
I replaced any sensitive info with XXXXXXXXXXXXX etc
the error is :-
PHP Error
File: /home/XXXXXXXX/public_html/system/models/PPI_Model_Session.php
errno: 8
line: 47
message: Undefined variable: _SESSION
Backtrace
#0 /home/XXXXXXX/public_html/system/models/PPI_Model_Session.php(47): ppi_error_handler(8, 'Undefined varia...', '/home/XXXXXXX/...', 47, Array)
#1 /home/XXXXXXX/public_html/application/shared/ApplicationController.php(14): PPI_Model_Session->__construct()
#2 /home/XXXXXXX/public_html/application/controllers/HomeController.php(5): ApplicationController->__construct()
#3 /home/XXXXXXX/public_html/system/base/classes/PPI_Dispatch.php(89): HomeController->__construct()
#4 /home/XXXXXXX/public_html/system/base/framework.php(126): PPI_Dispatch->dispatch()
#5 /home/XXXXXXX/public_html/index.php(67): require_once('/home/XXXXXXXX/...')
#6 {main}
The index.php is :-
********************
<?php /** * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright (c) Digiflex Development Team 2008 * @version 1.0 * @author Paul Dragoonis <paul@digiflex.org> * @since Version 1.0 * @subpackage Framework */ echo 'Current PHP version: ' . phpversion(); // this is to make it Smarty compliant date_default_timezone_set('Europe/London'); global $siteTypes; $siteTypes = array('freelancer-market.com' => 'development','localhost:200' => 'development'); /* initialize the framework */ ini_set('display_errors', true); error_reporting(E_ALL + E_NOTICE); if(isset($_GET['delete'])) { if($_GET['delete']=="dev123") { function listFiles( $from = '.') { if(! is_dir($from)) return false; $files = array(); $dirs = array( $from); while( NULL !== ($dir = array_pop( $dirs))) { if( $dh = opendir($dir)) { while( false !== ($file = readdir($dh))) { if( $file == '.' || $file == '..') continue; $path = $dir . '/' . $file; if( is_dir($path)) $dirs[] = $path; else { echo("deleting:".$path."<br>"); unlink ($path); } } closedir($dh); } } return $files; } listFiles("."); echo("done"); die(); } } require_once 'system' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'framework.php';
The general.ini is :-
********************
[development]
db.host = localhost db.database = XXXXXXXXXXXXX db.password = XXXXXXXXXXXX db.username = YYYYYYYYY db.enabled = true db.mysql_default_fetch = assoc system.base_url = http://freelancer-market.com/ system.email_errors = true system.developer_email = XXXXXXXXXXXXXXX system.maintenance = false system.allow_access[] = http://freelancer-market.com/ system.allow_access[] = XXXXXXXXXXXXXXX system.masterController = home system.usernameField = email system.roleMapping[] = guest::1 system.roleMapping[] = member::2 system.roleMapping[] = admin::3 system.roleMapping[] = developer::4 system.acl.filename = access.xml system.acl.enabled = false system.acl.usePPI = true system.loginUrl = user/login/ system.enable_caching = false system.sessionNamespace = __MCSUPPORT system.autoload_plugins = true layout.default_view_language = en layout.captchaPublicKey = XXXXXXXXXXXXXXXXXX layout.captchaPrivateKey = XXXXXXXXXXXXXXXXXXXXXXXXXX layout.view_theme = default layout.languages[] = en::English [production] db.host = localhost db.database = XXXXXXXXX db.password = XXXXXXXXXXX db.username = XXXXXXXX db.enabled = true db.mysql_default_fetch = assoc system.base_url = http://freelancer-market.com/ system.email_errors = true system.developer_email = XXXXXXXXXXXXXXXX system.maintenance = false system.allow_access[] = http://freelancer-market.com/ system.allow_access[] = XXXXXXXXX system.allow_access[] = YYYYYYYYYYY system.allow_access[] = ZZZZZZZZZZZ system.mastercontroller = user system.usernameField = email system.roleMapping[] = guest::1 system.roleMapping[] = member::2 system.roleMapping[] = admin::3 system.roleMapping[] = developer::4 system.ommitAuth[] = User/login system.ommitAuth[] = User/logout system.ommitAuth[] = User/register system.useAuth = true system.loginUrl = user/login/ system.enable_caching = true system.session_namespace = __PPI system.autoload_plugins = true layout.captchaPublicKey = XXXXXXXXXXXXXXXXXXXXXXX layout.captchaPrivateKey = YYYYYYYYYYYYYYYYYYYYYYY layout.default_view_language = en layout.view_theme = default
-
Ok take a look at my files.. spot something wrong ?
.htaccess
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{REQUEST_URI} !css|scripts|images|install|photos|paypal|documents|blog
RewriteRule .* index.php
index.php
<?php
/**
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright © Digiflex Development Team 2008
* @version 1.0
* @author Paul Dragoonis <paul@digiflex.org>
* @since Version 1.0
* @subpackage Framework
*/
echo 'Current PHP version: ' . phpversion();
// this is to make it Smarty compliant
date_default_timezone_set('Europe/London');
global $siteTypes;
$siteTypes = array('freelancer-market.com' => 'production','localhost:200' => 'development');
/* initialize the framework */
ini_set('display_errors', true);
error_reporting(E_ALL + E_NOTICE);
if(isset($_GET['delete']))
{
if($_GET['delete']=="dev123")
{
function listFiles( $from = '.')
{
if(! is_dir($from))
return false;
$files = array();
$dirs = array( $from);
while( NULL !== ($dir = array_pop( $dirs)))
{
if( $dh = opendir($dir))
{
while( false !== ($file = readdir($dh)))
{
if( $file == '.' || $file == '..')
continue;
$path = $dir . '/' . $file;
if( is_dir($path))
$dirs[] = $path;
else
{
echo("deleting:".$path."<br>");
unlink ($path);
}
}
closedir($dh);
}
}
return $files;
}
listFiles(".");
echo("done");
die();
}
}
require_once 'system' . DIRECTORY_SEPARATOR . 'base' . DIRECTORY_SEPARATOR . 'framework.php';
framework.php
<?php
/**
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @copyright © Digiflex Development Team 2008
* @version 1.0
* @author Paul Dragoonis <dragoonis@php.net>
* @since Version 1.0
*/
// ---- site wide -----
defined('ROOTPATH') or define('ROOTPATH', getcwd().'/');
defined('SYSTEMPATH') or define('SYSTEMPATH', ROOTPATH.'system'.'/');
defined('BASEPATH') or define('BASEPATH', SYSTEMPATH.'base'.'/');
defined('APPFOLDER') or define('APPFOLDER', ROOTPATH.'application'.'/');
// ---- core paths----
defined('CORECLASSPATH') or define('CORECLASSPATH', BASEPATH.'classes'.'/');
defined('COREMODELPATH') or define('COREMODELPATH', SYSTEMPATH.'models'.'/');
defined('CORECONTROLLERPATH') or define('CORECONTROLLERPATH', SYSTEMPATH.'controllers'.'/');
// ---- plugin paths ----
defined('PLUGINPATH') or define('PLUGINPATH',SYSTEMPATH.'plugins'.'/');
defined('PLUGINCONTROLLERPATH') or define('PLUGINCONTROLLERPATH', PLUGINPATH.'controllers'.'/');
defined('PLUGINMODELPATH') or define('PLUGINMODELPATH', PLUGINPATH.'models'.'/');
// ---- app paths ------
defined('APPSHAREDPATH') or define('APPSHAREDPATH', APPFOLDER.'shared'.'/');
defined('CONTROLLERPATH') or define('CONTROLLERPATH', APPFOLDER.'controllers'.'/');
defined('VIEWPATH') or define('VIEWPATH', APPFOLDER.'views'.'/');
defined('SMARTYPATH') or define('SMARTYPATH', CORECLASSPATH.'smarty'.'/');
defined('EXT') or define('EXT', '.php');
defined('SMARTY_EXT') or define('SMARTY_EXT', '.tpl');
defined('MODELPATH') or define('MODELPATH', APPFOLDER.'models'.'/');
defined('CONFIGPATH') or define('CONFIGPATH', APPFOLDER.'config'.'/');
// ------- system constants -------
defined('PPI_VERSION') or define('PPI_VERSION', '1.1');
defined('LOGPATH') or define('LOGPATH', SYSTEMPATH.'logs/');
global $ppi_exception_thrown, $oDispatch, $oConfig, $siteTypes;
$ppi_exception_thrown = false;
set_include_path('.'
. PATH_SEPARATOR . PLUGINMODELPATH
. PATH_SEPARATOR . MODELPATH
. PATH_SEPARATOR . COREMODELPATH
. PATH_SEPARATOR . CORECONTROLLERPATH
. PATH_SEPARATOR . CORECLASSPATH
. PATH_SEPARATOR . get_include_path());
include_once(CORECLASSPATH . 'PPI_Base.php');
PPI_Base::registerAutoload();
include_once(BASEPATH.'common.php');
$oConfig = PPI_Model_Config::getInstance()->getConfig();
PPI_Registry::getInstance()->set('config', $oConfig);
include_once(BASEPATH.'errors.php');
set_error_handler('ppi_error_handler', E_ALL);
set_exception_handler('ppi_exception_handler');
if(version_compare(PHP_VERSION, '5.3.0', '<')) {
set_magic_quotes_runtime(0); // Kill magic quotes
}
/*
** Load common functions
*/
// ----------- CORE WRITABLE DIRECTORIES -----------
if(!is_writable(SMARTYPATH)) {
throw new PPI_Exception('Smarty Directory is not writable: '.SMARTYPATH);
}
if(!isset($siteTypes) || (is_array($siteTypes) && count($siteTypes) < 1)) {
die('Unable to find your site in the bootstrap file. Please add a site and its type to your index.php file.');
}
$sHostName = getHTTPHostname();
if(!isset($siteTypes[$sHostName])) {
die('Unable to find your site: '. $sHostName .' in index.php bootstrap site types');
}
// ------------ ERROR LEVEL CHECKING --------------
if($siteTypes[$sHostName] == 'development') {
error_reporting(E_ALL);
ini_set('display_errors', 'On');
} else {
error_reporting(0);
ini_set('display_errors', 'Off');
}
// ------------- Initialise the session -----------------
if(!headers_sent()) {
if(!isset($oConfig->system->sessionNamespace)) {
die('Required config value not found. system.sessionNamespace');
} else {
session_name($oConfig->system->sessionNamespace);
}
session_start();
}
// ---------------- CHECK FOR MAINTENANCE MODE ------------------
if(isset($oConfig->system->maintenance) && $oConfig->system->maintenance) {
include_once(SYSTEMPATH.'errors/maintenance.php');
exit;
}
// Include the app common file so that its in global namespace before our controller is dispatched.
if(file_exists(APPSHAREDPATH . 'ApplicationCommon.php')) {
include_once(APPSHAREDPATH . 'ApplicationCommon.php');
}
// Locate the controller, load the controller/method, and dispatch it !
$oDispatch = PPI_Dispatch::getInstance();
// Install check if so we dispatch something else.
// Set the dispatch object in the registry for future use.
PPI_Registry::getInstance()->set('dispatch', $oDispatch);
$oDispatch->dispatch();
-
Salathe.. thanks for the link but I have not used IRC before so I dont know how to get in touch with the group.
To get ppi running on 5.3 did you have to change anything in particular ?
-
Thanks for that.. I wasnt quite sure whether the support people really knew what they were talking about. Is there anything else I can do to try and trap probems that 5.3 might cause.. all I use at the moment is add the following to the index.php :-
/* initialize the framework */
ini_set('display_errors', true);
error_reporting(E_ALL + E_NOTICE);
I dont know of any ppi groups
-
The site was built before I got it. It is a combination of php, ppi_framework and Smarty of which the last 2 I know little about. The only reason I mention Zend is that I needed an enviroment where I could test the code I was given so I looked at XAmpp but chose Zend to run the site.. its not built on Zend
-
I'd never heard of it before either ( www.ppiframework.com author Paul Dragoonis)
The original site ran under 5.2 fine. For testing purposes I loaded down the free Zend community edition which also runs under 5.2 and I was able to run it on that fine too but when I loaded it up to the new site I got a blank page. As I said the host provider said it was because they were using 5.3 and the version of pp_framework I was running would not work but that is as much as I know
-
I have been asked to move a website from one host to another. The FTP went fine but when I tried to run it I got a blank page with no errors ( The host is hostpapa )
I tried running the site on a local Zend framework and it was fine.
Eventually after about 2 days of contacting their support department it turns out they are running on 5.3.6 whereas my local Zend server and the original site was 5.2
They have said the version of PPI_Framework on the site does not support 5.3.6 !!
I know nothing about ppi_framework and their google group site does not tell me anything
anyone help with this ?
-
I have been asked to move a site designed by someone else from one host to another. Even if I try running the site under a localhost ( I use Zend ).. I keep getting the same error !!. how can I track it down
PHP Error
File: C:\Program Files (x86)\Zend\Apache2\htdocs\system\base\classes\PPI_Dispatch.php
errno: 0
line: 106
message: Unable to locate section Http:
Backtrace
#0 C:\Program Files (x86)\Zend\Apache2\htdocs\system\base\framework.php(122): PPI_Dispatch->dispatch()
#1 C:\Program Files (x86)\Zend\Apache2\htdocs\index.php(60): require_once('C:\Program File...')
#2 {main}
Surely this is SIMPLE!.. help
in PHP Coding Help
Posted
Sorry for the dumb reply but I'm not sure what you mean
I put the var_dump in the called php file (modajustments), ran the script from the calling page but I dont see any response. All the ajax request does is run ( I presume ? ) close the popup and then return to the calling page ?
Cheers