PHP: problem with index.php


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PHP: problem with index.php
# 1  
Old 07-02-2003
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');
?>
# 2  
Old 07-02-2003
Are you suppose to have an endwhile at the bottom of that - or a closing } ?
# 3  
Old 07-02-2003
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');


?>
# 4  
Old 07-02-2003
Maybe this will show a more specific error?

Replace

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

with

$result = mysql_query($sql, $conn) or die(mysql_error());
# 5  
Old 07-02-2003
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.
# 6  
Old 07-02-2003
Quote:
Originally posted by perleo
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)
Okay, so that wasn't incredibly more helpful. Smilie

I'm not sure what else to suggest - I don't know php so this is beyond me; maybe someone else here knows php...
# 7  
Old 07-02-2003
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'];

}
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running php index.php as shell in webpage

so i have a bit of a unique situation. i have an encrypted index.php file that that can't be run the normal way that a web browser would run it. if it is run the normal way, the php script will show only gibberish on the web browser, instead of the actual php code. when run from the command... (8 Replies)
Discussion started by: SkySmart
8 Replies

2. Red Hat

Update php 4.3 RPM to php 5.3.3 php

Dear All, My redhat version is: # cat /etc/redhat-release Red Hat Enterprise Linux AS release 4 (Nahant Update 4) # # uname -a Linux cotapplication3.cot.com 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:32:02 EDT 2006 x86_64 x86_64 x86_64 GNU/Linux # I want to update my php from: # php... (1 Reply)
Discussion started by: monojcool
1 Replies

3. UNIX for Advanced & Expert Users

Running multiple php scripts into one php only, cron mail alert problem...

hi, while separated they produce the usual mail alert and i can see the output... if i write into the php script: <?php system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script1.php'); system('php -f /var/www/vhosts/domain.com/httpdocs/folder/script2.php'); system('php -f... (0 Replies)
Discussion started by: 7stars
0 Replies

4. Web Development

I can't open my index.php page after insert php code

Hello guys, Does anyone can help me? I've just made my simple index.php without any code, but after insert session code to check if any user is authenticated, my index.php doesn't work anymore. Any fresh eyes could help me to see what and where the code is wrong? <? if... (6 Replies)
Discussion started by: metalfreakbr
6 Replies

5. Shell Programming and Scripting

Index problem with awk

Hello, I have this code: #!/bin/sh awk -v val="........." 'BEGIN{FS=OFS=" ";c=0} NR==FNR&&d==0{a=$0; c++;next} FNR==(NR-c){b=val;next} {if(1234 in a){print "okay"}} {print $1}' listi fpr.11 grn that is working (awk find the value in the table "a" and return "okay" followed by 1234) ... (2 Replies)
Discussion started by: jolecanard
2 Replies

6. Filesystems, Disks and Memory

why the inode index of file system starts from 1 unlike array index(0)

why do inode indices starts from 1 unlike array indexes which starts from 0 its a question from "the design of unix operating system" of maurice j bach id be glad if i get to know the answer quickly :) (0 Replies)
Discussion started by: sairamdevotee
0 Replies

7. Linux

PHP problem

Hi frnds I installed phpmyadmin for OTRS but when ever i tried to open the phpMyAdmin-2.6.2/index.php page i m getting the following error " urldecode the db name if (isset($lightm_db)) { // no longer urlencoded because of html entities in the db name // $db =... (8 Replies)
Discussion started by: naik_mit
8 Replies
Login or Register to Ask a Question