sql error

Started on the old forum in August 2010 · view the original in the archive · old links redirect here

#sql-error

12 replies · 579 views · started 16 years ago · 1 min read

5 participants
dominik92r Junior · 38 posts #1

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&sid=$sid" method="post">";

echo "Name:

<textarea name=\"ucaptxt\" rows=\"1\ cols=\"25\" maxlength=\"500\">$page[0]</textarea>

"; 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> "; 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 ""; echo "Update Status "; $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

"; }else{ echo "<img src="../images/notok.gif" alt="X"/>Database Error

"; } echo "<a href="index.php?action=viewuser&sid=$sid&who=$uid">Back To Profile</a> "; echo "<a href="index.php?action=status&sid=$sid&who=$uid">Status Page</a> "; echo "<a href="index.php?action=main&sid=$sid">Home Page</a>"; echo ""; include("footer.php"); echo "</body>";

realcoder Junior · 17 posts #2

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

brandon rules the codeing industry

dominik92r Junior · 38 posts #3

show me a page that says Database Error. before adding the category drop-down list everything worked

something else Fellow · 2,296 posts #4

have you got field called dir in your ibwf_status table?

dominik92r Junior · 38 posts #5

yes. but i choosen Char type maybe this is my bad

something else Fellow · 2,296 posts #6

use:

$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

dominik92r Junior · 38 posts #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

something else Fellow · 2,296 posts #8

one of these doesnt exsist: stext stime uid dirin your sql

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

robzky Developer · 205 posts #9

something else wrote: use:

$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!

something else Fellow · 2,296 posts #10

yeah add that after your mysql_query to see the error 🙂

robzky Developer · 205 posts #11

Thanks for this info somethingelse! 🙂

LESS TALK. LESS MISTAKE.

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

realcoder Junior · 17 posts #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

brandon rules the codeing industry

rukiya Lead · 569 posts #13
$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

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close