Sunday, 1 September 2013

Removing array element does not work

Removing array element does not work

there is a $_SESSION array that holds the ID of user's currently selected
products (which are in the cart). Now, when the user sees his bill, he
want to remove an item (product) from his cart, I have put him a link to
do so. but the script does not work. I have configured a $_GET['itemid']
in the URL and by using it, I unset() that array element.
BUT it does not work. What should I do? Here is my code
function remove_from_cart($stack_id) // stack_id is the id of the item in
cart array ($_SESSION)
{
for($i=0; $i < count($_SESSION['add-to-cart-item']); $i++)
{
if($_SESSION['add-to-cart-item'][$i] == $stack_id)
{
unset($_SESSION['add-to-cart-item'][$stack_id]);
}
}
}

Saturday, 31 August 2013

iOS - Facebook: "(#100) Array does not resolve to a valid user ID";

iOS - Facebook: "(#100) Array does not resolve to a valid user ID";

In my app I post location, friends and photos to the user's wall. It works
just fine, except when I try to tag a friend and not upload a photo, then
I get the error:
Error ===== Error Domain=com.facebook.sdk Code=5 "The operation couldn't
be completed. (com.facebook.sdk error 5.)" UserInfo=0xa5e9620
{com.facebook.sdk:HTTPStatusCode=400,
com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Array does not resolve to a valid user ID";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x97a4b70, state:
FBSessionStateOpen, loginHandler: 0x97a4c00, appID: 534257903313640,
urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy:
0xa5e2ac0>, expirationDate: 2013-10-31 02:09:29 +0000, refreshDate:
2013-09-01 02:55:35 +0000, attemptedRefreshDate: 0001-12-30 00:00:00
+0000, permissions:(
"video_upload",
"basic_info",
"publish_stream",
installed,
"status_update",
"user_friends",
"create_note",
"share_item",
"photo_upload",
"publish_actions"
)>}
I have no problem tagging a friend when I also upload a photo, and I have
no problem posting just a place to the wall also.
Here's my code:
- (IBAction)post2:(id)sender {
if ([FBSession.activeSession.permissions
indexOfObject:@"publish_actions"] == NSNotFound) {
// No permissions found in session, ask for it
NSArray *permissions = [[NSArray alloc]
initWithObjects:@"publish_actions", @"upload_photos", nil];
[FBSession.activeSession requestNewPublishPermissions:permissions
defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error) {
if (!error) {
[self post2:sender];
return;
// If permissions granted, publish the story
}
}];
}
else {
NSString *apiPath = nil;
NSMutableDictionary *params = [NSMutableDictionary
dictionaryWithObjectsAndKeys:@"oi", @"message", nil];
NSMutableArray *tags = [[NSMutableArray alloc] init];
if (self.foodPicture)apiPath = @"me/photos";
else apiPath= @"me/feed";
if(self.selectedPlace.id) {
[params setObject:self.selectedPlace.id forKey:@"place"];
}
NSString *tag = nil;
if(self.selectedFriends != nil) {
for (NSDictionary *user in self.selectedFriends) {
tag = [[NSString alloc]
initWithFormat:@"{\"tag_uid\":\"%@\"}",[user
objectForKey:@"id"] ];
[tags addObject:tag];
}
NSString *friendIdsSeparation=[tags
componentsJoinedByString:@","];
NSString *friendIds = [[NSString alloc]
initWithFormat:@"[%@]",friendIdsSeparation ]; [params
setObject:friendIds forKey:@"tags"];
}
if (self.foodPicture) {
[params setObject:self.foodPicture forKey:@"picture"];
}
FBRequest *request = [[FBRequest alloc] initWithSession:[FBSession
activeSession] graphPath:apiPath parameters:params
HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBRequestConnection *connection,
id result, NSError *error) {
if (error) {
NSLog(@"Error ===== %@",error.description);
}
else {
NSLog(@"eba!");
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Posted!" message:@"" delegate:self
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}];}
Thanks for the help

Multiple channel's message comes into single channel

Multiple channel's message comes into single channel

i am fresher of Spring Integration, i am confuing one question which i
have multiple channels but now i want to assemble messages from those
channel into single channel, how to implement it ? my senario is that i
have lots of businees modues and each module will corresponding to one
channel, those channels will receive the request then assemble the message
into one single channel , then output to the jms server:
is below code possible ?
<channel id='a'/> <bridge input-channel='a' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='b' out-channel='assembled'/>
<channel id='b'/> <bridge input-channel='c' out-channel='assembled'/>
<channel id='c'/> <bridge input-channel='d' out-channel='assembled'/>
<channel id='assembled'/>
<!-- the router will desicde which jms gateway to be sent -->
<router input-channel='assembled' >
<channel id='to_jms1'/>
<channel id='to_jms2'/>
<jms-outbound-gateway id='jms1' channel='to_jms1'/>
<jms-outbound-gateway id='jms2' channel='to_jms2'/>

DB_DataObject and PDO

DB_DataObject and PDO

I was told that using PDO is recommended to make my code more secure from
mysql injections.
I am currently using DB_DataObject that I read that cleans the input from
injections as well
(http://pear.php.net/manual/en/package.database.db-dataobject.php) Do I
still need to use PDO or DB_Dataobject should be ok ? Also can I combine
them together and if yes how.
Example part of my DB statement
$password=encryptpass($_REQUEST['password']);
$user->query("select username from {$user->__table} where
(username = '$username' or email='$username') AND password =
'$password' ");
Thanks

UIBarButton does not go back to Menu

UIBarButton does not go back to Menu

This may be a simple answer, but I am new to this... my back button in the
navigation bar is confused and does not want to go back to the Main Menu.
Instead, it goes back to the previous view. How can I specify in my app
that the "back" button should always go to to a specific view?

Accessing a mobile users phone number

Accessing a mobile users phone number

When a user is browsing a mobile site, I'd like to pre-populate the phone
number field of a form with the phone number of that mobile device. Is
that possible with a plan old html5 site?

HTML checkbox when select all tick doesn't show

HTML checkbox when select all tick doesn't show

<table class="list" id="example">
<thead>
<tr>
<td class="first" width="1" style="text-align: center;"><input
type="checkbox"
onclick="$('input[name*=\'selected\']').attr('checked',
this.checked);"></td>
<td class="left">
Username
</td>
<td class="left">
Status
</td>
<td class="left">
Date Added
</td>
<td class="right">
Action
</td>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;"><input type="checkbox"
name="selected[]" value="2">
</td>
<td class="left">testing</td>
<td class="left">Enabled</td>
<td class="left">31/08/2013</td>
<td class="right"> [ <a href="">Edit</a> ]</td>
</tr>
<tr>
<td style="text-align: center;"><input type="checkbox"
name="selected[]" value="1">
</td>
<td class="left">admin</td>
<td class="left">Enabled</td>
<td class="left">31/03/2013</td>
<td class="right">[ <a href="">Edit</a> ]</td>
</tr>
</tbody>
</table>
I got a checkbox when click will select all others checkbox, the first
time click the select all, others check box will checked shown tick. But
When uncheck the select all and select it again, the others checkbox
doesn't shown tick but when view source code checked="checked" does shown