SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member bazt's Avatar
    Join Date
    Oct 2000
    Location
    Northern Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi folks

    I have been working my way thru the tutorials and am having

    some problems.

    Authors/Managing Authors works fine but when it has some

    "authors" in it all I get is the bulit piont and the option

    to edit or delete.

    Any suggestions??

    Thanks in advance

    bazt

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which tutorial you are talking about?
    I don't quite understand what problem you having. So please clarify, maybe I could help
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Member bazt's Avatar
    Join Date
    Oct 2000
    Location
    Northern Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi there
    I'm working my way thru the PHP/mysql database tutorial on

    the jokes database by Kevin Yank

    There is a PHP file for doing admin on the joke authors

    table ie:- add delete edit their details. although it works

    fine (I can add/edit/delete info) it shows up a list of

    authors in the table but without a name against the entry?

    hope this is more helpfull

    bazt

  4. #4
    SitePoint Member bazt's Avatar
    Join Date
    Oct 2000
    Location
    Northern Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    further to my last bit I had to move machine here is the code that is giving me a problem

    $advertisers = mysql_query("SELECT ID, AdvertiserName FROM Advertisers");
    if (!$advertisers) {
    echo("<P>Error retrieving advertisers from database!<BR>".
    "Error: " . mysql_error());
    exit();
    }

    while ($advertiser = mysql_fetch_array($advertisers)) {
    $id = $advertiser["ID"];
    $name = $advertiser["AdvertiserName"];
    echo("<LI>$name ".
    "[<A HREF='editadvertisers.php?id=$id'>Edit</A>|".
    "<A HREF='deleteadvertisers.php?id=$id'>Delete</A>]");
    }


    when this is echoed <li> gives a bullit point $name gives nothing editadvertisers & deleteadvertisers work fine

    I know I have missed something I just can't see it


    Thanks folks

    bazt

  5. #5
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    i have duplicated the problem.

    this is code i am using on my site.

    $shops = mysql_query("SELECT shop_id, name FROM shop");
    if (!$shops) {
    echo("<P>Error retrieving shops from database!<BR>".
    "Error: " . mysql_error());
    exit();
    }

    while ($shop = mysql_fetch_array($shops)) {
    $shop_id = $shop["shop_id"];
    $name = $shop["name"];
    echo("<LI>$name ".
    "[<A HREF='editshop.php?shop_id=$shop_id'>Edit</A>|".
    "<A HREF='deleteshop.php3?shop_id=$shop_id'>Delete</A>]");
    }

    i remembered having the same problem you described while turning up my site.

    By changing to the following line:

    while ($Shop = mysql_fetch_array($shops)) {

    i get the same result. Just $Shop instead of $shop.

    But i think for you is should be $Advertisers instead of $advertiser

    But for sure, this is the area to work in.


  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    bazt,

    The problem you're having is symptomatic of a misspelled variable name, but as far as I can tell at this late hour, your code is flawless!

    Did you copy/paste your code into your message directly?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Member bazt's Avatar
    Join Date
    Oct 2000
    Location
    Northern Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Folks

    edshuck I will give that a go and let you know how I get on
    kyank The code was cut&pasted from the page

    Ta Folks

    bazt

  8. #8
    SitePoint Member bazt's Avatar
    Join Date
    Oct 2000
    Location
    Northern Ireland
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Back again folks

    I changed the variable names from advertiser to Advertiser and this made no real change

    However as I was working thru some of the other pages I discovered that the "name" field of the database which should appear elswhere dosen't if I go in and edit the advertiser the name then becomes visible in the aformentioned page and it seemed (at 1am) not to matter weither Ad or ad was the variable name ??? Hey sure I'm learning.( so an auld dog can be taught new tricks after all).

    I'll keep at it untill it works

    Barry


  9. #9
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    cut and paste this code and it should work. the one change i made is the spelling of Advertisers in the start of the while statement. This makes it match the spelling of the table name.

    $advertisers = mysql_query("SELECT ID, AdvertiserName FROM Advertisers");
    if (!$advertisers) {
    echo("<P>Error retrieving advertisers from database!<BR>".
    "Error: " . mysql_error());
    exit();
    }

    while ($Advertisers = mysql_fetch_array($advertisers)) {
    $id = $advertiser["ID"];
    $name = $advertiser["AdvertiserName"];
    echo("<LI>$name ".
    "[<A HREF='editadvertisers.php?id=$id'>Edit</A>|".
    "<A HREF='deleteadvertisers.php?id=$id'>Delete</A>]");
    }

    [Edited by edshuck on 10-23-2000 at 10:11 AM]

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry Ed I doubt that will work you have
    while ($Advertisers = mysql_fetch_array($advertisers)) {
    $id = $advertiser["ID"];
    $name = $advertiser["AdvertiserName"];
    echo("<LI>$name ".
    "[<A HREF='editadvertisers.php?id=$id'>Edit</A>|".
    "<A HREF='deleteadvertisers.php?id=$id'>Delete</A>]");
    }

    And then you try and call $id = $advertiser["ID"]
    What you should beusing is
    while ($advertiser = mysql_fetch_array($advertisers)) {
    $id = $advertiser["ID"];
    $name = $advertiser["AdvertiserName"];
    echo("<LI>$name ".
    "[<A HREF='editadvertisers.php?id=$id'>Edit</A>|".
    "<A HREF='deleteadvertisers.php?id=$id'>Delete</A>]");
    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •