Page 1 of 1

Coding Help needed

Posted: Wed Jul 19, 2006 3:31 pm
by Da P3s7
Pimptastic | Please use

Code: Select all

,

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 :wink:


Pimptastic | Please use

Code: Select all

,

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]

Posted: Wed Jul 19, 2006 3:35 pm
by hawleyjr
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['...']

Posted: Wed Jul 19, 2006 3:39 pm
by Da P3s7
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

Posted: Wed Jul 19, 2006 3:42 pm
by hawleyjr
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

$row['Executed']". ",

Code: Select all

echo $row['Name'] . ", " . $row['Description'] . ", " . $row['Path'] . ", " . $row['Executed'] . ", " . $row['Sold'] . ", " . $row['Price'];