Reply
displaying database content
Old 01-12-2005, 05:45 AM displaying database content
qnc
Skilled Talker

Posts: 74
(N.B. ***** used to keep esential info)

Hi there I created a database "******_ents" and then a table "works_test" in it
server uses phpmyadmin 2.6.1-rc1 with MySQL 4.0.22-standard

[sql]
CREATE TABLE works_test (
works_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
works_name TEXT NOT NULL ,
works_url TEXT NOT NULL ,
sub_date DATE NOT NULL );
[/sql]

Then i populated works_test with info

[sql]
INSERT INTO `works_test` ( `works_id` , `works_name` , `works_url` , `sub_date` )
VALUES (
'', 'tasha', 'http://www.qnctv.com/trini/tasha.jpg', CURDATE( )
), (
'', 'sando', 'http://www.qnctv.com/trini/sando.jpg', CURDATE( )
), (
'', 'purple', 'http://www.qnctv.com/trini/purple.jpg', CURDATE( )
), (
'', 'mayaro', 'http://www.qnctv.com/trini/mayaro.jpg', CURDATE( )
), (
'', 'maracas', 'http://www.qnctv.com/trini/maracas.jpg', CURDATE( )
), (
'', 'mtstbe', 'http://www.qnctv.com/trini/mtstbe.jpg', CURDATE( )
), (
'', 'mackeson', 'http://www.qnctv.com/trini/mackeson.jpg', CURDATE( )
);
[/sql]

then i checked with phpmyadmin to see that all was there using browse which gives the command SELECT * FROM `works_test` LIMIT 0 , 30


Then made this simple webpage to see what is in the database online.
Server has PHP Version 4.3.9 installed
page views at http://qnctv.com/testbed/firstphp/gallery/display.php

PHP Code:
<?php
//set paramenets
$dbhost '******';
$dbuser '******';
$dbpass '******';
$dbname '******_ents';
$dbtabl 'works_test';

// Connect to the database server
$dbcon mysql_connect($dbhost$dbuser$dbpass) OR die('could not connect to MySQL: ' mysql_error());

// Select the  database
mysql_select_db ($dbname) OR die('could not connect to database: ' mysql_error());

//query the database
$sql="SELECT * FROM $dbtabl";
$result mysql_query($sql) or die ('Failed to execute ' $sql ' due to ' mysql_error());

// generate and display result
while ($row mysql_fetch_array($result))
{  
**echo 
$row['works_id']; 
  echo 
$row['works_name'];
  echo 
$row['works_url']; 
  echo 
$row['sub_date'];
}
?>
I get
Parse error: parse error, unexpected T_VARIABLE in /home/qncqnc/public_html/testbed/firstphp/gallery/display.php on line 25 (where The echo is_

If I just use echo $result; instead of the while(){} I get Resource id #3.

What is going wrong. Also the replacement of $dbtabl in $sql with works_test makes no difference
qnc is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-12-2005, 05:53 AM
vivekar's Avatar
Webmaster Talker

Posts: 539
PHP Code:
**echo $row['works_id']; 
why there are some two stars?
Remove them. It should work fine.
__________________
| Submit URL at All the Websites Directory
| Get Certified in Web Design
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 01-12-2005, 05:54 AM
Ultra Talker

Posts: 377
**echo $row['works_id'];

What's that??
__________________
andrews_john
www.softwareforhosting.com
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 01-12-2005, 07:26 AM
qnc
Skilled Talker

Posts: 74
intersting i put two spaces in my code and that came up as ** when I copied and pasted it over when I put the echo code flush to the new line it works!!!

thanks
amazing what a fresh pair of eyes does!!
qnc is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to displaying database content
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13147 seconds with 12 queries