<? include '/usr/home/o/z/ozefrog/public_html/lib/header.inc'; ?>
<?php
// Important : keep your database table name as 'joke4'..i.e don't touch the select statements
include("joke4cfg.php");
$connection = mysql_connect($serverAddress,$databaseName,$serverPass)or die("Couldn't make connection.");
$db = mysql_select_db($databaseName,$connection)or die("Couldn't select database");
$limit=20; // rows to return
$numresults=mysql_query("select * from joke4 order by date_post desc");
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=0;
}
echo "<center><strong><font face=verdana size=3>Q&A Jokes</font></strong></center><br>";
echo "<hr width=90% size=1 color=#000000 noshade>";
echo "<br><br>";
// get results
$result=mysql_query("select * from joke4 order by date_post desc limit $offset,$limit");
// now you can display the results returned
while ($data=mysql_fetch_array($result)) {
echo "<table width=475 border=0 align=center id=AutoNumber2>";
echo "<tr>";
echo "<td width=55 bgcolor=#FFCC00><b><font size=2 face=Verdana> Name:</font></b></td>";
echo "<td width=420 bgcolor=#008BCE align=justify><font face=Verdana size=2 color=#ffffff>".$data[0]."</font></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=55 bgcolor=#FFCC00><b><font face=Verdana size=2> IP:</font></b></td>";
echo "<td width=420 bgcolor=#008BCE align=justify><font face=Verdana size=2 color=#ffffff>".$data[1]."</font></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=55 bgcolor=#FFCC00 height=60 valign=top><b><font size=2 face=Verdana> Question:</font></b></td>";
echo "<td width=420 bgcolor=#008BCE height=60 valign=top align=justify><font face=Verdana size=2 color=#ffffff>".$data[2]."</font></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=55 bgcolor=#FFCC00 height=60 valign=top><b><font size=2 face=Verdana> Answer:</font></b></td>";
echo "<td width=420 bgcolor=#008BCE height=60 valign=top align=justify><font face=Verdana size=2 color=#ffffff>".$data[3]."</font></td>";
echo "</tr>";
echo "</table>";
echo "<br>";
}
// next we need to do the links to other results
print "<center><font face=verdana size=2>Page Number: </font>";
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
print "<font face=verdana size=2><a href=\"$PHP_SELF?offset=$newoffset\">$i</a> </font>\n";
}
print "</center>";
mysql_close($connection);
?> <br>
<hr width="90%" size="1" color="#000000" noshade>
<script language=javascript>
function validate()
{
if (document.frm.usr_name.value==""){
alert("Please enter your name.");
return false;
}
if (document.frm.usr_joke.value==""){
alert("Please tell us your joke.");
return false;
}
if (document.frm.usr_ans.value==""){
alert("Please tell us your answer.");
return false;
}
}
</script>
<br>
<p align=center><font size=2 face=verdana>Please fill out the following to add your joke to our archive</font></p>
<form name="frm" action="joke4show.php" method="Post" onSubmit="return validate();">
<table width="400" border="0" cellspacing="1" cellpadding="3" align="center" id="AutoNumber1" style="border-collapse: collapse">
<tr>
<td width="50"><b><font size="2" face="Verdana">Name:</font></b></td>
<td width="350"><input type="text" name="usr_name" size="33"><input type="hidden" name="usr_id" size="30" value="<? echo $REMOTE_ADDR ?>"></td>
</tr>
<tr>
<td width="50" valign="top"><b><font size="2" face="Verdana">Question:</font></b></td>
<td width="350"><textarea rows="7" name="usr_joke" cols="32"></textarea></td>
</tr>
<tr>
<td width="50" valign="top"><b><font size="2" face="Verdana">Answer:</font></b></td>
<td width="350"><textarea rows="7" name="usr_ans" cols="32"></textarea></td>
</tr>
<tr>
<td width="50"> </td>
<td width="350"><input type="submit" value="Add">
<input type="reset" value="Clear"></td>
</tr>
</table>
</form>
<? include '/usr/home/o/z/ozefrog/public_html/lib/footer.inc'; ?>
<?php
include("joke4cfg.php");
$date_post = date("Y-m-d H:i:s");
$connection = mysql_connect($serverAddress,$databaseName,$serverPass)or die("Couldn't make connection.");
$db = mysql_select_db($databaseName,$connection)or die("Couldn't select database");
$insertSql ="insert into joke4 values ('".$usr_name."','".$usr_id."','".$usr_joke."','".$usr_ans."','".$date_post."')";
mysql_query($insertSql);
mysql_close($connection);
include '/usr/home/o/z/ozefrog/public_html/lib/header.inc';
echo "\n\n<font face=verdana size=2><center><strong>Your joke has been added into the joke archive!</center></strong></font><br><br>";
echo "<br><br><br><br><font size=2><center>Click <a href=joke4.php>Here</a> to go back to the joke archive.</font></center>";
include '/usr/home/o/z/ozefrog/public_html/lib/footer.inc';
?>
php_flag magic_quotes_runtime off
set_magic_quotes_runtime( 0 );
Originally posted by fatman
Just a long shot: did you place the function *after* the "<?" - ie,
Code:<? set_magic_quotes_runtime ( 0 ); ...
Well, show the code the prints out the text, not all the code.Originally posted by ozefrog
i placed it after the <?
Originally posted by megapuzik
This should work !!!
<? include '/usr/home/o/z/ozefrog/public_html/lib/header.inc'; ?>
<font face=verdana size=2>
<p align=center><b>The following is being added to the CheapHumour joke archive:</b><br><br><br>
<table width="475" border="0" align="center" id="AutoNumber2">
<tr>
<td width="55" bgcolor="#FFCC00"><b><font size="2" face="Verdana"> Name:</font></b></td>
<td width="420" bgcolor="#008BCE" align="justify"><font face=Verdana size=2 color=#ffffff><?php echo ($usr_name);?></font></td>
</tr>
<tr>
<td width="55" bgcolor="#FFCC00"><b><font face="Verdana" size="2"> IP:</font></b></td>
<td width="420" bgcolor="#008BCE" align="justify"><font face=Verdana size=2 color=#ffffff><?php echo ($usr_id);?></font></td>
</tr>
<tr>
<td width="55" bgcolor="#FFCC00" height="60" valign="top"><b><font size="2" face="Verdana"> Question:</font></b></td>
<td width="420" bgcolor="#008BCE" height="60" valign="top" align="justify"><font face=Verdana size=2 color=#ffffff><?php echo ($usr_joke);?></font></td>
</tr>
<tr>
<td width="55" bgcolor="#FFCC00" height="60" valign="top"><b><font size="2" face="Verdana"> Answer:</font></b></td>
<td width="420" bgcolor="#008BCE" height="60" valign="top" align="justify"><font face=Verdana size=2 color=#ffffff><?php echo ($usr_ans);?></font></td>
</tr>
</table>
<br><br>
<p align=justify><font face=verdana size=2>If you wish to edit this information, click on "Go Back", or click "Add Entry" to add it to our archive.</font></p><br>
<form name=actualsubmit method=post action="joke4add.php">
<input type=hidden name="usr_name" value="<?php echo $usr_name;?>">
<input type=hidden name="usr_id" value="<?php echo $usr_id;?>">
<input type=hidden name="usr_joke" value="<?php echo $usr_joke;?>">
<input type=hidden name="usr_ans" value="<?php echo $usr_ans;?>"><br>
<font face=verdana size=2>
<center><a href="javascript:history.back();">Go Back</a> | <a href="javascript:document.actualsubmit.submit();">Add Entry</a>
</center></font>
</form>
<? include '/usr/home/o/z/ozefrog/public_html/lib/footer.inc'; ?>
Originally posted by fatman
Actually both solutions (.htaccess and the function call) should work.
Ozefrog, if you get a parse error, you need to find out why. Eg, was something spelt wrongly, or was the file accidentally was uploaded in binary, etc?
BTW, which PHP version are you using? (I should have asked this at the beginning! )