Jump to content


php / mysql beginner question

  • Please log in to reply
1 reply to this topic

#1 webguy

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 23 June 2003 - 06:11 PM

Hello all,

I\'m new here and hope that someone has the answer of a real beginner.
I\'ve read several tutorials but what i want isn\'t working.

I have a little table with some fields:

name varchar(100) NOT NULL default \"\",
nr int(5) NOT NULL,
descr text NOT NULL,
UNIQUE KEY nr (nr),
UNIQUE KEY name (name)
) TYPE=MyISAM COMMENT=\"Products\";

I have a working php program to add data to the database.
I also have a little php program to list all records in the database.
Now i need a program that can be called with a parameter to show all fields of a product like:


My program looks like this:

include \'db.php\';
<body bgcolor=\"#ffffff\" >

# setup SQL statement
$sql = \" SELECT * FROM prod WHERE nr = \'$prodnr\'\";
# execute SQL statement
$rs = mysql_query($sql, $cid);
if (mysql_error()) { print \"Database Error: $sql \" . mysql_error(); }
# display results
print \"<p><b>Products</b><p>n\";
print \"<table border=0>\";
while ($row = mysql_fetch_array($rs))
$name = $row[\"name\"];
$nr = $row[\"nr\"];
$descr = $row[\"descr\"];
print \"<tr><td>$name</td><td>$nr</td><td>$descr</td><tr>\";
print \"</table>\";

But, i get NO results! I\'ve made shure product nr 3 is in the database, i\'ve checked it with PHPMYADMIN.
What am i doing wrone here? Can anybody point me in the right direction?

Thanks in advace,

#2 shivabharat

  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 24 June 2003 - 05:14 AM

ur code looks fine and I guess u have

opened a database connection and also selected the database in ur include file

also use the die command to check for error and u dont have to use a if to find that out.
Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users