|
-
Jul 29th, 2002, 09:39 PM
#1
Thread Starter
Hyperactive Member
Here's another Q....
Parse error: parse error, unexpected T_INC in /home/djstop/public_html/test/phatfx.php on line 322
my code:
PHP Code:
<?
myconnect();
$query = "SELECT * FROM `songs` ORDER BY `id` DESC";
$result = mysql_query($query);
$rows = @mysql_num_rows($result);
$foundentries = false;
while ($i < $rows) {
$foundentries = true;
$id = @mysql_result($result, $i, 'id');
$title = @mysql_result($result, $i, 'title');
?>
<option value="<?= $id; ?>"><?= $title; ?></option>
<?
i++;
}
myclose;
?>
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Jul 29th, 2002, 10:20 PM
#2
Fanatic Member
<option value="<?= $id; ?>"><?= $title; ?></option>
whats with the "=$id" should just be $id, same for title
-
Jul 30th, 2002, 12:07 AM
#3
Lively Member
the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
There's something I've noticed in the last year or so...
Australian's are good at EVERYTHING !!!
-
Jul 30th, 2002, 12:27 AM
#4
Stuck in the 80s
Originally posted by DJ P@CkMaN
the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
and also a very bad programming practice.
-
Jul 30th, 2002, 12:29 AM
#5
Stuck in the 80s
Re: Here's another Q....
Why don't you just do this?:
PHP Code:
<?php
myconnect();
$query = "SELECT * FROM `songs` ORDER BY `id` DESC";
$result = mysql_query($query);
$rows = @mysql_num_rows($result);
$foundentries = false;
while ($i < $rows) {
$foundentries = true;
$id = @mysql_result($result, $i, 'id');
$title = @mysql_result($result, $i, 'title');
echo "<option value=\"$id\">$title</option>";
i++;
}
myclose;
?>
-
Jul 30th, 2002, 09:49 AM
#6
Frenzied Member
take the stupid ` off the column names and table
and you should never use @ to surpress the errors until you know it will work without getting an error. see you have an error and you use the @ so how do you know where the error is being generated from? nothing towards you hobo I am just stating this in general. 
Carp: what line is 322? and try not to use mysql_result as it is a lot slower than mysql_fetch_array().
-
Jul 30th, 2002, 09:53 AM
#7
Frenzied Member
PHP Code:
<?php
myconnect();
$query = "SELECT * FROM songs ORDER BY id DESC";
$result = mysql_query($query);
echo "<form>";
while ($row = mysql_fetch_array($result)) {
$foundentries = true;
echo "<option value=\"".$row["id"]."\">$row["title"]</option>";
}
echo "</form>";
myclose();
?>
-
Jul 30th, 2002, 02:38 PM
#8
Fanatic Member
Originally posted by DJ P@CkMaN
the <?= $id; ?> is just a short way of typing <?php echo $id; ?>
Learn something new everyday
-
Jul 30th, 2002, 02:44 PM
#9
Fanatic Member
Originally posted by phpman
PHP Code:
<?php
myconnect();
$query = "SELECT * FROM songs ORDER BY id DESC";
$result = mysql_query($query);
echo "<form>";
while ($row = mysql_fetch_array($result)) {
$foundentries = true;
echo "<option value=\"".$row["id"]."\">$row["title"]</option>";
}
echo "</form>";
myclose();
?>
PHP Code:
<?php
myconnect();
$query = "SELECT * FROM songs ORDER BY id DESC";
$result = mysql_query($query);
echo "<form>";
while ($row = mysql_fetch_array($result)) {
$foundentries = true;
echo "<option value=\"".$row["id"]."\">".$row["title"]."</option>";
}
echo "</form>";
myclose();
?>
-
Jul 30th, 2002, 04:53 PM
#10
Stuck in the 80s
Originally posted by phpman
nothing towards you hobo I am just stating this in general.
I didn't put them in there, I just copied his code. In fact, I didn't even realize they were in there.
-
Jul 31st, 2002, 10:43 AM
#11
Thread Starter
Hyperactive Member
I fixed my error, All I had to do was put a $ before i++. I would have said this before but I couldn't connect to the server.
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Jul 31st, 2002, 10:46 AM
#12
Frenzied Member
but our way you don't need to add the i variable and is more proficient.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|