Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-26-2011, 04:31 PM   PM User | #1
dnnhater
New Coder

 
Join Date: Jul 2011
Location: Sunshine State
Posts: 79
Thanks: 18
Thanked 0 Times in 0 Posts
dnnhater is an unknown quantity at this point
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..
dnnhater is offline   Reply With Quote
Old 11-26-2011, 05:07 PM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,496
Thanks: 44
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 11-26-2011, 05:39 PM   PM User | #3
dnnhater
New Coder

 
Join Date: Jul 2011
Location: Sunshine State
Posts: 79
Thanks: 18
Thanked 0 Times in 0 Posts
dnnhater is an unknown quantity at this point
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
dnnhater is offline   Reply With Quote
Old 11-26-2011, 05:50 PM   PM User | #4
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,496
Thanks: 44
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 11-26-2011, 05:58 PM   PM User | #5
dnnhater
New Coder

 
Join Date: Jul 2011
Location: Sunshine State
Posts: 79
Thanks: 18
Thanked 0 Times in 0 Posts
dnnhater is an unknown quantity at this point
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
dnnhater is offline   Reply With Quote
Old 11-26-2011, 06:23 PM   PM User | #6
dnnhater
New Coder

 
Join Date: Jul 2011
Location: Sunshine State
Posts: 79
Thanks: 18
Thanked 0 Times in 0 Posts
dnnhater is an unknown quantity at this point
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!
dnnhater is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:03 AM.


Advertisement
Log in to turn off these ads.