SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question can any one tell me why this dosnt work

    PHP Code:
    //Retrieves data from MySQL

     
    $data mysql_query("SELECT * FROM register where name='$myname'") or die(mysql_error());
     
    $count mysql_num_rows($data);
     if (
    $count== 0) {
     Echo 
    "No record of that name";
     } else {
    //Puts it into an array 
    while($info mysql_fetch_array$data )) 

    //Outputs the image and other data
    Echo "<img src=http://www.lostpetsplymouth.com/images/".$info['pname'] ." alt=\"Image\" align=\"center\" width=\"150px\" height=\"150px\" hspace=\"10px\" vspace=\"8px\"> <br>";
    Echo 
    "<b>State:</b> ".$info['state'] . " <br>";
    Echo 
    "<b>Type:</b> ".$info['type'] . " <br>";
    Echo 
    "<b>Area:</b> ".$info['area'] . " <br>";
    Echo 
    "<b>Description:</b> ".$info['desc'] . " <br>";
    Echo 
    "<b>If Seen Please Tel:</b> ".$info['tel'] . " <br>";

    mysql_close();

    ?> 
    suppose to count rows and if = 0 then print no record
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What makes you think it "doesn't work"?
    What did you expect to happen?
    What actually happened?

  3. #3
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you enter a name in login box
    this is suppose to check the name by counting rows i think so no match rows = 0 then message come up no record
    all i am getting is blank screen
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You probably have a parse error somewhere, and have disabled display_errors. Are you developing locally, or are you uploading to your web host to test?

    It looks like you're missing a closing curly brace, but without seeing the entire script nobody but you can tell.

  5. #5
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need another closing brace after mysql_close to close the if else statement.

  6. #6
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok cheers works now
    but is it poss instead of printing no record
    can i send to another page called errors
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  7. #7
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($count == 0) {
     
    header('Location: http://www.youriste.com/errorspage.html');# could also be errorspage.php
     
    exit;
    } else {
    #while loop


  8. #8
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    big thanks to all
    have it sorted now
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net


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
  •