Forum Moderators: coopster
However I had a site built and the programer has fallen off the earth so It's time to learn. I know just enough HTML to be dangerous but not enough PHP to understand what the "$" sign means and what the error message,
Parse error: parse error, unexpected $ in /home/content/k/e/n/kenmcauliffe/html/admin/business_ctrl.php on line 1045
is telling me since there is no $ in the line in question.
Thanks in advance, Ken
However, some general notes: the "$" sign in PHP indicates a variable. For instance:
$foo = "abc";
Will assign "abc" to the variable $foo. Two dollar signs can be used to make a "variable variable"--be careful with this though, there are some security risks involved if this variable can be in any way shape or form set by the user.
$foo = "abc";
$abc = 123;
echo $$foo; //will print "123"--equivalent to writing echo $abc.
<?php
}
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
echo "<br><table align = 'center' width='15%' border=1 style='border-collapse:collapse;'><tr><td align='left' width='30%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0) {
if($to_view=="unapproved")
{
print "<a href='admin_control.php?bu_app1&start=$back' class=h1><b>« PREV</b></a>";
}else if($to_view=="approve"){
print "<a href='admin_control.php?bu_app1&start=$back' class=h1><b>« PREV</b></a>";
}else if($to_view=="search"){
print "<a href='admin_control.php?search_ctrl&bname=$bname&$name0=0&$name1=1&start=$back' class=h1><b>« PREV</b></a>";
}
}else{
print "<font face=verdana size=1 color=black><b>« PREV</b></font>";
}
//////////////// Let us display the page links at center. We will not display the current page as a link ///////////
echo "</td><td align='right' width='30%'>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this < $nume) {
if($to_view=="unapproved")
{
print "<a href='admin_control.php?bu_app1&start=$next' class=h1><b>NEXT »</b></a>";
}else if($to_view=="approve"){
print "<a href='admin_control.php?bu_app1&start=$next' class=h1><b>NEXT »</b></a>";
}else if($to_view=="search"){
print "<a href='admin_control.php?search_ctrl&bname=$bname&$name0=0&$name1=1&start=$next' class=h1><b>NEXT »</b></a>";
}
else{
print "<font face=verdana size=1 color=black><b>NEXT »</b></font>";
}
echo "</td></tr></table>";
?>
<table width="100%">
<tr><td colspan=3 align=right><input type=button name=btnapprove class=gbtnbig value="Approve Business" onclick="callApprove()">
<input type=button name=btndelete class=gbtnbig value="Delete Business" onclick="callDelete()"></td></tr>
</table>
</form>
</center>
</body>
</html>
<?php
function getMcatName($id)
{
$qry="select * from bus_main_catg where bus_mcat_id=$id";
$res=mysql_query($qry);
$row=mysql_fetch_array($res);
$mcat_name=$row['bus_mcat_name'];
return $mcat_name;
}
I should probably pay someone to debug this but maybe this will be the end.
Thaks, in advance again, Ken
function getMcatName($id)
{
$qry = "select * from bus_main_catg where bus_mcat_id = '".[url=http://www.php.net/mysql-real-escape-string]mysql_real_escape_string[/url]($id)."'";
$res = mysql_query($qry) or [url=http://www.php.net/die]die[/url]([url=http://www.php.net/mysql-error]mysql_error[/url]());
$row = mysql_fetch_array($res);
$mcat_name = $row['bus_mcat_name'];
#
return $mcat_name;
}
You should also note there I do not see a connection link to the database you are using anywhere. Usually if these are opening in another function there is some global variable assigned to the link. It would resemble something like this:
global $link;
And then that would be used for the db functions.
Anyway, let's see what this new version of the function returns. If your MySQL query is choking up somewhere, we'll know about it from this version.
Oh, and Welcome to WebmasterWorld! :)
P.S. Just a note...you should check to see if the query will return something first, and if it doesn't your function is going to want to "return NULL;" instead of a non-existing variable that will probably cause errors for you.