You have an error in your SQL syntax with tinymce - tinymce

Hi my script ading system is working perfectly but when i use tinymce plugin so i get this error please help fast if anyone can solve that
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 'color: #008000;">dsfdsfsdfsfdfsdfsdfsd", zone1 = "http://www.k' at line 8
this is my adding note code in userpanel
function add_note($note_title, $note_detail, $orient, $c_s, $zone1, $zone2, $zone3, $zone4, $z4_1, $z4_2, $z4_3, $zone5, $z5_1, $z5_2, $z5_3, $zone6, $z6_1, $z6_2, $z6_3, $s_m, $sm_back, $sm_text, $sm_direction, $sm_speed) {
global $db;
$query = 'INSERT into notes VALUES(NULL, "'.date("Y-m-d").'", "'.$note_title.'", "'.$note_detail.'", "'.$orient.'", "'.$c_s.'", "'.$zone1.'", "'.$zone2.'", "'.$zone3.'", "'.$zone4.'", "'.$z4_1.'", "'.$z4_2.'", "'.$z4_3.'", "'.$zone5.'", "'.$z5_1.'", "'.$z5_2.'", "'.$z5_3.'", "'.$zone6.'", "'.$z6_1.'", "'.$z6_2.'", "'.$z6_3.'", "'.$s_m.'", "'.$sm_back.'", "'.$sm_text.'", "'.$sm_direction.'", "'.$sm_speed.'", "'.$_SESSION['user_id'].'")';
$result = $db->query($query) or die($db->error);
return 'Note added successfuly!';
}//add notes ends here.
Here is this link of Full Code of my notes.php
http://pastebin.com/a6sNeXD0

all users Attention here for soloution if they want to use tinymce and they get error like this so they must have to enter there table like this
mysql_real_escape_string($sql_table).
so my code is like this
$query = 'INSERT into notes VALUES(NULL, "'.date("Y-m-d").'", "'.$note_title.'")
so i just add mysql_realescape_string
$query = 'INSERT into notes VALUES(NULL, "'.date("Y-m-d").'", mysql_real_escape_string($notetitle))
and it works but it show me
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established i
so for that you have to add this in before that $query thing :)
$con = mysql_pconnect("localhost","users","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
and you'r done ..... thanks for all help

Related

Different settings for sys_log in database and log file

i want to deactivate error logs in the database completely no error, no exception and no warning in the sys_log table in the database. I want to use a log file instead - all logging should happen only in this log file. (TYPO3 9 LTS)
Is there a possibility to achieve this?
Thanks
Peter
It seems only possible with an own ExceptionHandler and overloading the method writeLogEntries() in TYPO3\CMS\Core\Error\AbstractExceptionHandler:
protected function writeLogEntries(\Throwable $exception, $context) {
// snip
if ($this->logger) {
$this->logger->critical($logTitle . ': ' . $logMessage, [
'TYPO3_MODE' => TYPO3_MODE,
'exception' => $exception
]);
}
// Write error message to sys_log table
$this->writeLog($logTitle . ': ' . $logMessage);
}
There is no configuration possibility, every exception is written to log file and database.

Password change plugin in poste.io fails

I am experiment with poste.io mail server. It uses rouncube as its web interface. I tried to enable the password plugin.
I see below error whenever I try to set the password:
[21-Mar-2017 13:00:31 +0100]: DB Error: [1] no such function: update_passwd (SQL Query: SELECT update_passwd('$1$LXeDlIT0$NGunS8gcCOSrKK2ZJ6RIW/', 'naidu#example.com')) in /opt/www/webmail/program/lib/Roundcube/rcube_db.php on line 539 (POST /webmail/?_task=settings&_action=plugin.password-save)
The internet is full of using mysql as the database. I think I have to update the password change query in
/opt/www/webmail/plugins/password/config.inc.php
from
$sql = 'SELECT update_passwd(%c, %u)';
to
$sql = 'UPDATE mailaccount SET password=%c WHERE nname=%u LIMIT 1';
The UPDATE statement above is valid for mysql. What is the equivalent for sqlite3 database?
I have a setup consist of postfix with sqlite and my sql query is as below:
UPDATE mailbox SET password=%c WHERE username=%u LIMIT 1
My sqlite config as below:
$config['password_db_dsn'] = 'sqlite:////var/vmail/postfixadmin.db?mode=0646';
$config['password_query'] = 'UPDATE mailbox SET password=%c WHERE username=%u LIMIT 1';
Add this for debugging:
$config['debug_level'] = 4;
$config['sql_debug'] = true;
$config['imap_debug'] = true;
$config['ldap_debug'] = true;
$config['smtp_debug'] = true;
Hope this helps.

MYSQLi PHP connect

Is the following a valid mysqli php connect insert statement?
if($mysql_query = $conn->query("INSERT INTO users (username,password,question,securityanswer) VALUES ('$uname','$upass','$selectquestion','$answer')"))
{
?>
<script>alert('successfully registered ');</script>
<?php
}
else
{
?>
<script>alert('error while registering you...');</script>
<?php
}
}
However I am getting error as "error while registering you..."
Thanks
Issue is resolved. There was an issue with the "user_id" column primary key which was being updated duplicate(0 value) with this error "Duplicate entry '0' for key 'PRIMARY'. Upon updating user_id column with auto increment in phpmyadmin, the INSERT query got updated successfully.
Using the below code to check for errors helped.
die(mysqli_error($conn));
A simple example:
<?php
//Create the connection
$con = mysqli_connect("HostName","UserName","password","DBName") or die("Some error occurred during connection " . mysqli_error($con));
// Write query
$strSQL = "SELECT username FROM MyTable";
// Execute the query.
$query = mysqli_query($con, $strSQL);
while($result = mysqli_fetch_array($query))
{
echo $result["username"]."
";
}
// Close the connection
mysqli_close($con);
?>
Can you paste the whole block with connection statement?
Otherwise SQL statement looks fine. Excepct you should escape inputs to MySQL
if($mysql_query = $conn->query("INSERT INTO users (username,password,question,securityanswer) VALUES ('$uname','$upass','$selectquestion','$answer')"))
Why using if($mysql_query = $conn->query ?
better
if($conn->query("INSERT INTO users (username,password,question,securityanswer) VALUES ('$uname','$upass','$selectquestion','$answer')") === TRUE)

Errors in codeigniter-restserver library

I want to use restful in my ci 3.03 application:
I found this tutplus tutorial
I downloaded codeigniter-restserver-master.zip file and copied Format.php and REST_Controller.php(#version 3.0.0) files into /application/libraries/REST directory
I created control application/controllers/api/Users.php :
require_once("application/libraries/REST/REST_Controller.php");
require_once("application/libraries/REST/Format.php");
class Users extends REST_Controller
{
//protected $rest_format = 'json';
function users_get()
{
//$users = $this->user_model->get_all();
$filter_username= $this->get('filter_username');
$filter_user_group= $this->get('filter_user_group');
$filter_active= $this->get('filter_active');
$sort= $this->get('sort');
$sort_direction= $this->get('sort_direction');
//, $filter_user_group, $filter_active, $sort, $sort_direction
$users_list = $this->muser->getUsersList(false, ''/*, $filter_username, $filter_user_group, $filter_active, $sort, $sort_direction, ''*/);
echo '<pre>'.count($users_list).'::$users_lists::'.print_r($users_list,true).'</pre>';
if($users_list)
{
$this->response($users, 200);
}
else
{
$this->response(NULL, 404);
}
}
AND RUNNING URL http://local-ci3.com/api/users I got many errors:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Users::$format
Filename: REST/REST_Controller.php
Line Number: 734
Backtrace:
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 734
Function: _error_handler
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 649
Function: response
File: /mnt/diskD_Work/wwwroot/ci3/index.php
Line: 292
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Users::$format
Filename: REST/REST_Controller.php
Line Number: 752
Backtrace:
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 752
Function: _error_handler
File: /mnt/diskD_Work/wwwroot/ci3/application/libraries/REST/REST_Controller.php
Line: 649
Function: response
File: /mnt/diskD_Work/wwwroot/ci3/index.php
Line: 292
Function: require_once
Actually I wanted to get some workable library to help me with REST api creation. I think that is preferable way istead of making from zero.
But is this library not workable or does it needs for some fixing? Sorry, what I missed is if this library only for ci 2?
I made search on this forum and found such hint :
I have the same problem when I load both Format.php and
Rest_Controller.php into a controller. After have a quick glance at
Format.php, it appears to be a standalone format conversion helper.
Try to just load Rest_Controller.php and see if your problem goes
away.
I commented line
//require_once("application/libraries/REST/Format.php");
in my controller, but I still get errors like :
Message: Undefined property: Users::$format.
I tried to review code of this library and see that invalid block when data are converted to json format, line 731-757 :
elseif ($data !== NULL)
{
// If the format method exists, call and return the output in that format
if (method_exists($this->format, 'to_' . $this->response->format))
{
// Set the format header
$this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset')));
$output = $this->format->factory($data)->{'to_' . $this->response->format}();
// An array must be parsed as a string, so as not to cause an array to string error
// Json is the most appropriate form for such a datatype
if ($this->response->format === 'array')
{
$output = $this->format->factory($output)->{'to_json'}();
}
}
else
{
// If an array or object, then parse as a json, so as to be a 'string'
if (is_array($data) || is_object($data))
{
$data = $this->format->factory($data)->{'to_json'}();
}
// Format is not supported, so output the raw data as a string
$output = $data;
}
}
If I tried to commented this block, but get error
Message: Array to string conversion
Looks like data are not converted in this case...
Is is possible to fix these errors?
Or can you, please, to tell me advice some codeigniter 3 REST api workable library with similar interface like library above?
Thanks!
I use that lib, work just fine. My suggestion is follow the more relevant installation instruction on github .
you also wrong place the lib file :
Tutorial say :
require(APPPATH'.libraries/REST_Controller.php');
You try :
require_once("application/libraries/REST/REST_Controller.php");
require_once("application/libraries/REST/Format.php");
No need to include the format because on line 407 the lib will load it. And also good to know on line 404 it will load the configuration (application/config/rest.php) it will be your default configuration, and also you can change it to suit your need.
Please let me know if you still got error using my answer :)

Using Soap in magento

I'm trying to follow the information about how to use soap in magento, but always get same message in error.log
If any one experience something similar, that could give me some tip, it will be welcome.
"PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.site.com/index.php/api/?wsdl' : failed to load external entity "http://www.site.com/index.php/api/?wsdl"\n in /var/www/test.php on line 1"
$client = new SoapClient('http://www.site.com/api/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'somestuff.method');
$result = $client->call($session, 'somestuff.method', 'arg1');
$result = $client->call($session, 'somestuff.method', array('arg1', 'arg2', 'arg3'));
$result = $client->multiCall($session, array(
array('somestuff.method'),
array('somestuff.method', 'arg1'),
array('somestuff.method', array('arg1', 'arg2'))
));
// If you don't need the session anymore
$client->endSession($session);
where you have www.site.com in your SOAP code, replace it with localhost or whatever the correct URL is for your server. You'll also need to replace somestuff.method with real objects and methods as per the Magento documentation