facebook application error(im facing syntax error Parse error: syntax error

[php]<?php

/*


Version: 1.2

Created By:

Copyright © 2011


Created: 5/1/2011

*/

// class definition

class Gift {

// define properties
public $gid;
public function __construct() {
	$this->gid = null;
	$this->fields = array( 	'title' => '',
							'image' => '',
							'price' => 0,
							'category_title' => '');
}

// return an object populated based on the record's user id
public static function getById($gift_id) {

	$gift = new Gift();

	$row = mysql_fetch_assoc($res);

	$gift->gid = $gift_id;
	$gift->image = $row[gImage];
	$gift->price = $row[gPrice];
	$gift->hit = $row[gHit];
	$gift->category = $row[gCat];

	$rs = query("SELECT * FROM `gifts_category` WHERE `catid`=$row[gCat]");
	$rw = mysql_fetch_assoc($rs);

	$gift->category_title = $rw[catTitle];

	mysql_free_result($res);
	return $gift;
}

// save the record to the database
public function save() {

			`gTitle`=\"$this->title\",
			`gImage`=\"$this->image\",
			`gPrice`=$this->price,
			`gHit`=$this->hit,
			`gCat`=$this->category
			 	WHERE `gid`=$this->gid");
	}
}

}

?>

[/php]

are we supposed to guess what’s wrong??

apart from the title, you don’t really give any details??

sorry for that
when i deploy it on facebook its giving errer
Parse error: syntax error, unexpected ‘=’ in /home/username/public_html/gifts/inc/Gift.php on line 58

i have send u gifts.php code plz correct for me it will be great favour of u
[php]<?php

/*

Facebook Gift Store Application

Version:

Created By:

Copyright © 2011

Email:

Created:

*/

// class definition

class Gift {

// define properties
public $gid;
public function __construct() {
	$this->gid = null;
	$this->fields = array( 	'title' => '',
							'image' => '',
							'price' => 0,
							'category_title' => '');
}

// return an object populated based on the record's user id
public static function getById($gift_id) {

	$gift = new Gift();

	$row = mysql_fetch_assoc($res);

	$gift->gid = $gift_id;
	$gift->image = $row[gImage];
	$gift->price = $row[gPrice];
	$gift->hit = $row[gHit];
	$gift->category = $row[gCat];

	$rs = query("SELECT * FROM `gifts_category` WHERE `catid`=$row[gCat]");
	$rw = mysql_fetch_assoc($rs);

	$gift->category_title = $rw[catTitle];

	mysql_free_result($res);
	return $gift;
}

// save the record to the database
public function save() {

			`gTitle`=\"$this->title\",
			`gImage`=\"$this->image\",
			`gPrice`=$this->price,
			`gHit`=$this->hit,
			`gCat`=$this->category
			 	WHERE `gid`=$this->gid");
	}
}

}

?>

[/php]

it seems the error is in the save function, i have included it twice below as i’m not sure which one will work without being able to run the script and test it…

[php]
// save the record to the database
public function save() {

'gTitle'=$this->title,
'gImage'=$this->image,
'gPrice'=$this->price,
'gHit'=$this->hit,
'gCat'=$this->category
	"WHERE 'gid'"=$this->gid);
}

[/php]

[php]
// save the record to the database
public function save() {

	"'gTitle'=$this->title,
	'gImage'=$this->image,
	'gPrice'=$this->price,
	'gHit'=$this->hit,
	'gCat'=$this->category
	         \"WHERE 'gid'=$this->gid");
}

[/php]

Let me know if you have success (or not)
:wink:

hey thanx dude u saved my time
i modified little ur second code and it worked

following code worked for me
[php]// save the record to the database
public function save() {

             "'gTitle'=$this->title,
            'gImage'=$this->image,
             'gPrice'=$this->price,
           	 'gHit'=$this->hit,
            'gCat'=$this->category
                \"WHERE 'gid'=$this->gid";

          }
		  [/php]

one problem resolved another arised when i open admin panel managegift.php i get the following error

Parse error: syntax error, unexpected T_ELSE in /home/username/public_html/gifts/admin/managegift.php on line 72
here is managegift.php

[php]<?php

/*

=====================================================

Facebook Gift Store Application


Version: 1.2


Created By: Shyamal Borsaikia

=====================================================

Copyright © 2011 Shyamal Borsaikia

=====================================================

Email: [email protected]


Created: 5/1/2011

=====================================================

*/

require_once ‘admintop.php’;

if (in_array($user, $admins, TRUE)) {

echo '<P class=headerP>Manage Gift</P>';



if( !empty($_GET[del]) ) {

	query("DELETE FROM `gifts` WHERE `gid`=$_GET[del]");

	query("DELETE FROM `gifts_log` WHERE `gid`=$_GET[del]");



	echo '<div class=noticeBox><H2>Gift Details Deleted...</H2></div>';

}



// Page Navigation 

$res = query("SELECT COUNT(*) FROM `gifts`");

list($total) = mysql_fetch_array($res);



$limit=8;

if(!isset($_GET[page]))

	$page=1;

else

	$page=$_GET[page];



if($total>0)

{

	$p = new pagination();

	$p->Items($total);

	$p->limit($limit);

	$p->target('managegift.php');

	$p->currentPage($_GET['page']);

	$p->calculate();

	$p->changeClass("pagination");

}

		echo '<P>Hit: <B>'.$row[ghit].'</B></P>';



	$gift = Gift::getById($row[gid]);

	echo '<P>Category: <B>'.$gift->category_title.'</B></P>';

	

	echo '<BR><P><a href='.$appCanvasUrl.'admin/managegift.php?del='.$row[gid].'>Click To Delete</a></P>';



	echo '</td>';



	$counter++;

	if( $counter == 4 ) { 

		echo '</tr><tr>';

		$counter = 0;

	}

}



echo '</tr></table>';

else {

echo '<H1>You are not allowed to view this page....</H1>';

}

?>

[/php]

couple of errors i noticed: (i’ve made comments in the script)
[php]

<?php require_once 'admintop.php'; if (in_array($user, $admins, TRUE)) { echo '

Manage Gift

'; if( !empty($_GET[del]) ) { // at first glance there appears to be a variable sign missing below, maybe its correct? /* $ <-- is this missing? */ query("DELETE FROM `gifts` WHERE `gid`=$_GET[del]"); /* $ <-- is this missing? */ query("DELETE FROM `gifts_log` WHERE `gid`=$_GET[del]"); echo '

Gift Details Deleted...

'; } // Page Navigation $res = query("SELECT COUNT(*) FROM `gifts`"); list($total) = mysql_fetch_array($res); $limit=8; if(!isset($_GET[page])) $page=1; else $page=$_GET[page]; if($total>0) { $p = new pagination(); $p->Items($total); $p->limit($limit); $p->target('managegift.php'); $p->currentPage($_GET['page']); $p->calculate(); $p->changeClass("pagination"); } echo '

Hit: '.$row[ghit].'

'; $gift = Gift::getById($row[gid]); echo '

Category: '.$gift->category_title.'

'; echo '

Click To Delete

'; echo ''; $counter++; if( $counter == 4 ) { echo ''; $counter = 0; } } echo ''; // <-- this can't be here it needs to be in the IF or ELSE or above/below it, // it cant break up the if/else statement, and is probably what the error is refering to! else { echo '

You are not allowed to view this page....

'; } //<-- put the tags here! ?>[/php]

Let me know how you get on
:wink:

hey im facing lot of problems i want to send u the whole script,i had jus wasted the money,…plz send me your email.

i will upload it for you

i have send u the download link for full application plz download

i was able to resolve everything only one problem im facing now
when i send gift i recieve following error…

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/gifts/inc/Gift.php on line 23

Fatal error: Using $this when not in object context in /home/username/public_html/gifts/inc/Gift.php on line 29

here is gift.php code
[php]<?php

class Gift {

// define properties 

public $gid; 

public function __construct() { 
    $this->gid = null; 
    $this->fields = array(     
            'title' => '', 
            'image' => '', 
                            'price' => 0, 
                            'category_title' => ''
            ); 
} 

// return an object populated based on the record's user id 

public static function getById($gift_id) { 
    $gift = new Gift(); 
    $row = mysql_fetch_assoc($res); 
    $gift->gid = $gift_id; 
    $gift->image = $row["gImage"]; 
    $gift->price = $row["gPrice"]; 
    $gift->hit = $row["gHit"]; 
    $gift->category = $row["gCat"];      
    $rs = query("SELECT * FROM `gifts_category` WHERE `catid` = $gift->category"); 
    $rw = mysql_fetch_assoc($rs); 
    $gift->category_title = $rw["catTitle"]; 
    mysql_free_result($res); 
    return $gift; 
} 

// save the record to the database 
public function save() { 
   mysql_query("UPDATE 'gifts_category' SET 
            `gTitle` = ".$this->title.",
            `gImage` = ".$this->image.", 
            `gPrice` = $this->price, 
            `gHit`   = $this->hit, 
            `gCat`   = $this->category 
             WHERE `gid` = $this->gid"); 
    } 
} 

?> [/php]

sorry this is the error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/username/public_html/gifts/inc/Gift.php on line 23
Invalid query – SELECT * FROM gifts_category WHERE catid= – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

Hello,

The code you posted below looks fine, thats the good news,

Now the bad news :’(

I picked up the download and i’m just looking at it now…
…I have to say… what a mess!

There are plenty of errors in here, and i’m not going to re-write the authors code for him/her, a quick search on google reveals that this particular script is well known for errors (It has NEVER worked without the user fixing it first!!)

I’ll have a tinker with it and if i get it working i will email you with the corrections, thats the best i can offer i’m afraid… :frowning:

Hi

This script have too many error. i was try to fix it in 3 days. but i fail… it’s not working… :frowning:
Redscouse, if u get it working, dont forget to email me too. sharing with me please… Thank in advance

Hi mate :smiley:

I haven’t forgotten, i just haven’t looked at it properly yet, i’ve been a little busy with a project of my own recently, however its nearing completion so should be able to look at your script soon.

Of course i will send it to you if i fix it (i will let you know either way)

Cheers

Red :wink:

I sent you a message earlier today, stating i’d deployed the scripts and tested and i’m seeing a blank page only…

well here’s an update that will probably make you an un-happy person (but please don’t shoot the messenger :P)
I just stumbled upon this:
“this application code will not be supported any more from March 11, 2011 as facebook is deprecate FBML and FBJS from this date.” See http://developers.facebook.com/blog/post/462/

so i’m afraid it looks like the app you bought is useless today :o :’(

Sponsor our Newsletter | Privacy Policy | Terms of Service