Jump to content

Unexpected T_IF


adamjones

Recommended Posts

Hi, I keep getting this error;

 

Parse error: syntax error, unexpected T_IF in ../payments.php on line 120

 

This is my code;

 

<?php
require_once('config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

$sql="SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'"
if (mysql_num_rows($sql) > 0) {
while($rows=mysql_fetch_array($sql)){
?>

 

Not really sure why I'm getting this error... :S

Any help would be appreciated!

Link to comment
Share on other sites

Hi, I keep getting this error;

 

Parse error: syntax error, unexpected T_IF in ../payments.php on line 120

 

This is my code;

 

<?php
require_once('config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

$sql="SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'"
if (mysql_num_rows($sql) > 0) {
while($rows=mysql_fetch_array($sql)){
?>

 

Not really sure why I'm getting this error... :S

Any help would be appreciated!

 

$sql="SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'"

 

Is not ended with a ;

Link to comment
Share on other sites

Thanks, but now I get this error;

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

 

<?php
require_once('config.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

$sql="SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'";
if (mysql_num_rows($sql) > 0) {
?>
						<table cellspacing="0">
							<thead>
								<tr>
									<th>Service</th>
                                        <th>Domain</th>
									<th>Due Date</th>
									<td class="tc">Amount</td>
                                        <td class="tc">Payment</td>
								</tr>
							</thead>
							<tbody>
                                <?php while($rows=mysql_fetch_array($sql)){ ?>
								<tr class="first"><!-- .first for first row of the table (only if there is thead) -->
									<th><?php echo $rows['info']; ?></th>
                                        <th><?php echo $rows['domain']; ?></th>
                                        <td><?php echo $rows['duedate']; ?></td>
		              <td class="tc"><a class="ico-pay" href="#">£<?php echo $rows['amount']; ?></a></td><!-- a.ico-comms for comment-like backgrounds -->
									<td valign="bottom" class="tc"><div align="center"><a href="./pay_paypal?v=<? echo $rows['amount']; ?>&id=<? echo $rows['id']; ?>" target="_blank"><img src="css/img/paypal.gif"><br></a>
							        Prefer not to pay via credit card? You can also pay in person.<br>
								    </div></td>
							  </tr>
                                    <?php
}
}
?>
							</tbody>
						</table>
                            <?php
mysql_close();
?>

Link to comment
Share on other sites

You need to pass your sql query to mysql_query first!

 

$sql="SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'";
if (mysql_num_rows($sql) > 0) {

 

Oops! Ok, I changed it to;

 

$result = mysql_query("SELECT amount FROM payments WHERE user='".$_SESSION['user']."' AND member_id='".$_SESSION['id']."'");
if (mysql_num_rows($result) > 0) {

 

But I'm still getting this error;

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.