Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2011
    Location
    Sunshine State
    Posts
    80
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Parse error: syntax error, unexpected T_STRING

    the error is kicking on the echo line of:
    PHP Code:
    $artistQuery mysql_query('SELECT * FROM artists ORDER BY artistName ASC');
    while (
    $artistRow mysql_fetch_assoc($artistQuery)) {
        echo 
    '<p>'.$artistRow['artistName'].'</p>';

    at first I thought well ok it's not returning any records, let's double check in phpmyadmin that it's a good query - ran the query in there and boom it displays all 30 or so records

    then I thought well maybe I'm not asking for the correct array so then I did a print_r and sure enough it displays the listed array [0] through [30 something] with all the table data

    then I went to bed

    this morning I thought I would try again, but I'm still not having any luck and I've googled until my eyes crossed but I'm at an utter and complete loss as to what is causing this error

    any help is greatly appreciated
    Last edited by dnnhater; 11-26-2011 at 06:23 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,324
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    It's not those lines of code, PHP has got confused.

    It's elsewhere, try the line before, make sure there is a ; at the end as thats what the unexpected T_SOMETHING usually means.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New Coder
    Join Date
    Jul 2011
    Location
    Sunshine State
    Posts
    80
    Thanks
    18
    Thanked 0 Times in 0 Posts
    thanks for that tango...

    maybe I'm just being blind - I went on the hunt for ; and din't see anything out of place...below is the complete page code

    PHP Code:
    <?php
    session_start
    ();
    if (!isset(
    $_SESSION['logged_in'])) {
        
    header("Location:http://domain.com/TEST/admin/index.php?msg=1");
    }

    // Include required files
    require_once ('../includes/config.php');

    // Connect to the database
    $conn=mysql_connect(DB_HOST,DB_USER,DB_PASS);
    mysql_select_db(DB_BASE);


    // Instantiate Classes
    $artist = new Artists();

    $page->contentSet('<h1>Artists</h1>');

    $artistQuery mysql_query('SELECT * FROM artists ORDER BY artistName ASC');
    while (
    $artistRow mysql_fetch_assoc($artistQuery)) {
        
    $page->contentSet('<p>'.$artistRow['artistName'].'</p>');
    }

    display_page();
    ?>
    the only other thing being something got changed in config.php maybe? but then nothing would work because all pages include config.php

    this has to be something so stupid and simple and that's why I'm not seeing it

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,324
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Is this file included inside another file? - I'm guessing it is due to your use of the artist class and $page.

    I'd be looking in that including file because nothing is staring me in the face with your current code and i've just put it into notepad and reformatted it to make it easier to read:

    PHP Code:
    <?php
    session_start
    ();

    if (!isset(
    $_SESSION['logged_in']))
       {
       
    header("Location:http://domain.com/TEST/admin/index.php?msg=1");
       }

    // Include required files
    require_once ('../includes/config.php');

    // Connect to the database
    $conn=mysql_connect(DB_HOST,DB_USER,DB_PASS);
    mysql_select_db(DB_BASE);


    // Instantiate Classes
    $artist = new Artists();

    $page->contentSet('<h1>Artists</h1>');

    $artistQuery mysql_query('SELECT * FROM artists ORDER BY artistName ASC');

    while (
    $artistRow mysql_fetch_assoc($artistQuery))
       {
       
    $page->contentSet('<p>'.$artistRow['artistName'].'</p>');
       }

    display_page();
    ?>
    There just isn't anything wrong with it that I can see. It must be the calling script.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #5
    New Coder
    Join Date
    Jul 2011
    Location
    Sunshine State
    Posts
    80
    Thanks
    18
    Thanked 0 Times in 0 Posts
    thanks again tango

    I thought I was using the wrong class name so I had this whole "you're the best" speech and balloons and confetti but alas...it is the correct class name

    but I will now look more closely at the class and see what's going on there
    Last edited by dnnhater; 11-26-2011 at 06:03 PM. Reason: thought I had the correction but I was wrong

  • #6
    New Coder
    Join Date
    Jul 2011
    Location
    Sunshine State
    Posts
    80
    Thanks
    18
    Thanked 0 Times in 0 Posts
    ok so you do get the "you're the best" speech and balloons and confetti afterall

    I was not calling the class properly - it should have been $artists = new Artists($conn)

    PHP Code:
    <?php
    session_start
    ();
    if (!isset(
    $_SESSION['logged_in'])) {
        
    header("Location:http://domain.com/TEST/admin/index.php?msg=1");
    }

    // Include required files
    require_once ('../includes/config.php');

    // Connect to the database
    $conn=mysql_connect(DB_HOST,DB_USER,DB_PASS);
    mysql_select_db(DB_BASE);

    $artists = new Artists($conn);

    $artistList $artists->getArtistList();

    $page->contentSet('<h1>Artists</h1>');

    foreach (
    $artistList AS $artist) {
        
    $page->contentSet('<p>'.$artist['artistName'].'</p>');
    }

    display_page();
    ?>
    works like a charm now!


  •  

    Posting Permissions

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