2day i hve another problem ..this is my code

<?php
$data = mysql_query("SELECT * FROM entries ORDER BY id DESC LIMIT $x

, 3")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo"
<div id=\"containing\">s
<h1>".$info['contents']."</h1>


<div id=\"parent\" >
<p >".$info['author'] ."</p>
</div>
</div>
<?php
echo "<a href=\"$info['contents'].php\" >READ MORE</a>";
?>
";
}
?>

and i m getting this error in the 'echo <a href .....' line

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\xampp\htdocs\display.php


please reply fast

On line 16, you never closed out that echo statement.
Change line 16 to this:

</div>"; ?>

i didnt get u .
by the way now i tried this code

$data = mysql_query("SELECT * FROM entries ORDER BY id DESC LIMIT $x

, 3")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo"
<div id=\"containing\">s
<h1>".$info."</h1>
<div id=\"parent\" >
<p >".$info ."</p>
</div>
</div>
<a href=\"$info.php\" >READ MORE</a>
";
}
?>
its again showing error

<?php
$data = mysql_query("SELECT * FROM entries ORDER BY id DESC LIMIT $x, 3") or die(mysql_error());

while($info = mysql_fetch_array( $data )){
echo 
"<div id='containing'>s
    <h1>".$info['contents']."</h1>
    <div id='parent'> 
        <p >".$info['author'] ."</p>
    </div>
</div>";

echo "<a href='$info['contents'].php' >READ MORE</a>"; 
}
?>

Change this line:

<a href=\"$info.php\" >READ MORE</a>

To this:

<a href=\"".$info['contents'].".php\" >READ MORE</a>

learn to indent your codes for readability (see my code above)

The indentation was not causing the error, but it does help with readability!

yes i know... Daedal has solved my problem ...thanx for showing the interest in my problem evstevemd

this is my code of a php page

<?php
$p=big;
include_once"entry.php"; ?>

and whenever i load this page i see the following notice written on the top of the page .. can u tell whts the reason behind it??

Notice: Use of undefined constant big - assumed 'big' in C:\xampp\htdocs\big.php on line 2

I would have to see the code in the big.php file. I'm guessing you are setting a value without quotes around it.

Example:

$list[big] = "BIG WORDS";

Should be this way:

$list['big'] = "BIG WORDS";

the code i wrote above is of the none other than big.php file.i m again writing the code written in big.php file

<?php
$p=big;
include_once"entry.php"; ?>

PHP thinks that big is a constant because it does not have quotes.
Change

$p=big;

To this:

$p='big';

okk...i got it but there is an another problem ..this page is created dynamically and the code i wrote to create the big.php page dynamically is..

$_SESSION=$post;
$string = '<?php
$p='.$_SESSION.';
include_once"entry.php"; ?> ';
$fp = fopen("$post.php", "w");
fwrite($fp, $string);
fclose($fp);

here $post=big
so now how to write
$p='big'; which corresponds to the line $p='.$_SESSION.';?? i mean how to insert big in the quotes. hope u hve understand my problem

If the value is already a variable, then just do it this way:

$p=$_SESSION['z'];

If the value is a new string you can set it with quotes:

$p='big';

i didnt understand ... which value u r talking abt ??

heyy my value is already a variable n this line gives an error

$p=$_SESSION;

I am not sure I know either. :) What value do you want $p to have?

This does not need PHP open and close tags. (<?php ?>)

$string = '<?php
$p='.$_SESSION['z'].';
include_once"entry.php"; ?> ';

Use this:

$string = $_SESSION['z'];
include_once"entry.php";

dude ..ur code is not working .. i hve to use php open and close tagsto create dynamic pages

You keep changing your coding, what is the error, and what are you trying to accomplish?

u said that i hve to write this $p='big'; in big.php page
its working
but i m creating big.php page dynamically
so how to write code to insert 'big' in the quotes which is already a variable. i was using this

$p='.$_SESSION.'; to write $p=big in big.php page . now i want to write $p='big' .. HOW ???

If $_SESSION = 'big' already, then use the code you had:
You only need to add quotes if you are creating a new variable as a string.

//Just use this
//no quotes
$p=$_SESSION['z'];

i m assigning this

$post='big';
$_SESSION = $post;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.