Re: Probably a beginners error but...

From: Date: Sun, 01 Oct 2000 20:53:29 +0000
Subject: Re: Probably a beginners error but...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-18219@lists.php.net to get a copy of this message
you cannot just output directly from the query, I assume you want to either loop through a list or rows that you retrieved or that you just have one row. Either way you need to run a $thisrow = mySQL_fetch_row($result). The current row is then set in the array $thisrow and you can access each column thusly: $thisrow[0] $thisrow[1] ... hope that this helps. If you want to loop through each row then just put it in a while loop like this: while($thisrow = mySQL_fetch_row($result)) { ...your code... } Take a look at this page for all the avaliable PHP commands that deal with mySQL: http://php.net/manual/ref.mysql.php --Matt ----- Original Message ----- From: "Jari Ivanoff" <jari.ivanoff@telia.com> To: "PHP" <php-general@lists.php.net> Sent: Sunday, October 01, 2000 4:42 PM Subject: [PHP] Probably a beginners error but... > .. since I am a beginner... :-) > I am creating a php script that is getting some data from a MySQL database > and print out the data: > <?php > > $db = mysql_connect("localhost","root"); > mysql_select_db("news",$db); > $result = mysql_query("select * from news",$db); > > printf("Datum: %s <br>\n", mysql_result($result,0,"datum"); > printf("Klockslag: %s <br>\n", mysql_result($result,0,"tid"); > printf("Rubrik: %s <br>\n", mysql_result($result,0,"rubrik"); > printf("Innehåll: %s <br>\n", mysql_result($result,0,"innehall"); > ?> > > > I get this error message in my browser: > Parse error: parse error in c:\apache\htdocs\newsout.php on line 8 > I get the same error message on every single one of the printf lines. > Sorry about that some of the words are in swedish.. > /Jari > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#18219) next »