The syntax checker I am referring to is a neat little tool that I've used to help me check my code before committing it over our tortoiseSVN. It's never lead me astray until today.
I've made a simple function to find the order of magnitude of a number passed in, incomplete but included below:
function( $graphMax )
{
$a = (int)log10( $graphMax );
echo "<br><br>GRAPHMAX LOG-10: " . $a . "<br><br>";
$a = pow( 10 , $a );
return $a;
}
This will return the lowest value of that order of magnitude( 10,000 for numbers between 10,000-99,999 ).
The issue I am having is this part of the function:
$a = (int)log10( $graphMax );
The syntax checker says that there are no errors in the syntax when I copy/paste the entire file into it, but when I submit and run it on our server, I get:
Parse error: syntax error, unexpected '(', expecting T_STRING in /*/global_functions.php on line 364
as requested, this is the code above the function:
function countSections( $testID )
{ require( 'config.php');
//Connect to database server
$dsl_sqlh = mysql_connect( $dsl_db_host, $dsl_db_user , $dsl_db_pass )
or die ("Unable to connect");
mysql_select_db ( $dsl_db , $dsl_sqlh) or die ("Unable to select database");
//Get Section ID.
//With this we can query the correct section
$secQuery = sprintf("SELECT test_section_name FROM v_ak47_test_section WHERE ak47_testhistory_id= $testID and obsolete = 0");
$secResults = mysql_query($secQuery , $dsl_sqlh);
$rows = mysql_num_rows( $secResults );
if( $rows > 0 )
{
return $rows;
}
else
{
echo "<br><br>Test has no sections! Check test ID provided.<br><br>";
return null;
}
}
Answer: I didn't name the function. I have no idea how I missed that. It's early... I need more coffee:( Thanks for the help everyone! Sorry it was so anti-climatic. My last few posts have been like this.
You need to give your function a name
function {ENTER NAME HERE}( $graphMax )
{
$a = (int)log10( $graphMax );
echo "<br><br>GRAPHMAX LOG-10: " . $a . "<br><br>";
$a = pow( 10 , $a );
return $a;
}