mysql

Improving this longwinded and repetative sql script..

I've been learning about DRY code and my code isn't DRY... For example, I have a custom CMS and I save basically a name, content and a publish status for a few things... like an article, a user, a event. To submit a form, I submit to a file (process.php) which has a switch in it like so: switch($_POST['process']) { case 'speaker': ...

Best DB abstraction class for PHP

I'd like to start building my own framework. Everything is fine, but I can't build the most important part (from my point of view): DB controller. I've seen so many project codes and some uses ADOdb, others have built its own. I don't want compatibility, just an easy class that obviously filters SQL injections but also allows the user t...

how to store spatial files in MySQL

what is a better way to store spatial data in MySQL (say tracks) internally or as references to the external flat files? ...

What should I do with MySQL InnoDB error in MacOSX ?

My mysql installation is new and it was working a yesterday. Now, any MySQL related task in my ruby-on-rails app is failing with the error Mysql::Error: Unknown table engine 'InnoDB': SELECT version FROM schema_migrations I searched on the net for InnoDB and it seems to be a plugin. Some sources asked me to reinstall mysql with InnoDB...

INSERT..SELECT in MySQL

INSERT INTO tblprofile (fldDate,fldemployeeno,fldLName,fldFName,fldMI,fldEmployeeName, fldShiftCode,fldProjectGroup,fldTask,fldSuperior,fldPosition) SELECT now(),tblprofile.fldemployeeno,tblprofile.fldlname,tblprofile.fldfname,tblprofile.fldmi,tblprofile.fldemployeename, tblprofile.fldshiftcode,tblprofile.f...

Recursive tree CRUD PHP using a single MySQL table

i'm using a tutorial from jesse price but it isn't working for me, its only showing the root element, so I wonder could anybody give me a clue how a recursive tree's CRUD would work? It was an interview question, needless to say, i don't have the job, but still I want to know how it works.... using a single MySQL table please help! ...

the value is not inserted in db

i want to store more than 1000 character in database i use mysql database. when i insert 50-100 character the code run successfully.but when i insert 1000 character it not inserted. even it also not give error. when i use similar insert query in myphpAdmin, the query run successfully. this is query first two fields are varchar & last ...

Can't send textfield value to PHP file with jQuery

I would like to send this textfield value to a php file using jQuery. HTML code: <div> <label for="email">Email: </label> <input type="text" id="email" name="email" /> <span id="msgbox" class="msgbox"></span> </div> jQuery code: $(document).ready(function() { $("#email").blur(function() { $("#msgbox").rem...

MYSQL STORED PROCEDURE with OUTFILE with no spaces in txt file

I would like to export a query result in a txt file, but with no field separators like this: field1field2field3field4 if I use the fields terminated by and optionally enclosed by and set them to '', I still get some kind of tabs between fields... How can I get the output right? thanks in advance... ...

How to make the Order by statement for Two fields in a single query and one field needs to DESC and one field needs to ASC using Mysql?

Hello friend, I want to make a query that will give the result on order by using two columns. I made query like this. select el.*, lb.LabName,lb.LabType, lb.LabDescription from encounterlab el INNER JOIN labs lb ON lb.LabType=el.LabType where PatientAcctNo=4 ORDER BY el.DataOfService,lb.LabName DESC It ...

how to check now() falls between two specific dates?

I've a announcement table with the structure, Msgid int, title varchar(150) message text date_from datetime date_to datetime I've want to list all the announcements which will be due today (i.e) announcements of which today's date falls b/w date_from and date_to. any ideas? ...

MySQL Multiple Tables Link

Hi there I'm new to these types of MySQL Queries. Basically, I have two tables in a MySQL Database. One is called groupmembers and the other is called users groupmembers contains rows with two columns, a groupid and a userid users contains rows with also two columns, a userid and a username I am trying to write a query that searches t...

how to add ellipsis to pagination?

Hello! I need help adding an ellipsis to my pagination script. I can't find anything simple on Google. So that's why I ask on here. Thank you!!! Here is the code; if (isset($_GET['p'])) { $pageno = $_GET['p']; } else { $pageno = 1; } // if $query = mysql_query("SELECT count(id) FROM m3_musicblog"); $query_data = mysql_fetch_row($q...

Wordpress SQL attack...Unknown Javascript found on each post

My site is redirecting to some malware induced site and after looking into my SQL database, I can see this js code in every single one of posts - (Chrome throws a warning if you try and open this url) . It seems like I am not the only one http://wordpress.org/support/topic/was-my-site-just-hacked-found-random-script-in-all-pagesposts Ki...

MYSQL: Instead of using SELECT statements in a while loop - what are my options?

I have a table which contains a list of categories and and another table which contains a list of products in each category. e.g. CatID | Cat_Name ---------------- 1 | Books 2 | CDs and ProductID | Product_Name | CatID ------------------------------------ 1 |The Bible | 1 2 |The Koran | 1 ...

MySql:: if field is primary key + auto increment should he also defined as unsigned or mysql doing that by default?

Hi, MySql:: if field is primary key + auto increment should he also defined as unsigned or mysql doing that by default? Edit: I asking because integer unsigned save 2* space vs integer. I asking about INNODB. Thanks ...

Problem using MySQLdb on OSX: symbol not found _mysql_affected_rows

This is related to a previous question. However, the main posted solution there is not working for me. I'm on Snow Leopard, using the 32-bit 5.1.49 MySQL dmg install. I'm using the built in python (apparently, as noted in the comments, my Python version is different), which appears to be 2.6.5 32-bit: Python 2.6.5 (r265:79359, Mar 24 ...

Cyrillic , AJAX and database

Database - MySQL. I save form data in the database with native AJAX. In file 1 (where is the form and AJAX) I have <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> and mysql_query("SET CHARACTER SET utf8"); In file 2 (database submission) I have mysql_query("SET CHARACTER SET utf8"); iconv_set_encoding("inter...

I want to create a login page using servlets.

I want to create a login page using Servlet & JSP. I ve created a page which gets Username & password. I made a database with a table which contains Username & password. <form action="LoginPage" method="POST"> User name: <input type="text" name="userName" size="20"><br> Password: <input type="password" name="password" size="20...

Mapping Map<String,Foo> in Hibernate

Hi all, I'm trying to map my Hashmap in Hibernate. All examples I can find are simply like this: class FooBar{ Map<String,String> myStrings; } Which would simply map to <map role="ages"> <key column="id"/> <index column="name" type="string"/> <element column="age" type="string"/> </map> However, I use a more object-oriented ...