Page 1 of 1

Novice needs your help!!!

Posted: Tue Feb 25, 2003 12:54 pm
by Charles Tinkle
Hi,
I know very little about php and am desperate for some help. I have a classified program that can have credits allocated to the user. e.g. 50 credits = 50 ads. The problem is when an ad is deleted it removes a credit and leaves the user with 49 credits and admin has to re-credit them. I can stop the program from removing the credit but it leaves the user with unlimited ads. Now this bit of code, when the user reaches zero credits, sends them to a payment page, but if it was altered so that it sent them when ads = credits, that would solve the problem.


The code for ads is

Code: Select all

$ad_num
and the MySQL query is

Code: Select all

if (!$credits)
	{
		$sql = "update $usr_tbl set credits = 0 where email = '$valid_user'";
		$r = mysql_query($sql);
	}

	if ($credits < 1 and !$siteid)
	&#123;
		print "<hr />$la_credits_warning";
		$la_to_addcre = ereg_replace("\&#123;PAYMENTPAGE\&#125;", "<a href='payment_options.php'><b>paymentpage</b></a>", $la_to_addcre);
		print "<p />$la_to_addcre.<hr />";
The person who wrote the code only supports it when its paid for but the trouble is I have to pay for it to find out if it can be modified. Catch 22.

Thanks :cry:

Posted: Wed Feb 26, 2003 10:02 am
by daven
Thought: When a user deletes an advert, just have a credit tossed back onto their account (do the reverse of what happens when they create an advert).

Posted: Wed Feb 26, 2003 12:37 pm
by Charles Tinkle
Hi,
if you do that, the user ends up with unlimited ads as there is no way to check how many ads have been placed. It only stops the user from placing ads when credits = 0. Further up the file is code that deletes a credit when an ad is placed and I can stop the program from deleting credits when an ad is placed.

The code I have shown checks how many credits are left and if 0 send the user to the payment page. If the query was

Code: Select all

if ($credits = $adnum and !$siteid)

instead of

Code: Select all

if ($credits < 1 and !$siteid)
it would direct the user when ads = credits to the payment page but that alteration does not work and its probably because the way I have written it is wrong. " if ($credits = $adnum and !$siteid) "

Posted: Wed Feb 26, 2003 1:19 pm
by daven
ah. you want to use "==" instead of "=". A single "=" is for assignment, a double "==" is for comparison.

Code: Select all

if ($credits == $adnum and !$siteid)