Web Analytics Made Easy -
StatCounter Syntax error??? Really??? - CodingForum

Announcement

Collapse
No announcement yet.

Syntax error??? Really???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Syntax error??? Really???

    God I hate Adobe and especially Dreamweaver.

    I was recently forced to start using Dreamweaver when my laptop died and I pretty much lost everything. I had to move to my desktop which has Adobe cs6 installed i.e. Dreamweaver.
    I have gotten really spoiled to using Visual Studio but don't have a viable install of it in my desktop so I find myself having to use Dreamweaver.

    I am currently working on developing a new website and I'm trying to create a new Wordpress theme. I am beginning writing the index page and the first line in the file is

    Code:
    <?php
        if (have_posts()) : 
    	while (have_posts ()) : the_post(); ?>
    Dreamweaver is complaining that there is a syntax error on line 3.
    Granted I am new to php but I am reasonably sure there is no syntax error on line 3
    I am coping this character by character from a Youtube video and I have checked, rechecked and double rechecked. My code is identical to the code in the video
    Does anyone have any clue why Dreamweaver is choking on this dirt simple 3 lines of code.?
    Anybody spot something I'm missing. ?

  • #2
    You use dreamweaver to edit or create wordpress scripts?
    Is it just the editor part of dreamweaver ... how does dreamweaver do wordpress?

    Comment


    • #3
      Firstly, this is a php coding question, not a client-side or a web building question.

      It would be helpful if you posted the syntax error you are getting, to narrow down the possibilities.

      If the error happens to be an 'unexpected end of file' or similar message, it is because you haven't closed/ended both the while() and if() statements and the code is incomplete, i.e. php reached the end of the file while still expecting to find the closing syntax for both of those statements.
      Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

      Comment


      • #4
        Uhm... I don't know what language you are using, but I'd suspect those colons are the cause since no language I know of would use colons that way.

        Of course, if you are working on web technologies and don't like Dreamweaver, why the blazes use that overpriced bloated steaming pile of halfwit ignorant manure.

        Go get a flat text editor -- flo's notepad2, notepad++, editplus, sublime -- there's dozens if not hundreds of free ones, and test in the actual software not some goofy half-assed WYSIWYG and rubbish RAD that rarely if ever works like the real thing anyways!

        Same goes for the mouth-breathing idiocy known as Visual Studio... if you're working in anything remotely related to HTML and CSS, they (Dreamweaver, Visual Studio, anything involving the terms "WYSIWYG" or "RAD") are a giant middle finger to the development process and the ONLY thing you can learn from them is how NOT to build a website.

        As the joke goes, the only thing about Dreamweaver that can be considered professional grade tools are the people promoting its use.

        Oh, and your logic is also flawed, that test would skip your first instance of the call being true, I suspect what you want to do is:

        Code:
        <?php
          if (have_posts()) do {
            the_post();
          } while (have_posts());
        ?>
        Although given there is no "else" there is no legitimate reason for that if, as the first while will be false anyways, hence it is most likely what you meant to do is:

        Code:
        <?php
          while (have_posts()) the_post();
        ?>
        Again, no idea where or why you thought you needed colons in there, or even the if statement for that matter. Condition has to be true for the "while" to even run in the first place. Only reason to have that "if" would be if you have an "else" condition for if there were no posts later on in the code.
        Walk the dark path, sleep with angels, call the past for help.
        https://cutcodedown.com
        https://medium.com/@deathshadow

        Comment


        • #5
          Originally posted by deathshadow View Post
          Uhm... I don't know what language you are using, but I'd suspect those colons are the cause since no language I know of would use colons that way.
          Interesting that you don’t know about PHP’s colon syntax since you’re usually the one with long essays giving the impression of knowing most of the common scripting languages.
          Stop solving problems you don’t yet have!

          Comment


          • #6
            Originally posted by ronc0011 View Post
            God I hate Adobe and especially Dreamweaver.

            Dreamweaver is complaining that there is a syntax error on line 3.
            Granted I am new to php but I am reasonably sure there is no syntax error on line 3
            Urgh.. without meaning to sound like deathshadow, this is most definitely a case of coder over confidence and not enough actual knowledge.

            The first thing I noticed is that you're ranting about dreamweaver because you can't get it to do what you want and it's thrown an error. Then your code.. immediately shows up as defective since you can't write code in that syntax with php. I've no idea about that youtube video you're talking about but as you've not posted it I'm inclined to think you've made mistakes.

            Dreamweaver SHOULD complain - there is a glaring big error and it knows it. Errors and warnings are your friend and it's done you a favour though you don't realise it. If it didn't, you'd just be sat there thinking "Hey why doesn't this work?" and have no clue how to solve it.

            Finally.. you admit it yourself - you're new to php. So stop being so down on dreamweaver when you admit you have little knowledge of the language you're using. You can't go through life being over confident about stuff, it'll be your achillies heel.

            If you need help understanding php control structures and functions, just go to php.net/<function_name> and you'll automatically be on the page you need - or a search page with similar results.

            Dreamweaver is a good bit of kit (obviously deathshadow will send the firing squad round to my place overnight) but you need to know (as with anything in life) what you're doing with it. Life isn't simple anymore, you have to learn things over time.
            "Tango says double quotes with a single ( ' ) quote in the middle"
            '$Name says single quotes with a double ( " ) quote in the middle'
            "Tango says double quotes ( \" ) must escape a double quote"
            '$Name single quotes ( \' ) must escape a single quote'

            Comment


            • #7
              Originally posted by VIPStephan View Post
              Interesting that you don’t know about PHP’s colon syntax since you’re usually the one with long essays giving the impression of knowing most of the common scripting languages.
              Never seen it before, never seen it in any other language -- what purpose does it serve? I mean, if it were a ternary operator I could understand it as it would be the "else". Now that you mentioned it I'm looking for it in the manual and not finding it on anything to do with "if" either.

              What is it supposed to do other than throw precisely the errors the OP is getting for being invalid syntax?

              -- edit -- wait, do you mean that idiotic ": /* snip */ else" syntax that's a confusing mess only python lovers could love? If so he doesn't have that either... or the rest of it is missing from the snippet. Only time that ever made any sense to me was for block conditionals where you'd either have sequential drop-through with other control structures -- like after a CASE when you have break, return, or drop-through, since those clearly aren't terminated blocks.

              Not something I would teach to anyone until we got to switch/case, and not something I'd ever tell someone to use on if/else... much less an if that has no else or the mental midgetry that is the NewBASIC style "endif" rubbish.
              Last edited by deathshadow; Sep 17, 2016, 06:58 PM.
              Walk the dark path, sleep with angels, call the past for help.
              https://cutcodedown.com
              https://medium.com/@deathshadow

              Comment


              • #8
                Originally posted by deathshadow View Post
                Never seen it before
                hang about.. i'm sure just a few threads back you said you loved php so much you were still reading the manual for 2-3 hours a day after over a decade of using it?

                Tut, tut, tut
                "Tango says double quotes with a single ( ' ) quote in the middle"
                '$Name says single quotes with a double ( " ) quote in the middle'
                "Tango says double quotes ( \" ) must escape a double quote"
                '$Name single quotes ( \' ) must escape a single quote'

                Comment


                • #9
                  it look pretty good to me possible
                  <?php
                  if (have_posts()) :
                  while (have_posts ()) : the_post(); ?> change this
                  while (have_posts()) : the_post(); ?> to this that space could be throwing an unexpected eol exception I am not 100% sure PHP is not one of my better languages

                  Comment


                  • #10
                    Originally posted by tangoforce View Post
                    hang about.. i'm sure just a few threads back you said you loved php so much you were still reading the manual for 2-3 hours a day after over a decade of using it?

                    Tut, tut, tut
                    I'm thinking I either didn't recognize the use as its and incomplete snippet, or it was being used wrong.

                    But then I see ?> I assume there's no more coding logic, since that whole <?php ?> thing fifty times for a 80 line file thing is ugly as sin and hard to follow.

                    See my comment after... you rarely see the if:endif thing, and when you do usually something goes wrong with it. It's another of those things PHP could seriously do without -- to simplify the language AND speed up the parser so it has less junk to look for; it only seems included for the people coming from BASIC on ASP/.NET who can't handle a real programming language.

                    Kind of like <?php ?> which seem to only exist for people who, well... can't handle a real programming language... well, and to possibly open security holes through sloppy practices like having library files that actually run code directly or worse just blindly output stuff when included.

                    In that way, @ronc0011 could we see the code that follows down to the closures if you are indeed using the painfully bad "endif" and "endwhile" style nonsense? Are you missing the corresponding endif/endwhile which might make DW incorrectly report the wrong error? (since it's PHP checking is useless trash?)

                    What's REAL PHP return for an error (if any?)

                    Of course @__TomFoolery__ is onto something there with the extra space... I might have likewise recognized it if the space between the ) and : weren't there as well. Without seeing the matching endif/endwhile and the extra space in there, it looks like the colons were just slapped in there at random.

                    You can go overboard on whitespace to the point the parser can't handle it. The argument delimiters for a function (the () part) can be picky about that.

                    ... and if indeed that is for endif and endwhile, axe that rubbish and just use {} like the rest of the world. This isn't newbasic/quickbasic/visual basic -- be happy about that.
                    Last edited by deathshadow; Sep 17, 2016, 08:53 PM.
                    Walk the dark path, sleep with angels, call the past for help.
                    https://cutcodedown.com
                    https://medium.com/@deathshadow

                    Comment


                    • #11
                      hey now my friend not so harsh, I myself am a "python lover" I hated it at first thought it was too basic of a language then I learned otherwise, it is what runs blender, any CGI you have seen in a pixar/disney movie, landed a rover on mars ( another satalite or rover was in ruby) used in medical imaging, runs maya and 3d studio max. It is a great versitile language with endless applications "mostly for math and science nerds and geeks" but hell I am one of those

                      Comment

                      Working...
                      X