Return Array from Function
| From: | Hutchins, Richard | Date: | Thu, 26 Sep 2002 20:18:34 +0000 |
| Subject: | Return Array from Function | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-22031@lists.php.net to get a copy of this message | ||
Can somebody tell me what I might be doing wrong in the code below? I'm
trying to use a function to perform an often-used db query and return the
resulting resource to the calling script. I keep getting this error though:
Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$'
in c:\spidey\public\addleveltwo.php on line 51
I've looked and looked, but I can't find what could be causing a parse
error. Most likely, I've just been looking at it for too long. Any fresh
eyes available?
<?php
include("../protected/getContent.php");
getLevelOnes($docnum); //user-defined function from included file.
Definition appears after this snippet.
$num=mysql_num_rows($levelones);
if($num<1)
{
echo("There is no level one (Section) content for this
document in the database.");
exit();
}
while($row=mysql_fetch_array($levelones))
{
$1contentID=$row["1contentID"];
$parentID=$row["parentID"];
$1child=$row["childID"];
$1content=$row["1content"];
$1ordinal=$row["ordinal"];
echo("<tr><td>".$1content."</td><td><a
href=\"contentMgr.php?docnum=".$docnum."\"
target=\"_right\">Add</a></td></tr>");
}
?>
<?php
function getLevelOnes($docnum)
{
$sql="SELECT 1contentID, parentID, childID, 1content, 1ordinal FROM
levelone WHERE 1contentID='$docnum'";
$levelones=mysql_query($sql)
or die(mysql_error());
return $levelones;
}
?>