syntax error in my code
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
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
On line 16, you never closed out that echo statement.
Change line 16 to this:
</div>"; ?>
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
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"
s
".$info['contents']."
".$info['author'] ."
READ MORE
";
}
?>
its again showing error
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
<?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>";
}
?>
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
Change this line:
READ MORE
To this:
<a href=\"".$info['contents'].".php\" >READ MORE</a>
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
learn to indent your codes for readability (see my code above)
evstevemd
Senior Poster
3,713 posts since Jun 2007
Reputation Points: 462
Solved Threads: 392
The indentation was not causing the error, but it does help with readability!
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
yes i know... Daedal has solved my problem ...thanx for showing the interest in my problem evstevemd
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
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
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
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";
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
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"; ?>
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
PHP thinks that big is a constant because it does not have quotes.
Change
$p=big;
To this:
$p='big';
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
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['z']=$post;
$string = '<?php
$p='.$_SESSION['z'].';
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['z'].';?? i mean how to insert big in the quotes. hope u hve understand my problem
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
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';
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
i didnt understand ... which value u r talking abt ??
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
heyy my value is already a variable n this line gives an error
$p=$_SESSION['z'];
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
I am not sure I know either. :) What value do you want $p to have?
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
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";
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12
dude ..ur code is not working .. i hve to use php open and close tagsto create dynamic pages
aaloo
Junior Poster in Training
76 posts since Oct 2011
Reputation Points: 22
Solved Threads: 0
You keep changing your coding, what is the error, and what are you trying to accomplish?
Daedal
Junior Poster in Training
75 posts since Apr 2008
Reputation Points: 23
Solved Threads: 12