SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 56

Thread: Script problems

  1. #26
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Weblife
    but i had went through the forms to add results to the database with tests many times, so if thers no results theres obviously something wrong with database
    Did you verify the data was in the database? You should use phpMyAdmin to take a look in the database to see if the data you entered is there.

  2. #27
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Weblife
    ok i did a few things and now when i open display.php it tells me

    No results sorryUnknown column 'status' in 'where clause'
    Write out your db schema for list e.g.

    Code:
    ID
    First
    Last
    Email
    Status
    Because at the moment its saying that there isn't a column status in the table list. So if status isn't in list which table is it in?

    Sarah
    Regular user

  3. #28
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it says :

    Warning: Supplied argument is not a valid MySQL result resource in /users/iwebland.com/scars/display.php on line 12

    line 12 is the loop

    whats going on ....?

  4. #29
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That means $result is empty. Could you, as Sarah asked you, show us what your table looks like?

  5. #30
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Weblife,

    please can you list what the columns are in your table list.

    as we still don't know if status is actually in that table

    and 2 can you look at the db and see that there is actually data in that table in all the fields?

    Sarah
    Regular user

  6. #31
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i created my table exactly like this :

    create database ml;

    use ml

    create table list (
    id int(11) not null auto_increment,
    first varchar(20) not null,
    last varchar(20) not null,
    email varchar(20) not null,
    key id (id)
    ) type=myisam;

    thats exactly what i did after i opened the mysql.exe file in c:\mysql\bin\mysql.exe

    should i have done anything more?

  7. #32
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in phpmyadmin it clearly states there is a database called ml and a table called list in it with the feilds id, first, last, email.....

    i dont know how to check if the feilds have any data in them.. sorry

  8. #33
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you should do is download phpMyAdmin and place it in the document root of your webserver. After that, use it to connect to MySQL.
    Apart from the things Sarah already mentioned, are you certain that MySQL is running?

  9. #34
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Weblife,

    So what about the status column? Basically the way you have written that is correct but as the sql error says there isn't a status column.

    So what is the status column and where did you want it placed? If you want it in the list table then you can do this to add it in

    Code:
    alter table list add (status, int);
    I have created it as a int file but it could also be a varchar file.

    Now you need to look at your inserting back at the code where you add details into the list table and see where you set this status variable.

    Sarah
    Regular user

  10. #35
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Weblife

    Using mysql.exe is fine that is what I use.

    So type in this command

    Code:
    select * from list
    that will display all the data on your screen.

    But basically as I said before the problem is that you do not have a status column in that table.

    sarah
    Regular user

  11. #36
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i took this php script out of php4 bible...

    i had no intention of having a status feild...

    so you want me to take out status? i just thought it was part of the code..

  12. #37
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind the previous post on phpMyAdmin.
    If you want to check whether or not you have inserted data, just above the fields of the table there are a few links. One is insert and one should be along the lines of explore. Click that one and you will see all the listed records in the database.

  13. #38
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Man, this is going way too fast. Updated code for you which should work:

    PHP Code:
    $connection mysql_connect("localhost",$username,$password);
      
    $db = @mysql_select_db($database$connection) or die( "Unable to select database");

      
    $query "SELECT ID, first, last, email FROM list";
      
    $result mysql_query($query$connection);
      while(
    $row mysql_fetch_array($result))
        echo 
    $row["ID"].","$row["first"].","$row["last"].","$row["email"].", <br>\n";
    mysql_close(); 

  14. #39
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when i put select * from list , it said "empty set"

    if its empty, which it is, do you think theres something wrong with my script for inserting into the database? because ive run that script many times and if therse nothing in the database....

  15. #40
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post that script?

  16. #41
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my insert script is exactly this :

    <?
    $username="*******";
    $password="******";
    $database="*******";

    mysql_connect("localhost",$username,$password);
    mysql_select_db($database) or die( "Unable to select database");

    $query = "INSERT INTO list VALUES ('$first','$last','$email')";
    mysql_query($query);

    mysql_close();
    ?>

  17. #42
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and the form script that i use to trigger that one goes like this :

    <html>
    <body>
    <form method="post" action="joinml.php">
    <input type="text" name="first"><br>
    <input type="text" name="last"><br>
    <input type="text" name="email"><br>
    <input type="submit" value="submit"><br>
    </form>
    </body>
    </html>

  18. #43
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    that script seems fine BUT that is certainly where the problem is.

    Where do you get the values from is email etc.. a form?

    Can you also include that code too?

    Thanks

    Sarah

    [edit - okay thanks for that code, can you also show the rest of the php code where you check that the form has been filled in? Sometimes goes along the lines of
    PHP Code:
    !isset($submit
    ]
    Regular user

  19. #44
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    since these messages seem to be going as fast as a chat room LoL i think il leave a msg saying im out for an hour bbl

  20. #45
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yo i just posted that... u musta missed it

  21. #46
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this one:
    PHP Code:
    <?
    $username
    ="******";
    $password="******";
    $database="******";

    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database"); 

    $query "INSERT INTO list SET first ='$first', last='$last', email='$email'";
    mysql_query($query);

    mysql_close();
    ?>
    If your PHP version is 4.2 or more, then you should use this script:

    PHP Code:
    <?
    $username
    ="******";
    $password="******";
    $database="******";

    $first $_POST['first'];
    $last $_POST['last'];
    $email $_POST['email'];

    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database"); 

    $query "INSERT INTO list SET first ='$first', last='$last', email='$email'";
    mysql_query($query);

    mysql_close();
    ?>

  22. #47
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what does $_Post

    do?

  23. #48
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    basically if you are using a later version of php or your version has register_globals as off. You cannot assume that on clicking your form the values will be available to work with.

    So after the form is submitted you get the values that have been posted from the form by doing the $name = $_POST['name']; as Mrak suggested.

    Sarah
    Regular user

  24. #49
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im running on version 2.2

    and when i use this script :

    <?
    $username="******";
    $password="******";
    $database="******";

    $first = $_POST['first'];
    $last = $_POST['last'];
    $email = $_POST['email'];

    mysql_connect(localhost,$username,$password);
    mysql_select_db($database) or die( "Unable to select database");

    $query = "INSERT INTO list SET first ='$first', last='$last', email='$email'";
    mysql_query($query);

    mysql_close();
    ?>



    it says error on line 14

    when it says line 14.. does that meen the lines of the html before that also?

  25. #50
    SitePoint Zealot
    Join Date
    May 2002
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and i just tested the other script.. and it gives me the exact same error... error on line 14


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
  •