View Full Version : Resolved wrong synax error
slappyjaw 08-28-2009, 06:06 AM Error:
SQL 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 'from, to) VALUES ('slappyjaw', 'slappyjaw')' at line 1.
Developer Details:
SQL error: INSERT INTO friend_requests (from, to) VALUES ('slappyjaw', 'slappyjaw');. (SQL_ERROR)
tNG Execution Trace - VIEW
ugh idk why i am getting this error. I have tried so many different things and i dont think that there is anything that is wrong with my synax. this is it
$customTransaction->setSQL("INSERT INTO friend_requests (from, to) VALUES ({From_}, {To_});");
Any help is appreciated thanks!!:thumbsup:
The from and to part at the end is a variable. But is there something that you have to add before the begining of the colum selection part of the mysql.
i noticed you are using either Developer toolbox or mx kollection to build this, but this doesnt look like something it would generate, did you change the value variables at all?
slappyjaw 08-28-2009, 06:17 AM yes it is a custom sql synax. Do you use the developer toolbox. Also witht eh synax that it created i got a create fake record set error. Idk why though?
whizard 08-28-2009, 06:18 AM That's what I thought (that the variables were weird, I wasn't familliar with the specific libraries), but the error messages seemed to print out the correct values (I'm assuming)
is it inserting the data at all?
slappyjaw 08-28-2009, 06:20 AM yes. i didnt think that there was anything wrong with the information but my mysql server was also updated and is the current version. idk if that makes the difference.
slappyjaw 08-28-2009, 06:20 AM no to seco's post
can you post more of the code for this
slappyjaw 08-28-2009, 06:21 AM <?php
// Load the common classes
require_once('includes/common/KT_common.php');
// Load the tNG classes
require_once('includes/tng/tNG.inc.php');
// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");
// Make unified connection variable
$conn_mysql = new KT_connection($mysql, $database_mysql);
// Start trigger
$formValidation = new tNG_FormValidation();
$tNGs->prepareValidation($formValidation);
// End trigger
// Make a custom transaction instance
$customTransaction = new tNG_custom($conn_mysql);
$tNGs->addTransaction($customTransaction);
// Register triggers
$customTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Custom1");
$customTransaction->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);
$customTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{GET.request}");
// Set custom transaction SQL
$customTransaction->setSQL("INSERT INTO friend_requests (from, to) VALUES ({From_}, {To_});");
// Add columns
$customTransaction->addColumn("From_", "STRING_TYPE", "POST", "From_", "{SESSION.kt_login_user}");
$customTransaction->addColumn("To_", "STRING_TYPE", "POST", "To_", "{GET.request}");
// End of custom transaction instance
// Execute all the registered transactions
$tNGs->executeTransactions();
// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);
?><?
//Include headers!
$title = "Send friend request";
include("header.php");
?>
<head>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<?php echo $tNGs->displayValidationRules();?></head>
<body>
<p> Are you sure that you would like to send a friend request?</p>
<p>
<?php
echo $tNGs->getErrorMsg();
?>
<form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr>
<td class="KT_th"><label for="From_">From:</label></td>
<td><input type="text" name="From_" id="From_" value="<?php echo KT_escapeAttribute($row_rscustom['From_']); ?>" size="32" />
<?php echo $tNGs->displayFieldHint("From_");?> <?php echo $tNGs->displayFieldError("custom", "From_"); ?> </td>
</tr>
<tr>
<td class="KT_th"><label for="To_">To:</label></td>
<td><input type="text" name="To_" id="To_" value="<?php echo KT_escapeAttribute($row_rscustom['To_']); ?>" size="32" />
<?php echo $tNGs->displayFieldHint("To_");?> <?php echo $tNGs->displayFieldError("custom", "To_"); ?> </td>
</tr>
<tr class="KT_buttons">
<td colspan="2"><input type="submit" name="KT_Custom1" id="KT_Custom1" value="Insert record" />
</td>
</tr>
</table>
</form>
<p> </p>
</p>
</body>
</html>
slappyjaw 08-28-2009, 06:21 AM i left out the connection to the mysql part that it created.
hmm yeah thats very strange, everything looks fine.
try this for ****s and giggles
$customTransaction->setSQL("INSERT INTO friend_requests (from, to) VALUES ({SESSION.kt_login_user}, {To_});");
slappyjaw 08-28-2009, 06:30 AM mm still no same error its so wierd like sometimes this **** works but then it throws errors i like the developer toolbox but it seems to have bugs. It posts the values still but says theres an error.
yeah that doesnt make sense, you can surpress the errors if it is inserting the data.
PappaJohn 08-28-2009, 06:35 AM Both 'from' and 'to' are MySQL reserved words.
Ideally, you should change the field names. If you insist on using them, you'll have to enclose them in backticks in your query:
slappyjaw 08-28-2009, 06:43 AM ok i got it i think it was my MYSQL DATABASE! ugh.. Thank you all for your help especially you seco! and you papajohn. sorry i didnt see your post when i had posted this the webpage was old.
slappyjaw 08-28-2009, 06:44 AM oh ok thank you pappajohn
PappaJohn 08-28-2009, 06:59 AM :thumbsup:
|
|