PHP: problem with index.php

iam geting a error with this index script. heres the error

Parse error: parse error in c:\phpdev\www\dev\compulearn\in work\index.php on line 39

Whats wrong??

------------------------

<?php

//display header and left bars
include ('header.php');
include ('left.php');

//connect to the MySql Database

$conn = db_connect();

$sql = "select * from message
where page = '$page'
and published is not null
order by published desc";
$result = mysql-query($sql, $conn);

while ($story = mysql_fetch_array($result))
{
if ($story['picture']) {
$size = getImageSize ($story['picture']);
$width = $size[0];
$height = $size[1];
print "<img src=\"".$story['picture']."\" height=\"$height\" width=\"$width\" align=\"left\" />";

//print test from databasse
print $story['story_text'];
}

//display footer
include ('footer.php');
?>

Are you suppose to have an endwhile at the bottom of that - or a closing } ?

i've solved that, but now I want to read the text from the mySql db and display in that page.
i keep gettin a error :
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\phpdev\www\dev\compulearn\in work\main.php on line 18

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\phpdev\www\dev\compulearn\in work\main.php on line 19

heres what ive done. Can sumone solve this

----------------------------
<?php
include ('include_fns.php');
include ('header.php');
include ('left.php');
include_once('db_fns.php');

//connect to the MySql Database

$conn = db_connect();

$sql = "select * from stories
where page = '$pages'
and published is not null
order by published desc";
$result = mysql_query($sql, $conn);
while ($story = mysql_fetch_array($result))
{

$size = getImageSize($story['picture']);
$width = $size[0];
$height = $size[1];
print "<img src=\"".$story['picture']."\" height=\"$height\" width=\"$width\" align=\"left\" />";

print $story['story_text'];
}

include ('footer.php');

?>

Maybe this will show a more specific error?

Replace

$result = mysql_query($sql, $conn);

with

$result = mysql_query($sql, $conn) or die(mysql_error());

now I get this

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\phpdev\www\dev\compulearn\in work\main.php on line 18
Access denied for user: 'content@127.0.0.1' (Using password: NO)

ive no user or password on the db.

this is whats in the db_fns.php which is inlcuded once in main.php

<?php
//connect to database and retreive info from tables
function db_connect()
{
$result = @mysql_pconnect('localhost', 'content', '');
if (!$result)
return false;
if (!@mysql_select_db('content'))
return false;

return $result;
}

function get_story_record($story)
{
$conn = db_connect();
$sql = "select * from stories where id = '$story'";
$result = mysql_query($sql, $conn);
return(mysql_fetch_array($result));
}

?>

i then removed the usr and pass stuuf to:

<?php
//connect to database and retreive info from tables
function db_connect()
{
$result = @mysql_pconnect('', '', '');
if (!$result)

and i get this now

Unknown column 'published' in 'where clause'

I have no data in the database.

Okay, so that wasn't incredibly more helpful. :smiley:

I'm not sure what else to suggest - I don't know php so this is beyond me; maybe someone else here knows php...

okay, i have a table named stories. it has 1 picture.
i have the db done fine

how do i just get the text from it and display it and align the pic to the right top side of the text.
i have this but will it work

$conn = db_connect();

$sql = "select * from stories
where page = '$page'
and published is not null
order by published desc";
$result = mysql_query($sql, $conn);

while ($story = mysql_fetch_array($result))
{
print '<h2>'.$story['headline'].'</h2>';
if ($story['picture']) {
$size = getImageSize($story['picture']);
$width = $size[0];
$height = $size[1];
print "<img src=\"".$story['picture']."\" height=\"$height\" width=\"$width\" align=\"left\" />";

}
print $story['story_text'];

}

I'd watch while ($story = mysql_fetch_array($result)) - it looks like you might be assigning a new value to $story. Is there a comparison operator, like == ?

i wrote this one, and get no errors, but it wont display anything . It will coneect to the db, cause if i change stuff in the dbconnect.php, it displays unable to connect to db, which is the custom error i put in. I have changed db's to make sure i didnt make a mistake in creating the db, but still nottin. Whats wrong with the script?

<?php

include('dbconnect.php');
include('header.php');

$result = mysql_query("select * from message")
or die (mysql_error());

while ($row = mysql_fetch_array($result));
{

print $row['text'];

}
mysql_free_result($result);

?>

Okay, see if this helps:

that worked :smiley: thanks, now

PHP doesnt really support html stuff, so have alook at this

www.compulearn.ie and see the text, with the picture, how do i get php to display exactly like that, but php gets it from mysql.

what kinda code would i have to put into mysql for php to display like that,

ive made the menu bar on the left part of the header.php, but php puts the text from mysql underneat that, how do i get php to put the text where it is on the website, do i have to put like <<maintext>> thing in so it will place the text there ?

Thanks

okay, heres the problem.

i have drawin a diagram below to show what happens when my sql print the text. I have a header and left bar, named header.php ( includes the left bar) and it puts the text under all that as shown.

+--------------------------------------------------------+
| |
| HEADER |
+---------+----------------------------------------------+
| Home |
| News |
| Links |
| Contact|
| Join Us|
| Login |
| Register|
+----------+
TEXT ENDS UP DOWN HERE

But i want it like this

+--------------------------------------------------------+
| |
| HEADER |
+---------+----------------------------------------------+
| Home | I WANT THE TEXT TO GO HERE LIKE
| News | THIS BUT IT WONT DO IT FOR ME !!!!
| Links |
| Contact|
| Join Us|
| Login |
| Register|
+----------+

Can someone tell me y mysql puts the text down under everything??
I also want to have a admin interface to edit that e.g.

A text box and a edit button and it will change the text.

Please someone help me

I think it'd help if you pasted the contents of header.php, if it's not too big...

its too big.

is it possible to get mysql to print to a varaible?eg...

+--------------------------------------------------------+
| |
| HEADER |
+---------+----------------------------------------------+
| Home |
| News |
| Links |
| Contact| $printhere
| Join Us|
| Login |
| Register|
+----------+