Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am new to ejabberd and I have a problem with mod_roster_odbc.
I follow the instruction here :
http://www.planeterlang.org/en/planet/article/How_to_install_ejabberd_2.0.0_with_PostgreSQL_support/
In the ejabberd.cfg, I replace mod_roster with mod_roster_odbc and provide pgsql infomation ( the infomation is correct)
I download the schema of ejabberd for pgsql in :
( I fixxed some error of the queries, some commas are missing. )
https://github.com/processone/ejabberd/tree/master/src/odbc
But the odbc roster not work.
When I create user using ejabberdctl , it say: User newuser#domain already registered at node ejabberd#localhost .
in the pgsql database, nothing changes, no data inserted .
So, my final question is : I have a database stored rosters users, rostergroups , ... How do I use the mod_roster_odbc.
Thank you very much
Update 1 :
When I try to subscribe ( add user to roster using XMPP client) , I can see the log :
=ERROR REPORT==== 2012-09-16 12:29:21 ===
E(<0.308.0>:ejabberd_odbc:405) : SQL transaction restarts exceeded
** Restarts: 10
** Last abort reason: []
** Stacktrace: [{ejabberd_odbc,sql_query_t,1},
{mod_roster_odbc,'-process_subscription/6-fun-0-',8},
{ejabberd_odbc,outer_transaction,3},
{ejabberd_odbc,run_sql_cmd,4},
{p1_fsm,handle_msg,10},
{proc_lib,init_p_do_apply,3}]
** When State == {state,<0.309.0>,pgsql,30000,"mossi",1000,{0,{[],[]}}}
I finally find out the problem due to Postgres version. I change Postgres from 9.0 to 8.4 and that works.
The problem because Postgres 9.0 doesn't handle multi lines query using "\".
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have a database where i store my photos title, tags, and their path on sever some of the records have names like:
photo 1234.png. I need to make them like photo1234.png
Why can't I use a query like
UPDATE tblPhoto a
set a.photoLink = replace(a.photoLink , ' ', '')
where a.photoLink like '% %';
And which is the best way to rename them in Linux Server, can I use php ?
You don't need where clause
UPDATE tblPhoto SET photoLink = REPLACE(photoLink , ' ', '');
For replacing the file name on your Linux Server you can try to look in this answer.
https://stackoverflow.com/a/2709619/7921383
Use php method for example:
$old_name="Hello World";
echo str_replace(" ","",$old_name);
//output Helloworld
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
First post. Please bear with me if formatting isn't one-hundred per-cent. Thanks.
I'm in the process of migrating from an older centos server to one with a more up-to-date Debian 9 operating system and I've run into several program incompatibilities... but it hasn't been all bad. I have the full LAMP stack working and "several databases and their pages" up and running just fine. Unfortunately, I've run into a snag. I'll walk through it...
In my www-accessible perl script, I don't include login details in a publically accessible location. I initiate MySQL like so...
use DBI ;
require "connect.cgi" ;
&my_connect();
In the connection file, I have like this...
sub my_connect {
$dsn = "DBI:mysql:dbmydatabase:localhost" ;
$user_name = 'uMyUser';
$user_pass = 'pMyPassword';
$dbh = DBI->connect($dsn, $user_name, $user_pass, { RaiseError => 1} ) ;
return $dbh;
}
So far, so good. I've checked the connection like so...
if(!$dbh){
die "failed to connect to MySQL database DBI->errstr()";
}else{
print("Connected to MySQL server successfully.\n");
}
... and all appears fine and dandy.
I also call for execution from the connection file, like so...
sub Do_SQL {
$sth = $dbh->prepare($SQL);
$rv = $sth->execute;
return $sth;
}
And for the task -- I want to check for the existence of a record in a database. So I set it up and run it...
$SQL = qq/ SELECT EXISTS(SELECT 1 FROM `table1` WHERE `col1` = '$col1') /;
&Do_SQL;
Trouble is, I'm getting an empty query message.
DBD::mysql::st execute failed: Query was empty at connect.cgi line 54.
I have tried a few variations on the query. For example...
$SQL = qq/ SELECT count(*) FROM `table1` WHERE `col1` = '$col1') /;
$SQL = qq/ SELECT `id` FROM `table1` WHERE `col1` = '$col1') /;
$SQL = qq/ SELECT * FROM `table1` /;
... but the result is the same.
I might be tempted to suggest there is some sort of version incompatibility between old and new set up but I have several other pages with similar configuration working fine. A difference might be that the stuff I have working was backed up and restored from previous databases. Whereas this current problem is the first new database I've created from scratch on the new server.
Interestingly, the queries I note above work on the command line. They do not work within the perl script. I've done several searches but can find nothing to point toward a solution. So here I am seeking the benefit and wisdom of more experience than my own.
Thanks for your insights.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I try to login a user account on my Page, I get the following error:
Table 'mysql.users' doesn't exist
I have checked that I have only one 'mysql' table and that is named User not Users.
Someone please guide me how to get rid of this error. Can I change the Table name to "User"?
Right now I have the following code:
query("SELECT * FROM `users` WHERE `username`='" . $mysqli-
real_escape_string($useroremail) . "' and `password`='" . md5($password) . "'
and `userlevel`='".($vendor==true ? 30 : 20)."'LIMIT 1;") or die($mysqli->error);
Can i change the Table name to "User"?
Yes you can.
Try this.
RENAME TABLE `oldTableName` TO `newTableName`
RENAME TABLE 'Users' TO `User`
Hope this helps.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am trying to get some hands on Jaggery frameworks modules and i am facing problems in managing the sessions.
For eg Lets say the user is logging in and then logging out, but even after that when he presses the back button in browser in takes back the user to inner pages.
Here I am destroying the session on clicking Logout like session.invalidate();
but then to the user can traverse back.
Does anyone know how to solve this and manage sessions.
Thanks !
To connect Jaggery to MySQL, you need to download JDBC driver jar to <jaggery>\carbon\repository\components\dropins\ directory.
In MySQL, create new database sodb by typing: mysql> create database sodb.
the example below shows how to create table, insert data in MySQL and view the data using Jaggery.
Create folder sodbmysql in /apps/
Create sodb.jag file in the sodbmysql folder then add this code in the file:
<%
var query1 = "CREATE TABLE example(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT);";
config = {};
var db = new Database("jdbc:mysql://<mysql host>:<port>/<database>", "<mysql_username>", "<mysql_password>", config);
try{db.query(query1); print('Created the table');}
catch(e){print(e.toString());}
finally{db.close();}
%>
Start Jaggery server and go to: localhost:9763/sodbmysql/sodb.jag.
Go to MySQL console> database sodb and enter this to view the table: mysql> show tables;.
To insert the data from Jaggery application, change query to insert data to table:
var query1 ="INSERT INTO example (name, age) VALUES('Jad','34');".
To print in jaggery page, use:
var query1 = "SELECT * FROM example;"
or:
var results = db.query(query3);
print(results);
** For more information, check this link.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Here's how bind_params seem to be preparing sql statements:
stmt = db.prepare( "select * from table where a=? and b=?" )
stmt.bind_params( 15, "hello" )
So in reality inside the stmt, we need to have map/array or something that will eventually map the arguments and create the right stmt. What's the most optimal way of doing this internally? Plus strings need extra precaution I imagine - the above will have to be mapped like "select * from table where a = 15 and b = \"hello\" ".
I looked into SQLite3 and OCI and they seem to be passing these to internal C code.
I am trying to prepare the queries at the client side and send it to the server
If you're trying to do what it sounds like you're trying to do... don't try to do that.
That's not what a prepared statement is (or at least that isn't what it should be).
Your client code should not be trying to interpolate values into the query string in order to generate a "finished" query to send to the server for execution. That is a recipe for disaster, not to mention a false sense of security.
Prepared statements deliver the statement with ? placeholders to the server as-is, where the server "prepares" the statement for execution... and then the client send the parameters to the server ("binding" the parameters) for execution. Doing this, the server will never be confused as to "which part is the SQL" and "which part is the data," making sql injection impossible and making escaping and sanitizing the data unnecessary.
mysql_stmt_bind_param() is used to bind input data for the parameter markers in the SQL statement that was passed to mysql_stmt_prepare(). It uses MYSQL_BIND structures to supply the data. bind is the address of an array of MYSQL_BIND structures. The client library expects the array to contain one element for each ? parameter marker that is present in the query.
— http://dev.mysql.com/doc/refman/5.6/en/mysql-stmt-bind-param.html
If you are not communicating directly with the C-API then you should be calling the methods in your library that expose those same functions to you.