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
https://forums.phpfreaks.com/topic/189770-unexpected-t_if/
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
https://forums.phpfreaks.com/topic/189770-unexpected-t_if/#findComment-1001468
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
https://forums.phpfreaks.com/topic/189770-unexpected-t_if/#findComment-1001469
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
https://forums.phpfreaks.com/topic/189770-unexpected-t_if/#findComment-1001485
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.