sql error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sql error

    hi i use lava script. I did a normal form but does not work. if someone knows why. Thanks and sorry but my english is bad

    this is index.php file

    echo "<form action=\"main2.php?action=post&amp;sid=$sid\" method=\"post\">";

    echo "<b>Name:</b><br/><textarea name=\"ucaptxt\" rows=\"1\ cols=\"25\" maxlength=\"500\">$page[0]</textarea><br>";
    echo "Category: <select name=\"dir\" value=\"$dir[0]\">";
    if($dir[0]=="1"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"1\"$selected>bla bla</option>";
    if($dir[0]=="2"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"2\"$selected>bla bla 2</option>";
    if($dir[0]=="3"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"3\"$selected>bla bla 3</option>";
    if($dir[0]=="4"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"4\"$selected>bla bla 4</option>";
    if($dir[0]=="5"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"5\"$selected>bla bla 5</option>";
    if($dir[0]=="6"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"6\"$selected>bla bla 6</option>";
    if($dir[0]=="7"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"7\"$selected>bla bla 7</option>";
    if($dir[0]=="0"){$selected=" selected=\"selected\"";}else{$selected="";}
    echo "<option value=\"0\"$selected>bla bla 8</option>";
    echo "</select><br/>";
    echo "<input type=\"Submit\" value=\"ok\" name=\"Post\"></form>";


    this is main2.php file action="post"

    $who = cleanQuery($_GET["who"]);
    $user = getnick_sid($sid);
    $dir = cleanQuery($_POST["dir"]);
    $text = cleanQuery($_POST["ucaptxt"]);
    echo "<head>";
    echo "<title>Updating Shouts</title>";
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
    echo "</head>";
    echo "<body>";
    include("header.php");
    echo "<div align=\"center\">";
    echo "<b>Update Status</b><br/>";
    $uid = getuid_sid($sid);

    $shtm = time();
    $res = mysql_query("INSERT INTO ibwf_status SET stext='".$text."', stime='".$shtm."', uid='".$uid.", dir='".$dir."'");
    if($res)
    {
    echo "<img src=\"../images/ok.gif\" alt=\"O\"/>Your Status was Successfully change<br/><br/>";
    }else{
    echo "<img src=\"../images/notok.gif\" alt=\"X\"/>Database Error<br/><br/>";
    }
    echo "<a href=\"index.php?action=viewuser&amp;sid=$sid&amp; who=$uid\">Back To Profile</a><br/>";
    echo "<a href=\"index.php?action=status&amp;sid=$sid&amp;wh o=$uid\">Status Page</a><br/>";
    echo "<a href=\"index.php?action=main&amp;sid=$sid\">Home Page</a>";
    echo "</div>";
    include("footer.php");
    echo "</body>";

    #2
    what error you get? , what seems to be the problem ur having

    Comment


      #3
      show me a page that says Database Error.
      before adding the category drop-down list everything worked
      Last edited by dominik92r; 08.08.10, 14:06.

      Comment


        #4
        have you got field called dir in your ibwf_status table?

        Comment


          #5
          yes. but i choosen Char type maybe this is my bad
          Last edited by dominik92r; 08.08.10, 14:29.

          Comment


            #6
            use:
            PHP Code:
            $res mysql_query("INSERT INTO ibwf_status SET stext='".$text."', stime='".$shtm."', uid='".$uid.", dir='".$dir."'") or die("MySQL ERROR: ".mysql_error()); 
            to find your error

            Comment


              #7
              i have this error now
              Update Status
              MySQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3'' at line 1

              Comment


                #8
                one of these doesnt exsist: stext stime uid dir in your sql

                or maybe you need to change dir to something else as its probably getting mixed up with php function dir()

                Comment


                  #9
                  Originally posted by something else View Post
                  use:
                  PHP Code:
                  $res mysql_query("INSERT INTO ibwf_status SET stext='".$text."', stime='".$shtm."', uid='".$uid.", dir='".$dir."'") or die("MySQL ERROR: ".mysql_error()); 
                  to find your error
                  - Somethingelse, if i want to see the error in my page or code.
                  i always add this code or die("MySQL ERROR: ".mysql_error()) in mysql_query.
                  Am i right??
                  LESS TALK. LESS MISTAKE.

                  HTTP://APPSROB.COM - LIST OF MY FACEBOOK APPS!

                  Comment


                    #10
                    yeah add that after your mysql_query to see the error

                    Comment


                      #11
                      Thanks for this info somethingelse!
                      LESS TALK. LESS MISTAKE.

                      HTTP://APPSROB.COM - LIST OF MY FACEBOOK APPS!

                      Comment


                        #12
                        stext='".$text."', stime='".$shtm."', uid='".$uid.", dir='".$dir."

                        i see you have defined the following above recheck Ur syntax something is obviously spelt incorrect or not added as u defined

                        Comment


                          #13
                          PHP Code:
                          $res mysql_query("INSERT INTO ibwf_status SET stext='".$text."', stime='".$shtm."', uid='".$uid.", dir='".$dir."'") or die("MySQL ERROR: ".mysql_error()); 
                          stime, uid are integers, so insert values as integers, not as strings. Do not use INSERT ... SET command, instead use INSERT... VALUES command

                          Comment

                          Working...
                          X