mysql

Handle quotes and commands in SQL string

In my MySQL table, I have a column of TEXT type. On my HTML Form, user pastes text into it that might contain "" , ' ( ) and so on. I want to know how to safely execute Insert Query if these characters exist in the text and might crash the query execution. How to handle them properly in PHP? ...

mysql with EF 4.0

Hello everyone, Do you know a way for using mysql in vs2010 with ef4? Thanks in advance. ...

PHP - Assigning values in a while loop and Accessing them individually outside the loop

Hi all, PLATFORM: PHP, mySQL WHAT I HAVE: I have a Database table. Within my application, I am able to fetch all the rows. When I am querying the database, I have set the records fetch limit dynamically. WHAT I AM TRYING TO DO: I am trying to pull out all the rows of data until the record fetch limit is reached, in a loop. I want...

MySQL- Why is LAST_INSERT_ID() not working for me?

I have the following code: public function createNewGuide($userID,$guideName) { $sql =" INSERT INTO myTable(name, updated) VALUES ('$guideName', 'NOW()')"; //Process query $this->query($sql); // This inserts the new row $this->query('LAST_INSERT_ID()'); // This throws an error return $this->query_r...

PHP-MySQL-How to safely increment MySQL integer field?

I wan to increment a field value safely using php and mysql. what type of table/field must I use? is there a minimum version of MySQL I must use? what's the sql code for this, safe transaction for MySQL? ...

jQuery ajax output as return of a function

I created a small php script that returns a mysql result depending on given post/get parameters. With this file I can now use the jquery.post or .get command to retrieve something from my database. The script always returns 1 value. So I tried to make a javascript function that returns the retrieved value from the database. This is wha...

How do I insert data into a mysql database using a procedure?

I have a single procedure that has two insert statements in it for two different tables. I must insert data into table1 before I can insert into table2. I'm using PHP to do the data collection. What I'd like to know is how to insert multiple rows into table2, which can have many rows associated with table1. How would I do this? I want t...

How to check Table depended view's procedure

Hi , i have table student,fields are student_id, student_name, year_joining ... now i want to rename the year_joining to year_completion , but i am not sure, How many view,procedure functions depend this year_joinging , In mysql, is there any function do that... ...

MySQL table design: Primary Foreign Multi-Column Key possible?

I am currently thinking about the database design of a 'friends' table (many-to-many, stores the friendships between users). Columns: user_id friend_id Does it make sense to prefer a multi-column primary key instead of an additional 'friendship_id' column? If so, can I add Foreign Keys for both columns? ...

How to store multiple items in database. Confused with database structure

I had a select box where the user will select the list of cities they travelled. After that the admin will search for the users with particular cities. I am very confused with the structure of the database. There are totally 300 cities. Creating column for each city and store it with boolean on or off, looks a childish technique. Any o...

cakephp adding record with some parameters fixed

I'm sure this sort of problem must be common in cakephp (which I've recently started using), but I haven't managed to find a clear answer. In my database I have, among others, tables called customers and contacts, in a one-to-many relationship (Customer hasMany Contact; Contact belongsTo Customer). When I add a record to the contacts ta...

MySQL database orginization and PHP select

I am setting up a MySQL database and will be querying it with PHP. Is is better to break the information up into multiple tables and do select queries on each of the tables; or is it better to put all the items in one table and do a single select query? For example: It will hold information on upto 7 cars; which would mean that their ...

How to Call Java Code from MySQL?

I found an article from 2008 discussing how to call Java code from MySQL. There were a lot of caveats and disclaimers because the process involved working with an experimental branch of MySQL. For a project I have in mind, it would be very useful to be be able to access Java libraries within MySQL, analogous to Oracle's Java Stored Proc...

Zend PHP Class Variable retention for mysql queries

I have a flash application which uses a single php file to retrieve records from a database (using the Zend framework). When the application first begins, I make a call to the php to set a class variable, so that all future requests to the database will use this variable to select records based on its value. So here is how the class begi...

Faking SQL Server

I have application that requires SQL Server 2000 as database storage. I do not really want to use SQL Server 2000, but I can user MySQL Server instead. Application uses ODBC to connect to SQL Server Database. I would like to know if it is possible to make fake SQL Server which will send and receive data to/from MySQL Server applicatio...

implementing a simple prepared query in PHP

I'm trying to create a very simple database abstraction, one part of it using prepared queries. Now, I have a function take a query string and an array of values like this: $query = "SELECT `first_name`, `last_name` FROM ::table_name WHERE `id` = :id" $values = array( 'table_name' = $this->table_name, 'id' = $user_id, ); this...

Mysql query returns only the first letter of strings

Can someone please tell me what I am missing. the following sql query returns only the first letter of strings it fetched from the my database: $result = mysql_query("SELECT * FROM users) or die("error in the query"); thanks. Update $result = mysql_query("SELECT * FROM properties ...

How to combine data from 2 tables under circumstances?

I have 2 tables. One table contains posts and the other contains votes for the posts. Each member can vote (+ or -) for each post. (Structure example:) Posts table: pid, belongs, userp, text. Votes table: vid, userv, postid, vote. Also one table which contains the info for the users. What I want is: Supposing I am a logged-in membe...

Using PHP to group and display MySQL entries by week

Hi - I'm building a site with several 'one-liners'. These are added using a simple PHP5 form, stored in a MySQL 5 database. Each row has an 'id' (auto_increment), 'title', 'description', 'status' (1 or 0) and 'date_added' (MySQL datetime). I want to display them grouped by Month and Year, like so: <dl> <dt>August 2009</dt> <dd>...

(Fluent) NHibernate composite-id problem : MySQL complains that the parameter index is out of bounds

I'm using Fluent NHibernate to create an ASP.NET MVC project, with Submissions and Votes (Up/Down) by Users. Of course, Users can vote submission Up or Down. To record this, I created a middle table, SubmissionVote, which contain the following fields: submissionId (int) userId (int) score (enum: up/down) Here are my mappings: Submis...