View Full Version : Resolved wrong synax error

08-28-2009, 07:06 AM
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.

08-28-2009, 07:16 AM
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?

08-28-2009, 07: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?

08-28-2009, 07: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)

08-28-2009, 07:20 AM
is it inserting the data at all?

08-28-2009, 07: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.

08-28-2009, 07:20 AM
no to seco's post

08-28-2009, 07:20 AM
can you post more of the code for this

08-28-2009, 07:21 AM
// Load the common classes

// Load the tNG classes

// 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();
// End trigger

// Make a custom transaction instance
$customTransaction = new tNG_custom($conn_mysql);
// 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

// 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";
<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>
<p> Are you sure that you would like to send a friend request?</p>
echo $tNGs->getErrorMsg();
<form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>">
<table cellpadding="2" cellspacing="0" class="KT_tngtable">
<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>
<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 class="KT_buttons">
<td colspan="2"><input type="submit" name="KT_Custom1" id="KT_Custom1" value="Insert record" />

08-28-2009, 07:21 AM
i left out the connection to the mysql part that it created.

08-28-2009, 07:27 AM
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_});");

08-28-2009, 07: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.

08-28-2009, 07:33 AM
yeah that doesnt make sense, you can surpress the errors if it is inserting the data.

08-28-2009, 07: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:

08-28-2009, 07: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.

08-28-2009, 07:44 AM
oh ok thank you pappajohn

08-28-2009, 07:59 AM