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)
Related
I have a psycopg2 connection which I am using to connect to postgresql from pyspark. Here is my code -
host = 'IP Address'
port = 'Port'
user = 'postgres'
db = 'postgres'
password = 'password'
def move_records(main_table,stg_table):
try:
connection = psycopg2.connect(host=host,
database=db,
user=user,
password=password,
#driver = driver,
port = port)
cursor = connection.cursor()
move_query = "INSERT INTO " +main_table+ " select * from "+stg_table+" where country ='USA'"
cursor.execute(move_query)
connection.commit()
logger.debug("Record moved successfully")
except (Exception, psycopg2.DatabaseError) as error :
logger.error("%s Error in transction Reverting all other operations of a transaction ", error)
global flag
flag = False
connection.rollback()
finally:
if(connection):
cursor.close()
connection.close()
logger.debug("PostgreSQL connection is closed")
move_records(table_1,table_2)
But I keep getting error below error on line if(connection):
"UnboundLocalError","evalue":"local variable 'connection' referenced before assignment"
Can not figure out what is the issue. Need help.
I am no expert in Python but I have worked on similar thing, connecting from Python to Postgres in in AWS Lambda using psycopg2.
I believe the error lies somewhere in scope of variable. You need to declare all variables(host, port, user, db, password) inside function once again as global or nonlocal and then try to run function.
For your reference, check out this link:-
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.
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.
I have downloaded the IPP PHP SDK and am wondering how to make the REST calls for reporting. I am trying to make any REST call and it doesn't seem to work..
I have used the AccountFindAll.php as an example for calling the REST API. I either get nothing back, which makes me think if I am even calling it right, or there is no data returned. I have received an error though for the AgedPayables report saying permission denied. The AccountsFindAll.php example does work and brings me back what I want but it is using some kind of query format.
I would like to use the REST API but I can't get it to work. If anyone can point me in the right direction it would be so appreciated.
Here is my code:
<?php
require_once('config.php');
require_once(PATH_SDK_ROOT . 'Core/ServiceContext.php');
require_once(PATH_SDK_ROOT . 'DataService/DataService.php');
require_once(PATH_SDK_ROOT . 'PlatformService/PlatformService.php');
require_once(PATH_SDK_ROOT . 'Utility/Configuration/ConfigurationManager.php');
//Specify QBO or QBD
$serviceType = IntuitServicesType::QBO;
// Get App Config
$realmId = ConfigurationManager::AppSettings('RealmID');
if (!$realmId)
exit("Please add realm to App.Config before running this sample.\n");
/*
$accessToken = $_REQUEST['accessToken'];
$tokenSecret = $_REQUEST['tokenSecret'];
$realmId = $_REQUEST['realmId'];
*/
$realmId = ConfigurationManager::AppSettings('RealmID');
// Prep Service Context
$requestValidator = new OAuthRequestValidator(ConfigurationManager::AppSettings('AccessToken'),
ConfigurationManager::AppSettings('AccessTokenSecret'),
ConfigurationManager::AppSettings('ConsumerKey'),
ConfigurationManager::AppSettings('ConsumerSecret'));
$serviceContext = new ServiceContext($realmId, $serviceType, $requestValidator);
if (!$serviceContext)
exit("Problem while initializing ServiceContext.\n");
//$httpsUri = "company/".$realmId."/reports/AgedPayables"; //?date_macro=Today
$httpsUri = 'company/'.$realmId.'/companyinfo/'.$realmId;
//$httpsUri = 'company/'.$realmId.'/query';
//$httpsPostBody = 'select * from CompanyInfo startPosition 0 maxResults 500';
$httpsPostBody = NULL;
$httpsContentType = CoreConstants::CONTENTTYPE_APPLICATIONTEXT;
$requestParameters = new RequestParameters($httpsUri, 'GET', $httpsContentType, NULL);
$restRequestHandler = new SyncRestHandler($serviceContext);
list($responseCode, $responseBody) = $restRequestHandler->GetResponse($requestParameters, $httpsPostBody, NULL);
$parsedResponseBody = NULL;
try {
$responseXmlObj = simplexml_load_string($responseBody);
if ($responseXmlObj && $responseXmlObj->QueryResponse)
{
$responseSerializer = CoreHelper::GetSerializer($serviceContext, false);
$parsedResponseBody = $responseSerializer->Deserialize($responseXmlObj->QueryResponse->asXML(), FALSE);
}
}
catch (Exception $e) {
echo $e->getMessage();
IdsExceptionManager::HandleException($e);
}
print_r($parsedResponseBody);
?>
I get an XML response to report queries.
Please refer:
https://developer.intuit.com/blog/2014/03/25/the-quickbooks-online-reports-api-has-arrived
PHP SDK does not support Reports at this time.
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