(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
//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
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