Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

PHP Help needed.


  • Please log in to reply

#1
rgin

rgin

    New Member

  • Member
  • Pip
  • 2 posts
Hi, I'm making a website that shows a member's genealogy. I'm doing this in PHP on a Windows XP box with WAMP installed. It works fine when I view it locally but when I upload it to my hosting site(byethost.com) it generated this error.
Parse error: syntax error, unexpected '}' in /home/somesite/public_html/ssi/somepage.php on line 13

Here is the full php code for somepage.php.
<?php

$con = mysql_connect($location, $user, $pass) or die(mysql_error());
mysql_select_db($DB ,$con) or die(mysql_error());

?>


<?php

if (!isset($_POST['memID'])) //If not isset -> set with dummy value
{
$_POST['memID'] = "";
}


if(!isset($parentID))
{
$parentID = "";
}

$memID = $_POST['memID'];
if($memID != "") // Gets the User's Name if an ID is submitted.
{
$getMem = "SELECT * FROM mstmember WHERE memberCode = $memID";

$result = mysql_query($getMem, $con);

$Name = mysql_fetch_array($result);

$pID = $Name['id'];

$query = "SELECT * FROM mstmember WHERE parentid = $pID";
}

function getName() // Gets first level names
{
GLOBAL $query;
GLOBAL $con;
GLOBAL $memID;

$results = mysql_query($query, $con);

$tag = 1;

while($memID != "" && $Names = mysql_fetch_array($results))
{

echo "<div name='$tag'>"; // divs here belong to down class

echo $Names['firstName'] . " " . $Names['lastName'];

echo "</div>";

$tag++;

}

}

function getSecond() // gets second level
{

GLOBAL $memID;
GLOBAL $pID;
GLOBAL $con;

$query = "SELECT id FROM mstmember WHERE parentid = $pID"; //gets the IDs of the first downline
$results = mysql_query($query, $con);

while($memID != "" && $down1 = mysql_fetch_array($results))
{
echo "<div class='down2'>";
$parentID = $down1['id'];
$results2 = mysql_query("SELECT * FROM mstmember WHERE parentid = $parentID", $con);
while($down2 = mysql_fetch_array($results2))
{
echo "<div>" . $down2['firstName'] . " " . $down2['lastName'] . "</div> <br class='clrlft' />";
}
echo "</div>";
}

}


function getInfo()
{

GLOBAL $memID;
GLOBAL $Name;

echo "<h3>". $Name['firstName'] . " " . $Name['lastName'] ."</h1>";

if($memID != "") { echo "<p>About Member..</p>"; }

}


?>

<form action="genealogy.php" method="post">

<span>

<div class="searchgene">

<div>

<p>Enter your ID Number/Member Code: </p>

</div>

<div>

<input name="memID" type="text" value="" />

</div>

<div>

<input style="margin-top:3px;" type="submit" value="Submit" />

</div>

</div>

<div class="geneInfo">

<?php getInfo(); //Gets Member's info ?>

</div>

<hr style="border: 1px thin #000; width:80%; float: left; margin-left: 80px;" />

<br class="clearfloat" />

</span>

</form>



<center>

<div class="gene">

<?php echo $Name['firstName'] . " " . $Name['lastName']; ?>

</div>

<div class="down">

<?php getName(); ?>

</div>

<br class="clrlft" />

<?php getSecond(); ?>

<br class="clearfloat" />


</center>


Usual causes for this error (as far as I know) are missing brackets or using short open tags without it being enabled. But, I checked, I'm using full open tags on all php blocks and it's enabled on my php.ini file anyway. So that can't be it.

Also, if this is some bracket mishap. I cannot, for the life of me, see where it's missing.

HELP? =(

EDIT: I just tried this on another hosting site. The script works perfectly fine.

The support I'm getting from my current host is pretty bad as I don't think they know how to fix this, I can't blame them. I can't even figure it out.

Anyone here have any idea what could be causing this?

UPDATE:
This problem has been solved. See second post for details. Please keep the thread going as I'd like to hear some advices about PHP programming.

Thanks.

Edited by rgin, 08 November 2010 - 10:16 PM.

  • 0

Advertisements


#2
rgin

rgin

    New Member

  • Topic Starter
  • Member
  • Pip
  • 2 posts
Well, I finally solved it. I'm gonna post what happened here in case anyone comes by with the same problem.

It had nothing to do with my code. The code, despite being such a mess, works great. It was in the transition of uploading my files to the said webhost. They did something with the arrangement of the code making it nearly impossible to tell what went wrong.

When I uploaded the files, they rearranged the function brackets. I had mine look like this.
function name() //comment here
{
  some code;
}

What they did was move the brackets so that the function would look like this.
function name() {
  some code;
}

But since I had the line comment placed in an unusual way(right after the function name, before the open bracket). It commented out the open bracket, causing the error.
function name() //comment here {
  some code;
} 

So I was right, it was a missing bracket error, only I couldn't see the missing brackets until I really looked over my code over a hundred times.

I've rewritten my code and learned something new. (watch out for comments, they may drive you nuts)

Hope this helps someone out there.

As a side note, I'd like to keep this thread going, since I've already posted my code here. I would love to get some critique on it. I'm an avid programmer but am fairly new to PHP. Any inputs or advices would be appreciated.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP