I have a paypal form which is submitted and working, this is part of the ipn, which means I can not see the error reporting on page which means I am a little blind on what is the issue.
Everything looks fine I think.
Here is the code:
$newcustom = rtrim($_POST['custom'], ',');
$buyingarray = explode('~', $newcustom);
$name = $buyingarray[1];
$phone = $buyingarray[2];
$email = $buyingarray[3];
$comments = $buyingarray[4];
$date = $buyingarray[5];
$time = explode(",",$tt[6]);
$person = explode(",",$tt[7]);
$orderID = $tt[0];
$booking_date = strtotime($date);
$nowitsdate = date('Y-m-d G:i:s', strtotime("now"));
$addreservation = $pdo->prepare("INSERT INTO reservations (id, dateCreated, name, email, phone, comments, status, eventID, voucherCode, voucherplace, OrderID) VALUES ('', :dateCreated, :name, :email, :phone, :comments, 1, NULL, '', 'PayPal Purchase', :OrderID)");
$addreservation->execute(array(':dateCreated' => $nowitsdate,':name' => $name,':email' => $email,':phone' => $phone,':comments' => $comments,':OrderID' => $orderID));
$addreservation_num = $addreservation->rowCount();
if($addreservation_num == 0){ $inserterror = $pdo->query("INSERT INTO testipn (id, testing, testing2) VALUES ('','Input into reservations died','')"); exit();}
Now I know that everything is ok with the details coming in as I have input each of the variables into the testipn row which is telling me if an error occurred when the ipn is being used.
As far as I can see everything looks fine yet it still is not finding the problem.
Now the only thing I can think it can be is the NULL within the eventID, maybe that is causing an issue?
If a ID is not present which it wont be within this table, then it needs to be NULL.
The rows effected is 0 which means my error row in the database says: Input into reservations died
Thanks for any input into finding a solution :)
Related
I'm quite new to CakePHP and have an issue. I'm trying to update one field in a row with this:
$options = array('conditions' => array('User.id' => $_POST['userid']));
$user = $this->User->find('first', $options);
$currentpoint = $user['User']['point'];
$correctanswerpoint = Configure::read('CORRECT_SYSTEMANSWER_POINT');
$newpoint = $currentpoint + $correctanswerpoint;
$this->User->updateAll(array('User.point'=>$newpoint), array('User.id'=>$_POST['userid']));
There are no errors, but the field point (bigint(20)) is not being updated. I've changed the field to update to another one in the same row which is of smallint type and the update goes through fine.
My debugging log seems to show that the SQL query is ok too:
[query] => UPDATE `askyoode_askyoo`.`users` AS `User` LEFT JOIN `askyoode_askyoo`.`countries` AS `Country` ON (`User`.`country_id` = `Country`.`id`) LEFT JOIN `askyoode_askyoo`.`accesstypes` AS `Accesstype` ON (`User`.`accesstype_id` = `Accesstype`.`id`) SET `User`.`point` = 57 WHERE `User`.`id` = 124
[params] => Array
(
)
[affected] => 1
[numRows] => 1
[took] => 12
)
And manually running the same SQL statement in MySQL works. Been tearing out my hair for the whole day trying to resolve this. Any help is greatly appreciated. Thanks!!
I have a registration action in Zend controller and I want to ensure that given username isn't already in the database.
$tUser = $userMapper->getDbTable();
$select = $tUser->select()
->from(array('u'=>'users'))
->where('u.user_username = ' . $value);
$row = $tUser->fetchRow($select);
Unfortunately, this snippet of code throws the Exception when i just want to check the $row is null or not and keep writing my code.
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'admin' in 'where clause', query was: SELECT u.* FROM users AS u WHERE (u.user_username = admin) LIMIT 1
Should I remove the try/catch blocks in my controller or can I do it in another way?
Judging by error description, I'd say it will throw an exception always, no matter if user exists or not, because bad SQL query will be generated. Try passing $value as second parameter to where, like this:
$tUser = $userMapper->getDbTable();
$select = $tUser->select()
->from(array('u'=>'users'))
->where('u.user_username = ?', $value);
$row = $tUser->fetchRow($select);
You will then check if user exists like this:
if(!$row) {
// user doesn't exist
} else {
// user exists
}
try {
$tUser = $userMapper->getDbTable();
$select = $tUser->select()
->from(array('u'=>'users'))
->where('u.user_username = ?', $value);
$row = $tUser->fetchRow($select);
} catch (Zend_Db_Exception $e) {
echo "<pre>";print_r($e);
}
I have the following tables in my database.
subscriber(
subscriber_id int,
status char(1),
...
)
sendlist(
sendlist_id int,
...
)
subscriber_list(
subscriber_id int,
sendlist_id int,
status char(1)
)
in my SendList model I have a relation defined as follows:
'Subscribers'=>array(self::MANY_MANY, 'Subscriber', 'subscriber_list(sendlist_id, subscriber_id)',"on"=>"Subscribers_Subscribers.status='a' and Subscribers.status='a'")
I have tried setting both the on and condition clause, and one or the other, however the sole Subscriber in the table at present (linked to this sendlist) is ALWAYS returned, regardless of whether it's status in the subscriber table, or the subscriber_list table is set to 's'.
When I check the DB - the query that the join supposedly gives something along the lines of:
SELECT `Subscribers`.`subscriber_id` AS `t1_c0`, `Subscribers`.`full_phone` AS `t1_c1`, `Subscribers`.`status` AS `t1_c2`, `Subscribers`.`contact` AS `t1_c3`, `Subscribers`.`client_id` AS `t1_c4`, `Subscribers`.`date_joined` AS `t1_c5` FROM `subscriber` `Subscribers`
INNER JOIN `subscriber_list` `Subscribers_Subscribers` ON (`Subscribers_Subscribers`.`sendlist_id`=7075) AND (`Subscribers`.`subscriber_id`=`Subscribers_Subscribers`.`subscriber_id`) AND (Subscribers.status='a' and Subscribers_Subscribers.status='a')
WHERE (Subscribers.status='a' and Subscribers_Subscribers.status='a');
returns an empty set (as it should). But when I print_r the $list->Subscribers array, I get the following:
Array(
[0] => Subscriber Object
(
...
[_attributes:CActiveRecord:private] => Array
(
[subscriber_id] => 2043221
[full_phone] => 447944426885
[status] => s
[contact] => 0
[client_id] => 14002
[date_joined] =>
)
so it recognises that the subscriber is status 's', but still loads it!
The code that causes the issue is here:
$client = new Client();
$client->save(false);
//ensure that we are working with a clean subscriber set.
$subscribers = Subscriber::model()->findAll();
foreach($subscribers as $subscriber){
$subscriber->delete();
}
//create a new subscriber with a set of filter options.
$subscriber = new Subscriber();
$subscriber->client_id = $client->client_id;
$subscriber->full_phone = "44712345678";
$subscriber->country = "England";
$subscriber->gender = "Male";
$subscriber->save(false);
//create a new list with a set of matching options
$list = new SendList();
$list->client_id = $client->client_id;
$list->gender = "=Male";
$list->save(false);
//confirm that the subscriber can be added to the list.
self::assertTrue($list->canImport($subscriber));
$list->import();
//confirm that the subscriber has been added to the list.
self::assertEquals(1, $list->active_subscriber_count);
self::assertEquals(1, sizeof($list->Subscribers));
//remove all subscribers (set status to 's')
$list->remove();
//check that the list no longer records the subscribers presence.
self::assertEquals(0, $list->active_subscriber_count);
self::assertEquals(1, $list->stopped_subscriber_count);
//check that the subscriber has no lists associated with it.
$subscriber->refresh();
self::assertEquals('s', $subscriber->status, sizeof($subscriber->SendLists));
//attempts to refresh the list. Tested without these with the same result.
$list_id = $list->sendlist_id;
unset($list);
unset($subscriber);
$list2 = SendList::model()->findByPk($list_id);
$list2->refresh();
//check that the the list has no subscribers - this fails.
self::assertEquals(0, sizeof($list2->Subscribers));
Have I missed something silly?
I have a problem when saving array into session data in Codeigniter.
var_dump($this->session->userdata('data')); // output is boolean false
$array = array(0 => 'abc', 1 => 'def', 2 => 'ghi');
$this->session->set_userdata(array('data' => $array, 'name' => 'my_name'));
var_dump($this->session->userdata('data')); // output is 0 => 'abc', 1 => 'def', 2 => 'ghi'
Everytime page is loaded "userdata('data')" is lost but other userdata is ok. It means only this array is lost. I'm 100% sure it can work, it worked for me before i did lot of modifications, so now i can't find solution.
Thanks.
I have found what's the problem. Codeigniter has some limits in session, my array was too big.
More info here
It's seems that the cookies are disabled in your navigator.
You need to use a database. The 4kb limit is a browser limit for cookie sizes. It's generally a good practice to keep cookies and session small, since every request header to an object on a server (for the same domain) will send this cookie.
Also, a good tip for CI concerning database session table's, set the type to MEMORY, so that the sessions are stored in RAM instead of disk, which makes your site quicker.
The SQL
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(16) DEFAULT '0' NOT NULL,
user_agent varchar(50) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id)
);
CI Configuration (in application/config/config.php):
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
Noob here.
I have a super column family sorted by timeuuidtype which has a number of entries. I'm trying to perform a simple get function with phpcassa that wont work. I'm trying to return a specific value from a UTF8 sorted column within a TimeUUID sorted SC. The exact code works with a similar SC Family sorted by BytesType.
Here is the info on the scf I'm trying to get from which i previously entered via -cli.
ColumnFamily: testSCF (Super)
Columns sorted by: org.apache.cassandra.db.marshal.TimeUUIDType/org.apache.cassandra.db.marshal.UTF8Type
RowKey: TestKey
=> (super_column=48dd0330-5bd6-11e0-adc5-343960c1b6b8,
(column=test, value=74657374, timestamp=1301603831288000))
=> (super_column=141a69b0-5c6e-11e0-bcce-343960c1b6b8,
(column=new test, value=6e657774657374, timestamp=1301669004440000))
And here is the phpcassa script I'm using to retrieve the data.
<?php
require_once('.../connection.php');
require_once('.../columnfamily.php');
$conn = new Connection('siteRoot');
$scf = 'testSCF';
$key = 'testKey';
$super = '141a69b0-5c6e-11e0-bcce-343960c1b6b8';
$col = 'new test';
$entry = new ColumnFamily($conn, $scf);
$q = ($entry->get($key, $columns=array($super)));
echo $q[$super][$col];
?>
Also if I don't specify the SC like so.
$q = ($entry->get($key));
print_r($q);
It returns:
Array ( [HÝ0[ÖàÅ49`Á¶¸] => Array ( [test] => test ) [i°\nà¼Î49`Á¶¸] => Array ( [new test] => newtest ) )
I know part of the issue might have been brought up in How do I insert a row with a TimeUUIDType column in Cassandra?
But it didn't really help me as I presumably have accepted timeuuidtypes.
Thanks for any help guys.
Suppose I didn't try hard enough to begin with. The answer in fact was everything to do with the link.
Appears that the -cli accepted what jbellis in the link describes as 32 byte representation of the timeUUID (141a69b0-5c6e-11e0-bcce-343960c1b6b8) when I inserted it. This confused me.
It works fine when you 'get()' with the "raw" 16 byte form (HÝ0[ÖàÅ49`Á¶¸).
Cheers.