Jump to content

Up For A Challenge?


techiefreak05

Recommended Posts

If you're bored .. you can help me ... even the most expeirenced PHP user will have a toughie with this ...

With the following code i get an "unexpected $end" on line 91 ... which is funny cuz a min ago it said 215 .. and then 232 and i dont even have a line 215 or line 232 .... i commented in line 91 so you can see ... this is the ENTIRE code for my page...about 192 lines ... of which i can find no error .. this is a very crucial age.... any help would be more than appreciated.. you have no idea....
ready for the code??

here it is::

[code]<?php
session_start();
include("func.php");
include("login.php");
?>

<? PageTop() ?>

  <?php
if($logged_in){
function emailUsed($new_email){
   global $conn;
   if(!get_magic_quotes_gpc()){
      $new_email = addslashes($new_email);
   }
   $q = "select email from users where email = '$new_email'";
   $result = mysql_query($q,$conn);
   return (mysql_numrows($result) > 0);
    }
?>
<b>Account Information</b><br><br>
<table cellpadding="2" cellspacing="2">
<tr>
<td align="center">
<div id="form">
Here you can edit your account settings and your <b>zPage Information</b><i>(below)</i>.<br><br><font color="#FFFFFF">You may enter HTML into any area but with some limitations.</font>
</div>
</td>
</tr>

<tr>
<td>
<! -- UPDATE EMAIL - !>
<?php
if($_POST['updateI']){
$new_email = mysql_real_escape_string(trim($_POST['emailNew']));
$username = $_SESSION['username'];
   if(emailUsed($_POST['emailNew'])){
         $new_email = $_POST['emailNew'];
         die("Sorry, the email address (<i>{$new_email}</i>) provided is already in use");
   }else{
$sql = "UPDATE `users` SET `email` = '$new_email' WHERE `id` = '$_SESSION[id]'";
$query = mysql_query($sql) or die(mysql_error());
}
}
?>
<?php
$sql = "SELECT * FROM users WHERE id = '$_SESSION[id]' LIMIT 1";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "<center>Current E-mail: <b>" .$row['email']. "</b>";
}
?>
<form action="" method="post">
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td ><font color=black>New E-mail:*</font></td><td><input type="text" name="emailNew" maxlength="30"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="updateI" value="-Update-"></td></tr>
</table>
<! - END EMAIL - !>
<br>
<! -- UPDATE DISPNAME - !>
<?php
if($_POST['updateDISP']){
$new_disp = $_POST['dispNew'];
$_SESSION['disp_name'] = $new_disp;
$sql = "UPDATE `users` SET `dispname` = '$new_disp' WHERE `id` = '$_SESSION[id]'";
$query = mysql_query($sql) or die(mysql_error());
}
?>
<?php
$sql = "SELECT * FROM users WHERE id = '$_SESSION[id]' LIMIT 1";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "Current Display Name: <b>"  .$row['dispname']. "</b>";
}
?>
<form action="" method="post">
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td ><font color=black>New Display Name:</font></td><td><input type="text" name="dispNew" maxlength="2500"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="updateDISP" value="-Update-"></td></tr>
</table>
</form>
<! - END DISPNAME - !>

<! - UPDATE FNAME - !>
<?php
if($_POST['updateFNAME']){
$username = $_SESSION['username'];
$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));

// 91 - THIS IS LINE 91, THIS COMMENT IS NOT IN MY CODE// $sql = "UPDATE `users` SET `fname` = '$new_name' WHERE `username` = '$username'";
$query = mysql_query($sql) or die(mysql_error());

$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
echo "Current First Name:<b> " .$row['fname']. "</b>";
}
}
?>
      <table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td ><font color=black>New First Name:</font></td><td><input type="text" name="fnameNew" maxlength="30"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="updateFNAME" value="-Update-"></td></tr>
</table>
<table align="center" border="0" cellspacing="0" cellpadding="3">
<tr><td colspan="2" align="right"><input type="submit" name="updateALL" value="-Save All-"></td></tr>
</table>
    </form>

<font color="red">* = This piece of information is <i>NOT</i> displayed when users "Get Info" about you.</font>
<!-  END FNAME - !>

<! - UPDATE ALL - !>
<?php
if($_POST['updateALL']){
$new_name = mysql_real_escape_string(trim($_POST['fnameNew']));
$new_email = mysql_real_escape_string(trim($_POST['emailNew']));
$new_disp = mysql_real_escape_string(trim($_POST['dispNew']));
$username = $_SESSION['username'];
if(emailUsed($_POST['emailNew'])){
      $new_email = $_POST['emailNew'];
      die("Sorry, the email address (<i>{$new_email}</i>) provided is already in use<br><br><center><A HREF='index.php' class='box'> Return Home</a>");
   }else{

$sql = "UPDATE `users` SET `fname` = '$new_name', `email` = '$new_email' `dispname` = '$new_disp' WHERE `username` = '$username'";
$query = mysql_query($sql) or die(mysql_error());
?>
<meta http-equiv="refresh" content="0">
<?
}
}
?>
<!-  END ALL - !>
<hr>
<b>zPage Profile Information - <a href="http://profiles.zycoworld.com/index.php?id=<?php echo $_SESSION[id]; ?>" class="blue">[View zPage]</a></b>

<?php
function hasProfile($a){
   global $conn;
   $q = "select * from `zpageinfo` where `id` = '$a'";
   $result = mysql_query($q,$conn);
   return (mysql_num_rows($result) > 0);
}
if(!hasProfile($_SESSION[id])){
?>
<div align="right">
<form action="" method="post">
<input type="submit" value="Create zPage" name="zCreate">
</form>
</div>
<?php
}
?>
<br><br>
</td>
</tr>
</table>
<?php
if($_POST['zCreate']){
echo "<font color=red>zPage Created!</font>";
mysql_query("INSERT INTO `zpageInfo` SET `id` = '$_SESSION[id]'") or die(mysql_error());
}

if($_POST['zpageUPDATE']){
echo "<b><font color=red>zPage Updated!</font></b><br><br>";
$sql = "UPDATE `zpageInfo` SET `location` = '$_POST[location]', `film` = '$_POST[film]', `literature` = '$_POST[literature]', `music` = '$_POST[music]', `aboutme` = '$_POST[aboutme]', `friends` = '$_POST[friends]', `gender` = '$_POST[gender]' WHERE `id` = '$_SESSION[id]'";
$query = mysql_query($sql) or die(mysql_error());
}

$sql = "SELECT * FROM zpageInfo WHERE id = '$_SESSION[id]' LIMIT 1";
$query = mysql_query($sql);
while($row = mysql_fetch_array($query)) {
?>
<form action="" method="post">
Location: <br><input type="text" name="location" value="<?php echo $row[location];?>" size="100"><br><br>
Gender:<br>Male<input type="radio" name="gender" value="Male"><br>Female<input type="radio" name="gender" value="Female"><br><br>
Television/Film:<br><textarea name="film" rows="14" cols="75"><?php echo $row[film];?></textarea><br><br>
Literature:<br><textarea name="literature" rows="14" cols="75"><?php echo $row[literature];?></textarea><br><br>
Music:<br><textarea name="music" rows="14" cols="75"><?php echo $row[music];?></textarea><br><br>
About Me:<br><textarea name="aboutme" rows="14" cols="75"><?php echo $row[aboutme];?></textarea><br><br>
Friends:<br><textarea name="friends" rows="14" cols="75"><?php echo $row[friends];?></textarea><br><br>
<input type="submit" name="zpageUPDATE" value="-Save All">
</form>
</center>

<?
}
}else{
loginPage();
}
PageBottom();
?>
[/code]

im about to litterally go insane .. idk even what happened .. or how...

Link to comment
https://forums.phpfreaks.com/topic/29493-up-for-a-challenge/
Share on other sites

When I was just starting to learn PHP i did that .. to make things easier to understand .. it organized it sorta .. and its kinda a habbit, i really dont try. i just write snippets that start and end with <?php and ?> and i put it all together .. and up till now.. that pages has worked fine ...
Link to comment
https://forums.phpfreaks.com/topic/29493-up-for-a-challenge/#findComment-135344
Share on other sites

just as a syntax error I've spotted a few lines like these...

[code=php:0]$sql = "SELECT * FROM users WHERE username = '$_SESSION[username]' LIMIT 1";[/code]

...should be...
[code=php:0]$sql = "SELECT * FROM users WHERE username = '{$_SESSION[username]}' LIMIT 1";[/code]


When you're sticking array values into double quoted strings, be sure to put braces around the array[key]
(there are a few other times you've done this, you probably want to look over your code for the other instances)

Also be sure that the errors you are getting aren't from "func.php" or "login.php" (files you included) you can tell this if you read the error message closely.

Other than that, I "find & replaced" the &#160; from the code (I figured that was in there by accident) and it had no errors, other than (of course) that I had none of the include files, or any of the included functions.

PHP error checking isn't always 100% correct on the specifics, be sure to check func.php or login.php for errors even if they weren't the ones on the error message, it couldn't hurt!
Link to comment
https://forums.phpfreaks.com/topic/29493-up-for-a-challenge/#findComment-135347
Share on other sites

the error is solely in this file, and has nothingt o do with fun.php or login.php .. I read the massge. it said "... in editAccnt.php" (which is name of the file. ...)


the exact error is:

"
Parse error: parse error, unexpected '}' in C:\wamp\www\editAccnt.php on line 91
"
Link to comment
https://forums.phpfreaks.com/topic/29493-up-for-a-challenge/#findComment-135348
Share on other sites

Just saying that PHP's error checking isn't always 100% correct on the issue, just raising the possibility that it's the other two files...

I tested that code on my ZDE, my local server, and my web server, and it ran on every single one of them, except for some include errors of course (and I pulled out the custom functions, since that is a fatal error if they aren't defined)

Wish I could give you more info, but while the code is messy, it works (with the &#160; taken out of course)
Link to comment
https://forums.phpfreaks.com/topic/29493-up-for-a-challenge/#findComment-135351
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.