PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
bironeb
Forum Commoner
Posts: 59 Joined: Thu Nov 20, 2003 12:02 pm
Post
by bironeb » Mon Mar 22, 2004 10:40 am
Here is my code:
Code: Select all
<?php
$db_name = "testDB";
$table_name = "my_music";
$connection = @mysql_connect("localhost", "byron", "byronb") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT id, format, title, artist_fn, artist_ln, rec_label,
my_notes, date_acq FROM $table_name ORDER BY id";
$result = @mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$format = $row['format'];
$title = stripslashes($row['title']);
$artist_fn = stripslashes($row['artist_fn']);
$artist_ln = stripslashes($row['artist_ln']);
$rec_label = stripslashes($row['rec_label']);
$my_notes = stripslashes($row['my_notes']);
$date_acq = $row['date_acq'];
if ($artist_fn != "") {
$artist_fullname = trim("$artist_fn $artist_ln");
} else {
$artist_fullname = trim("$artist_ln");
}
if ($date_acq == "0000-00-00") {
$date_acq = "[unknown]";
}
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>;
}
?>
<html>
<head>
<title>My Music (Ordered by ID)</title>
</head>
<body>
<h1>My Music: Ordered by ID</h1>
<? echo "$display_block"; ?>
<p><a href="my_menu.html">Return to Menu</a></p>
</body>
</html>
Im getting the below error:
Parse error: parse error, unexpected T_VARIABLE on line 37
Line 37 is the line below:
Any Ideas?
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Mon Mar 22, 2004 10:43 am
you wrote:
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>;
}
should be
Code: Select all
$display_block = "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>;
} ";
??
CoderGoblin
DevNet Resident
Posts: 1425 Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany
Post
by CoderGoblin » Mon Mar 22, 2004 10:50 am
T_VARIABLE normally means something wrong with variables not having $ on them. This does not seem to be the case here..
Looking athe code
Code: Select all
$display_block.= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>";
// Append to existing
should be OK although I would set $display_block=""; before the while to prevent a possible PHP warning.
Try <?php echo("$display_block"); ?> in your last area...
(Note brackets).
Last edited by
CoderGoblin on Mon Mar 22, 2004 10:57 am, edited 1 time in total.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Mon Mar 22, 2004 10:54 am
your all wrong
should be like this (notice position of last quote and last curly brace)
Code: Select all
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>";
}
Mark
Last edited by
JayBird on Mon Mar 22, 2004 10:55 am, edited 1 time in total.
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Mon Mar 22, 2004 10:54 am
you've forgotten to end the string,
Code: Select all
<?php
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>;
?>
should be
Code: Select all
<?php
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>";
?>
bironeb
Forum Commoner
Posts: 59 Joined: Thu Nov 20, 2003 12:02 pm
Post
by bironeb » Mon Mar 22, 2004 11:02 am
Thanks for your help guys, to fix the error I first used this line before the while loop:
Then added the missing " on the line:
Code: Select all
$display_block .= "
<P><strong>$title</strong> ($artist_fullname) <br>
$my_notes <em> (acquired: $date_acq, format: $format)</em></p>";
}
?>
werlop
Forum Commoner
Posts: 68 Joined: Sat Mar 22, 2003 2:50 am
Location: /dev/null
Post
by werlop » Mon Mar 22, 2004 2:14 pm
This is where syntax highlighting helps. If your editor supported that, you probably would have noticed you hadn't ended the string, as the text would be a different colour.
Last edited by
werlop on Mon Mar 22, 2004 5:06 pm, edited 1 time in total.
m3mn0n
PHP Evangelist
Posts: 3548 Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada
Post
by m3mn0n » Mon Mar 22, 2004 3:04 pm
werlop wrote: This is where syntax highlighting helps. If your editor supported that, you probably would have noticed you hadn't ended the sting, as the text would be a different colour.
Indeed. *hugs Dreamweaver*
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Tue Mar 23, 2004 5:15 pm
- hugs full 12 pack of cold beer
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Tue Mar 23, 2004 7:30 pm
*hugs..
..
...
*looks around for something to hug*
..
..
....
*hugs door*