Novice needs your help!!!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Charles Tinkle
Forum Newbie
Posts: 2
Joined: Tue Feb 25, 2003 12:54 pm

Novice needs your help!!!

Post 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:
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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).
Charles Tinkle
Forum Newbie
Posts: 2
Joined: Tue Feb 25, 2003 12:54 pm

Post 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) "
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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)
Post Reply