I'm trying to set a simple cron script to do some database updating, and I'm pretty worthless with MySQL without ActiveRecord (I use CodeIgniter). I keep getting the error message,
mysql_fetch_object(): supplied argument is not a valid MySQL result resource
with the following code:
mysql_connect("localhost", "user", "pass") or die(...
How do you most easily calculate how many e.g. Mondays are left in a month using MySQL (counting today)?
Bonus points for a solution that solves it for all days of the week in one query.
Desired output (run on Tuesday August 17th 2010):
dayOfWeek left
1 2 -- Sunday
2 2 -- Monday
3 3 -- Tu...
I get the following error session.save(student);
org.hibernate.HibernateException: The database returned no natively generated identity value
Here is main function
{
BasicConfigurator.configure();
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
try {
transaction = session...
1.I have a script, that executes some update/delete operations
2.All sql operations are executed inside transaction(InnoDb tables)
3.From time to time I get "Deadlock found when trying to get lock; try restarting transaction"
There are some other jobs in this application, that perform database operations. My problem is to find which ...
Hi,
New to PHP, would love to get to know it better. Currently working on a project around RSS + SMS gateway for users to get alerts on certain events around them.
I have a MySQL table with auto_increment ID's, assigned systematically. I'd like to create a PHP page that allows the user to go to http://mysite.com/page.php?id=Mysql_ID -...
Hi,
I'm doing some refactoring work on PHP/MySQL code and stumbled across an interesting problem, and as of right now, I can't find a proper solution for it.
I have this table:
CREATE TABLE example
(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
userID INT UNSIGNED NOT NULL,
timestamp INT UNSIGNED NOT N...
Hi all,
can somebody help me to write a sql select to perform a task.
So the problem is that we have a table and there are some duplicates, so i need to find where name, street and house are the same and to group somehow them.
I have almost this situation but the difference is that i would like to group them to find what is duplicate o...
How does one create a PHP script that checks the MySQL row consistently and if a set query is matched, it starts an event, such as sending an email?
For example, on query match Fire start email:
To: [email protected]
From: [email protected]
Subject: Set query met, auto email complete.
It would be around MySQL5. I'm stuck on this. Am I best to ...
//lets get the auto name set
$accepted = 0;
$sql = mysql_query("SELECT * FROM ".TBL_FACTIONS." WHERE f_name='no_name'");
$numrows = mysql_num_rows($sql);
//default name 1
if($numrows == 0){ $auto_name = 'no_name'; $accepted = 1;}
//default name 2
if ($accepted == 0){ $sql = mysql_query("SELECT * FROM ".TBL_FACTIONS."
WHERE f_name='no_na...
Hi,
I need to intersect two tables based
on a column,in both tables.
Here's my code snippet :
SELECT b.VisitID, b.CarrierName, b.PhoneNum, b.PatientName, b.SubscriberID, b.SubscriberName,
b.ChartNum, b.DoB, b.SubscriberEmp, b.ServiceDate, b.ProviderName, b.CPTCode, b.AgingDate,
b.BalanceAmt, f.FollowUpNote, f...
I am creating such application where user can post there articles upto 800-1000 words .
What should I use to maintain text formating like paragraph, next line etc.(if i use textarea as input textbox for article?). I am using mySql so what shod my datatype to store article text VARCHAR or TEXT?? and what shoud be the size for 1000 words? ...
Hi..
I am new to Ruby on Rails. I have read many article regarding easy installing steps. I installed ruby on windows. After starting the server i got welcome message too. After that if i add a controller I got this message on browser.
And also when tried to do a rake db:migrate i get the error saying mysql gem is missing.
I have inst...
Hi all,
I need to get 1-2 rows from query result retrived with SQL select on indexed columns without getting the whole record set.
For example I will retrieve 10 000 records using query
SELECT * FROM table WHERE field 1>1 AND field1 < 10
but I need only 1 random row from this query regarding to highload of my database.
I can use
...
I need to select from a table all rows that have date_added between CURDATE() and 6 weeks ago.
Help please.
...
I have a table STUDENT with a column NAMES.that column contains 10 rows ,
in SQL when i write
SELECT @variable= NAMES FROM STUDENT ;
it wiil display all 10 rows data in a single row ;
How to achive this in MySql?
please help me
...
I'm using MySQL and a web-service connect to the database to read some values.
The web-service and the database are on the same server.
I want to deny access to the database through the public static IP of the server and the port of MySQL.
That means only allow access to the database through localhost, so that only the web-service can ...
Hi, i am using a MYSQL database as form of IPC datastore between web client and C code process on Debian linux. When web client writes some data to the mysql database via php script, i need my C code app to go and pickup that data.
However i don't want the C app continually polling some flag to check if data is available. Is there anywa...
Looking for a best-practice advice:
Let's suppose I have a Account object with limit attribute. Each day there can be n Payments, with sum of their amounts up to the account limit. When creating a new payment, it checks to see if it's amount + amounts of other payments of the day are still within the account limit, and either saves the ...
final class MySQL {
private $connection;
public function __construct($hostname, $username, $password, $database) {
if (!$this->connection = mysql_connect($hostname, $username, $password)) {
exit('Error: Could not make a database connection using ' . $username . '@' . $hostname);
}
if (!mysql_select_db($database, $...
I'm trying to figure out how to get the top users in each category with a mysql query:
My Users Table looks like this:
user_id,category_id ... and some other stuff
My Votes Table looks like this (each row is one positive vote):
reciever_id ... and some other stuff
I was thinking that I need to first determine the unique votes by user_...