Results 1 to 26 of 26

Thread: why wont this work?

  1. #1

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919

    why wont this work?

    sorry about all the questions, i'm VERY crappy with mysql.

    PHP Code:
     $mysql_select_db("fragblast",$db);
                    
                    
    $ip=getenv('REMOTE_ADDR');

                    
    $sql "INSERT INTO reviews (id,name,email,gamename,desc,
    system,score,review,ss1,ssd1,ss2,
    ssd2,ss3,ssd3,ip,password) VALUES ('','
    $name',
    '
    $email','$gid',
    '
    $desc','$system',
    '
    $score','$review','$ss1','$ssd1','$ss2','$ssd2',
    '
    $ss3','$ssd3','$ip','$password')";

                    
    $result mysql_query($sql);
                    
                    print 
    'Thank you, your review has been submitted into the database'
    whenever i add something, nothing gets inserted into the table
    it doesnt give any errors. the first field, "id", is auto-increment
    Last edited by nabeels786; Apr 20th, 2002 at 05:38 PM.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    leave ID out alltogether, don't even set it to a zero length string

  3. #3

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    still doesn't work
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    hmm...

    are all the table and field names correct?
    have you permission to insert into tables?
    unlikely, but try seperating comma values with a space...sometimes it gets upset about that

    e.g. name, email, gamename, desc etc

  5. #5

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    how do you give permission to insert into a table?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    if it's your computer, save yourself a lot of bother and download phpmyadmin from here http://phpwizard.net/projects/phpMyAdmin/

    Install on your computer then use it to open the mysql table. From there you can change permissions for all the users

    If it's a remote server run by somebody else, you can try doing that but I wouldn't fancy your chances. Ask them if you have permission and if not, to grant it to you.

  7. #7

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    yeah thats what im using. but how exactly do i add in permissions?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  8. #8
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    On the main page, you'll see a Users link. Click that and you'll get the permissions page, where you can specify down to a fine level all the things a user can do

  9. #9

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    Yep, I have permissions for everything, still won't add anything in
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  10. #10
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    okay

    Is all the data valid?

    e.g. are you trying to insert text into a number field anywhere?

  11. #11

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    everything is a text field except id
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  12. #12
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    try getting phpmyadmin to do the query. If that can't do it either, there must be something wrong with mysql.

  13. #13

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    the query

    "INSERT INTO reviews (name) VALUES ('testing')"

    works fine, within SQL admin. im making a quick page to check whether it works on a page
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  14. #14

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    my mini test page worked fine, i guess there is something wrong with my query
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  15. #15
    scoutt
    Guest
    try this
    PHP Code:
    $mysql_select_db("fragblast",$db);
                    
                    
    $ip=getenv('REMOTE_ADDR');

                    
    $sql "INSERT INTO reviews (id,name,email,gamename,desc,
    system,score,review,ss1,ssd1,ss2,
    ssd2,ss3,ssd3,ip,password) VALUES ('','
    $name',
    '
    $email','$gid',
    '
    $desc','$system',
    '
    $score','$review','$ss1','$ssd1','$ss2','$ssd2',
    '
    $ss3','$ssd3','$ip','$password')";

                    
    $result mysql_query($sql);
                    echo 
    $sql;
                    if (!
    $result){
                    echo 
    mysql_error($result)
                    }
                    print 
    'Thank you, your review has been submitted into the database'
    I think I have that right. it will print out the insert statment to see if you have the query right. you can comment it out after it is working properly. also the mysql_error will tell you if there is a problem with you query. I think I have the correct syntax for mysql_error, if not I will post it later. I am not at my computer right now so don't have nothing to confirm it.

  16. #16

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    Here whats i got

    INSERT INTO reviews (id,name,email,gamename,desc, system,score,review,ss1,ssd1,ss2, ssd2,ss3,ssd3,ip, password) VALUES ('','Nabeel','[email protected]','','sdf','pcgame','7','sdf','','','','','','','127.0.0.1','just atest')
    Warning: Supplied argument is not a valid MySQL-Link resource in c:\inetpub\wwwroot\reviews\submit.php on line 167
    its the ss1..stuff, those are optional fields, i guess its complaining hat they're blank. how do i specify that those can be blank?


    edit: its not complaining about that, i entered everything in...bah?
    Last edited by nabeels786; Apr 20th, 2002 at 07:10 PM.
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  17. #17
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I don't know what to say dude, it's beyond me why there is anything wrong with that query but
    Warning: Supplied argument is not a valid MySQL-Link resource in c:\inetpub\wwwroot\reviews\submit.php on line 167
    means there is something wrong with it because it couldn't return a valid pointer

    Perhaps you have set a restriction on the fields not to accept null values?

  18. #18

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    the attributes are "not null" for all of them, if thats what you mean
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  19. #19
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    yes, that is what I meant.

    Did you try using phpmyadmin to run the query outputted by the code scoutt gave you?

  20. #20

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    lets see

    MySQL said:


    You have an error in your SQL syntax near 'desc, system,score,review,ss1,ssd1,ss2, ssd2,ss3,ssd3,ip, password) VALUES ('','' at line 1
    maybe its the spaces thing?
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  21. #21
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    can't hurt to try. I always space them so I wouldn't know if not spacing works or not

  22. #22

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i spaced them out, then took out the spaces, still didnt do anything. I cant find anything wrong with the peice of code it said was errored
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  23. #23
    scoutt
    Guest
    Originally posted by chrisjk
    I don't know what to say dude, it's beyond me why there is anything wrong with that query butmeans there is something wrong with it because it couldn't return a valid pointer

    Perhaps you have set a restriction on the fields not to accept null values?
    the reason you got that error is because one of the category names maybe wrong.

    double check your category names. I think it is picky as to the spaces, not sure. keep it all one line. I did notice a space after desc, and nothing on anything else.

    $sql = "INSERT INTO reviews (id,name,email,gamename,desc,system,score,review,ss1,ssd1,ss2,ssd2,ss3,ssd3,ip,password) VALUES ('','$name','$email','$gid','$desc','$system','$score','$review','$ss1','$ssd1','$ss2','$ssd2','$ss3 ','$ssd3','$ip','$password')";

  24. #24

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    i fixed it, iguess it didnt like the name "desc", i changed it to "describ", and it worked fine
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

  25. #25
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    OMG I can't beleive I didn't notice!!

    DESC is a keyword in the ORDER BY clause, so it got confused

  26. #26

    Thread Starter
    Fanatic Member nabeels786's Avatar
    Join Date
    Jul 2001
    Location
    New York
    Posts
    919
    lol, yep that could be a problem,

    thanks for the help though
    Visit www.fragblast.com
    Gaming, forums, and a online RPG/Battle system




    (__Flagg) DOT NET? is this a Hindi Dating service?

Posting Permissions

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



Click Here to Expand Forum to Full Width