Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 74
Trades: 0
(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
 
 
Register now for full access!
Old 01-12-2005, 06:53 AM
vivekar's Avatar
Webmaster Talker

Posts: 612
Trades: 0
PHP Code:
**echo $row['works_id']; 
why there are some two stars?
Remove them. It should work fine.
__________________

Please login or register to view this content. Registration is FREE
(Active since 2003) |
Please login or register to view this content. Registration is FREE
vivekar is offline
Reply With Quote
View Public Profile Visit vivekar's homepage!
 
Old 01-12-2005, 06:54 AM
Ultra Talker

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

What's that??
__________________
andrews_john

Please login or register to view this content. Registration is FREE
andrews_john is offline
Reply With Quote
View Public Profile Visit andrews_john's homepage!
 
Old 01-12-2005, 08:26 AM
qnc
Skilled Talker

Posts: 74
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.13720 seconds with 12 queries