Good morning
in the book of kevin jank , joke.php capitol 7 this funciton
if (mysql_num_rows($catresult) < 1)
{
exit('<p>Couldn\‘t find specified category in the database!</p>’);
don’t is ready!!!
Good morning
in the book of kevin jank , joke.php capitol 7 this funciton
if (mysql_num_rows($catresult) < 1)
{
exit('<p>Couldn\‘t find specified category in the database!</p>’);
don’t is ready!!!
You must be using a really old edition of the book as the latest version uses PDO and the previous version would have used either PDO or mysqli_* The mysql_* functions are depreceated as of the current version of php
I’m designing my website and I have this old book as a reference . How can I update this file ?
thanks
/ Get category name
$ catresult = @ mysql_query ( " SELECT name from category WHERE id = ' $ cat ' ");
if ($ catresult ) {
exit ( ' Error retrieving Into category name from database ! <br /> ' .
' Error : ' . mysql_error ( ) . ' </ p >');
}
if ( mysql_num_rows ($ catresult ) < 1 )
{
exit ( ' Into couldn \\ ' t find specified category in the database </ p > ');
}
$ catdetail = mysql_fetch_array ($ catresult ) ;
$ catname = htmlspecialchars ($ catdetail ['name ' ] ) ;
Else { }
$ catname = ' All ' ;
}
? >
<h1> <? php echo $ catname ; ? > Jokes </ h1>
<table>
<tr> <th> Joke Text </ th> <th> Author </ th> <th> Date < / th> < / tr>
<? php
$ jokes = @ mysql_query ($ jokessql ) ;
if ($ jokes ) {
echo ( ' </ table >');
exit ( ' Error retrieving Into jokes from the database! <br /> ' .
' Error : ' . mysql_error ( ) . ' </ p >');
}
while ($ joke = mysql_fetch_array ($ jokes )) {
$ id = $ joke [ ' id ' ] ;
joketext = $ $ joke [ ' LEFT ( joketext , 20) ' ] ;
/ / If the joke text is 20 characters long , add " ... " to the end of it
/ / To set That it is actually longer. strlen ( ) returns string length !
if ( strlen ($ joketext ) == 20) {
$ joketext . = "..." ;
}
/ / Remove any custom tags (even partial ones! ) In the joke text . They are not needed in this preview.
$ joketext = ereg_replace ( ' \\ \\ [ ( B | EB | I | EI | L | L = | L = [ -_./a-z0-9 ! &% #? + , \\ ' = : ; @ ~] + | EL | E) ? ( ] | $) ' ,'', $ joketext ) ;
/ / Finally , make it safe to display in an HTML document
$ joketext = htmlspecialchars ($ joketext ) ;
$ author = htmlspecialchars ($ joke ['name ' ] ) ;
$ email = htmlspecialchars ($ joke ['email ' ] ) ;
JDate = $ $ joke [ ' jokedate ' ] ;
echo " <tr valign=\\"top\\"> \\ n";
echo " <a <td> href=\\"joke.php?id=$id\\"> $ joketext </ a> < / td> \\ n";
echo " <a <td> href=\\"mailto:$email\\"> $ author </ a> < / td> \\ n";
echo " $ <td> JDate </ td> \\ n";
echo " </ tr> \\ n";
}
? >
</ table>
Into <a href="index.php"> Back to front page </ a> < / p>
</ body>
</ html>
Have a read through this article (http://www.sitepoint.com/migrate-from-the-mysql-extension-to-pdo/) which explains about how to migrate from the old and deprecated mysql_* extension over to PDO.