Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2012
    Posts
    3

    Red face Unanswered: Brickwall mode - need help! syntax error

    Hi everyone,

    Newbie here, and am damn glad to have found this forum. I've been stumped on a problem for ages now and can't seem to find a solution.

    Doing a project for Uni and I'm using Dw CS5 on a mac.

    Using VM and Access 2003 to generate a SQL statement, which I then incorporate into the advanced setting of recordset - I then test it and it works the way I want it to work, but when I click ok:

    "There is a syntax error on line 35. Code hinting may not work until you fix this error"

    The entire code is as follows:

    <?php require_once('file:///Macintosh%20HD/Users/arsenalfan101/Documents/03-Web%20Project/project/Root/Connections/LiveServer.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }
    }

    mysql_select_db($database_LiveServer, $LiveServer);
    $query_Recordset1 = "SELECT tblcourses.CourseCertificate, tblcourses.CourseDescription, tblcourses.CourseLevel, tblcourses.CourseLength, tblcourses.CoursePriceEU, tblcourses.CoursePriceNonEU FROM tblcourses WHERE (((tblcourses.CourseDescription)="Standard English"))";
    $Recordset1 = mysql_query($query_Recordset1, $LiveServer) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    </body>
    </html>
    <?php
    mysql_free_result($Recordset1);
    ?>

    ************************************************** ********

    Found this forum thru a friend. There was another post sometime ago with a syntax error an the solution was to remove a semi colon which appeared to have worked for that person, but when I tried to do similar, the syntax error didn't go away - hence my post.

    That post was here

    Would really appreciate any help on this!

    Thanks everyone, and yes I know, a lousy way to introduce myself

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    at first glance I suspect this error may be missing a closing bracket of some type, probably a superflouous } or a missing }

    normally I'd expect to see a variable to hold the return from the mysql_select_db function. it could be that is throwing the script execution

    at what point do you establish the connection to the server
    using the libraries you are I'd expect to see 3 stateemnts
    a connect
    a select db
    a query
    ..I cna see the query and the connect, but no connection. it could be that is the error, but because you are not using the or die or similar construct or examining the MySQL Error code to handle why the code fails

    beyond that I don't know.
    is this error being reported in PHP or Dreamweaver?

    as an aside...
    defining a function if it doesn't exists seems a waste... have you considered stuffing your functions into a function library and INCLUDE_ONCE that library. Mind you having defined the function you don't seem to use it anywhere

    rather than report the error as line 35 could you actually point out which line is throwing the error...

    the MySQL library you are using is deprecated ,meaning it shouldn't really be used in new code, but I guess you are probably OK for coursework, but not if the script has a continuing use elsewhere. mind you I'd also expect to see some form of error reporting or trapping to halt script execution int he event of a MySQL error

    when posting PHP scripts here its helpful to include it inside [ p h p] and [ / p h p ] (minus the spaces)

    consider using a more specific PHP IDE such as NETBeans or Chamisoft's HTMLKIT or others. the advantage begin that these editors are smarter about code blocks

    Personally I prefer to see code blocks starting with { and ending with } starting on the same character position, which isnt' as per the accepted 'standard
    eg
    PHP Code:
    if ($MyVal == 5)
    {  if(
    $MyOtherVal >6)
       {  
    //do soemthing
       
    }  else
       {  
    //do somethign else
       
    }
    }  else
    {  
    //do nothing

    as opposed to the 'standard
    PHP Code:
    if ($MyVal == 5) {
      if(
    $MyOtherVal >6) {
         
    //do soemthing
         
    }  else
         {  
    //do somethign else
         
    }
      }  else
    {  
    //do nothing

    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2012
    Posts
    3
    Thanks heardem - believe it or not, my problem was solved by changing the double quotations "Standard English" to single quotations 'Standard English'!

    Appreciate the time you've taken to help me out. I'm defo gonna stick around here!

    Thanks again!!

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    sometimes y'just can't see the wood for the trees....

    using a PHP aware editor such as Netbeans would have shown that error immediately.... try it.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2012
    Posts
    3
    Will get that now! Another headwreaker like this and I'll be an alcoholic!!

    Thanks mate!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •