The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MySQL Help
|
Whats worng here?
Discuss Whats worng here? in the MySQL Help forum on Dev Shed. Whats worng here? MySQL Help forum discussing administration, SQL syntax, and other MySQL-related topics. MySQL is an open-source relational database management system (RDBMS).
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 19th, 2012, 11:18 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 13
  
Time spent in forums: 3 h 23 m 4 sec
Reputation Power: 0
|
|
|
Whats worng here?
this error message appears when i run my code in php
#1064 - 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 '19:37:36,jhj,jhjh)' at line 1
this is the code for the class:
html Code:
Original
- html Code |
|
|
|
<script type="text/javascript">
function changeButton(){
if(document.getElementById("name").value !=""){
$("#button1").text("Send to: "+ document.getElementById("name").value);
}else{
$("#button1").text("Send Message");
}
}
</script>
</head>
<body>
<?php
if($_GET["op"]=="send_message"){
$to = $_POST["username"];
$from = $_SESSION["valid_user"];
$time_sent = date('Y-m-d H:i:s');
$subject = $_POST["subject"];
$message = $_POST["message"];
include("dbConfig.php");
$enter_mess = "INSERT INTO private_message (to_id,from_id,time_sent,subject,message) VALUES (0,0,$time_sent,$subject,$message)";
//declare in the order variable
$result = mysql_query($enter_mess) or die(mysql_error()); //order executes
if($result){
echo "message sent!!!<br> </br>";
echo $_POST["message"]."<br> </br>";
}else{echo"error";}
}else{
?>
<form action="?op=send_message" id="send_message" method="POST">
<fieldset>
<legend>Message</legend>
Username:<br /> <input name="username" type="text" id="name" onkeyup="changeButton()" size="15" /><br />
Subject:<br /> <input name="subject" type="text" id="subject" size="30" /><br />
Message:<br /> <textarea name="message" cols="50" rows="10" id="message"></textarea>
<br />
<button id="button1">Send Message</button>
</fieldset>
</form>
<script>
$('textarea').jqte();
</script>
<?php }?>
|

November 19th, 2012, 11:24 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
immediately before you do this --
Code:
$result = mysql_query($enter_mess)
please do this -- then, copy/paste the actual sql string here, and we'll show you what's wrong with it
|

November 19th, 2012, 11:29 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 13
  
Time spent in forums: 3 h 23 m 4 sec
Reputation Power: 0
|
|
|
this is what came up
INSERT INTO private_message (to_id,from_id,time_sent,subject,message) VALUES (0,0,2012-11-19 17:29:02,jhj,jhjh)
|

November 19th, 2012, 11:32 AM
|
 |
SQL Consultant
|
|
Join Date: Feb 2003
Location: Toronto Canada
|
|
there's your problem
datetime strings need to be enclosed in single quotes
also, string strings need to be enclosed in single quotes
Code:
VALUES ( 0 , 0 , '2012-11-19 17:29:02' , 'jhj' , 'jhjh' )
|

November 19th, 2012, 11:35 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 13
  
Time spent in forums: 3 h 23 m 4 sec
Reputation Power: 0
|
|
thankyou that worked 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|