Forum Moderators: coopster

Message Too Old, No Replies

parse error, unexpected $ in

since there is no $ whats up?

         

kenmcauliffe

4:33 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



I'm not just a newbe I know nothing.....

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

WesleyC

4:44 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Can we see the code around it? Without that, it's hard to debug. :)

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.

cameraman

4:46 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, kenmcauliffe!

Try looking on the line above (line 1044).

kenmcauliffe

5:25 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Here is the code before this error, but since the " $ " is not there I don't know what to think... and the error is on the line after the code ends. ? Beyond me.

<?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>&laquo&nbsp;PREV</b></a>";

}else if($to_view=="approve"){

print "<a href='admin_control.php?bu_app1&start=$back' class=h1><b>&laquo&nbsp;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>&laquo&nbsp;PREV</b></a>";

}

}else{

print "<font face=verdana size=1 color=black><b>&laquo&nbsp;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&nbsp;&raquo</b></a>";

}else if($to_view=="approve"){

print "<a href='admin_control.php?bu_app1&start=$next' class=h1><b>NEXT&nbsp;&raquo</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&nbsp;&raquo</b></a>";

}

else{

print "<font face=verdana size=1 color=black><b>NEXT&nbsp;&raquo</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>

dreamcatcher

6:31 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld kenmcauliffe. :)

unexpected $end is pretty much always a missing brace. Check your braces to make sure you have opening and closing braces for each statement.

dc

kenmcauliffe

6:32 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Thanks, I'll give that a try...Ken

kenmcauliffe

8:01 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Closing the braces did the job for that problem but now there is a new one....
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
here is the line of code...
$row=mysql_fetch_array($res);
here is the code around it...

<?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

WesleyC

8:14 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Try putting this line before the line $res=mysql_query($qry);

var_dump( $id );

Then tell us what the output is right before the warning.

dreamcatcher

10:24 pm on Jun 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



and you might need the var in quotes:

$qry="select * from bus_main_catg where bus_mcat_id='$id'";

dc

kenmcauliffe

12:04 am on Jun 27, 2008 (gmt 0)

10+ Year Member



I do have the quotation marks but I noticed you have a double quote mark after the $ID

eelixduppy

5:22 am on Jun 27, 2008 (gmt 0)



Try the following function. If this doesn't work, then try to run the query manually in the command line to see if it's not choking somewhere there.

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.