Jump to content


Photo

dynamic text using php and mysql


  • Please log in to reply
6 replies to this topic

#1 joepro0000

joepro0000
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 15 April 2006 - 10:10 PM

I want to pull info out mysql and put it on a php page, but I keep getting errors. heres the script I got.



<?php
// this line connects to database
include_once("connections/connections.php");

$result = mysql_query("SELECT sample, Category FROM category");
// we use the names of columns as <row> properties.
echo "colors=";
while ($row=mysql_fetch_array($result)
$line = $row[C].'.';
echo $line;

?>





#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 16 April 2006 - 07:24 PM

What errors? MySQL errors?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 16 April 2006 - 07:42 PM

[!--quoteo(post=365374:date=Apr 16 2006, 08:24 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 16 2006, 08:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What errors? MySQL errors?
[/quote]
is it your php syntax by any chance?..

try
while($row = mysql_fetch_array($result))
{
$line = $row[c];
echo $line;
}


#4 joepro0000

joepro0000
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 April 2006 - 10:16 PM

[!--quoteo(post=365374:date=Apr 16 2006, 03:24 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 16 2006, 03:24 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
What errors? MySQL errors?
[/quote]


>> Parse error: parse error, unexpected T_VARIABLE in /home/content/j/o/e/joepro0000/html/display.php on line 3<<

My code is-

<? php
// Vars - fill these in
$address = "localhost"; // The address of your database server. Leave as "localhost" if it's on the same machine, otherwise put the IP or domain name of the machine it's on.
$username = "Username"; // MySQL username
$password = "Password"; // MySQL password
$db = "joepro0000"; // The database to use
$table = "Category"; // The table your data is in


// Connect to the server
$conn = mysql_connect($address, $username, $password);
// Select database
$rs = mysql_select_db($db, $conn);
while($row = mysql_fetch_array($result))
{
$line = $row[c];
echo $line;
}

?>


#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 April 2006 - 11:16 PM

First, that's definitely a PHP error -- are you sure you can use barewords for hash keys? And which line is 3?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 joepro0000

joepro0000
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 17 April 2006 - 11:57 PM

First, that's definitely a PHP error -- are you sure you can use barewords for hash keys? And which line is 3?<<

not sure about barewords, I'm a php newbie.

I just want content drawn out my mysql table/database and be placed on a php page. I want to make dynamic text.

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 18 April 2006 - 07:34 AM

I understand -- is the "c" a column name? Where does it come from?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users