SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2013
    Location
    Florence
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql_fetch_array ($variable) formatazione

    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!!!!!!

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    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
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2013
    Location
    Florence
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm designing my website and I have this old book as a reference . How can I update this file ?
    thanks
    PHP Code:
    / 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> <thJoke Text </ th> <thAuthor </ th> <thDate < / 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 longerstrlen ( ) 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>
    Last edited by SpacePhoenix; Oct 14, 2013 at 14:17. Reason: placed php tags around php code

  4. #4
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Have a read through this article (http://www.sitepoint.com/migrate-fro...ension-to-pdo/) which explains about how to migrate from the old and deprecated mysql_* extension over to PDO.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •