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
Da P3s7
Forum Commoner
Posts: 30 Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686
Post
by Da P3s7 » Wed Jul 19, 2006 3:31 pm
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
$con = mysql_connect("*","*","*");
if (!$con)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("****", $con);
$select = mysql_query("select * from main;", $con);
while (mysql_fetch_array($select))
{
echo "$select[Name]" . ", " . "$select[Description]" . ", " . "$select[Path]" . ", " . "$select[Executed]" . ", " . "$select[Sold]" . ", " . "$select[Price]" . ".";
echo "<br />";
}
I get only the commas on 6 lines (as i got 6 rows in my db).....can anyone give me a hand?
P.S. It's Part of a code. Im just messing around with it. Yet i cant figure it out. LoL
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Wed Jul 19, 2006 3:35 pm
Your while needs to be like this:
Code: Select all
while($row = mysql_fetch_array($select))
Change "$select[...]" to $row['...']
A couple of other things.
You don't need double quotes around your $select[...]
Also, you do need single (Or double) Quotes inside your brackets $row['...']
Da P3s7
Forum Commoner
Posts: 30 Joined: Wed Jul 19, 2006 3:25 pm
Location: /usr/src/kernels/ 2.6.15-1.2054_FC5-i686
Post
by Da P3s7 » Wed Jul 19, 2006 3:39 pm
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING *** on line 22
where as line 22 is
echo "$row['Name']" . ", " . "$row['Description']" . ", " . "$row['Path']" . ", " . "$row['Executed']" . ", " . "$row['Sold']" . ", " . "$row['Price']" . ".";
Any ideas?
Thx by the way.
-bump the last post.....
It was the double quotes around the $row array.
Soz.... Thx
Last edited by
Da P3s7 on Wed Jul 19, 2006 3:43 pm, edited 1 time in total.
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Wed Jul 19, 2006 3:42 pm
Da P3s7 wrote: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING *** on line 22
where as line 22 is
echo "$row['Name']" . ", " . "$row['Description']" . ", " . "$row['Path']" . ", " . "$row['Executed']" . ", " . "$row['Sold']" . ", " . "$row['Price']" . ".";
Any ideas?
Thx by the way.
Pleae try and use php tags and not code tags
Your problem is here:
Code: Select all
echo $row['Name'] . ", " . $row['Description'] . ", " . $row['Path'] . ", " . $row['Executed'] . ", " . $row['Sold'] . ", " . $row['Price'];