mysql

ext/mysql charset support vs ext/mysqli charset

Hi, I read some articles that promoted the use of the new ext/mysqli in php due to it's support of character sets. I currently use ext/mysql and use SET NAMES UTF-8 to ensure all my data is stored as utf-8. isn't that charset support in ext/mysql or am I missing something larger? Thanks :) ...

What are the differences between backtick and single quote? Can I use IF statement in a query as above?

In the codeigniter manual writes the following. $this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement. $this->db->select('(SELECT SUM(payments.amount) FROM paym...

How do I save the values of checkboxes in a form into a single MySQL field?

I have a form where i have many music genres. An artist can be singing under many genres. I have put the genres in checkboxes. Now i need to store the values of the checkboxes in to a single field. Can some one help me out with some code snippet as i am new to php programming? ...

Count top 10 inputs in a table

I have a function on my site where people can vote on photos. Everytime someone click the vote-button my script adds a row in a table (mysql). Each row looks like this: (Table name = likes) id --------- userId --------- photoName --------- date 1 ----------- 21 -------------- 34234 ----------- 20100101 How do i find the top 10 photo...

inner join on null value

I'm not sure if i made a mistake in logic. If i have a query and i do an inner join with a null value would i always get no results or will it ignore the join and succeed? example user { id PK, name NVARCHAR NOT NULL, banStatus nullable reference } if i write and u.banStatus i will receive no rows? select * from user as u join banst...

how to add multiple records in mysql using php

how to add multiple records in mysql using php. Is using array the only solution to this problem. Because I tried using array but the record that would be added in the database would look like this: array ...

mysql: find rows which have a field that is a substring of "string"

is there a way to write an sql query that finds all rows where the field value is a substring of a given string. Example: table names Name | Nickname rohit iamrohitbanga banga rohitnick sinan unur query should be something like select * from names where Name is a substring of "who is rohit...

creating multiple tables with single sql command

I searched for this here and on google and surprisingly couldn't find an answer. I tried to create syntax to submit to mysql that would create multiple tables with the same columns, but it returned an error. Can you point out what is wrong with my syntax, or if this is even possible? CREATE TABLE news, life ( id int PRIMARY KEY AUTO_...

MySQL querying products from one table only if they appear in certain category table

I've got the following tables: Products: id, name, ... Products_in_Categories id, category_id, product_id Categories id, name, ... I have an admin page where I want to let him search products by name, catalog id etc. And of course by category and name and catalog id ... So without the category - it's really easy. But when I w...

How to apply normalization on mysql using php

Please I don't have any idea. Although I've made some readings on the topic. All I know is it is used to make the data in the database more efficient and easy to handle. And It can also be used to save disk space. And lastly, if you used normalization. You will have to generate more tables. Now I have a lot of questions to ask. First,...

Does naming your form fields the same as mysql actually pose any security risk?

Is there any reason why you should or shouldn't name your form fields exactly the same as the HTML fields? <input type="text" name="my_field_1" id="my_field_1" /> --> mysql row my_field_1 or <input type="text" name="myField1" id="myField1" /> --> mysql row my_field_1 The only thing I can think of are probably naming conventions for...

login form in php

how to make a login form in php. I just need to validate a user stored in the database. Please, I don't have any idea on how to make it. ...

simple encryption technique for mysql using php

How to encrypt user password in php. please explain in a way a beginner can understand. I already have this sample code: $password="john856"; $encrypt_password=md5($password); echo $encrypt_password; Can you help me incorporate it in my current code, which does not do any encryption. <?php $con = mysql_connect("localhost","root...

How can I see how long statements take to execute on the mysql command line?

When I execute statements on the mysql command line, there must be some way to always display how long the command took to execute? ...

PhP/MySQL Storing User Searches between Pages so the User Can Go Back to Them

I'm writing a php-mysql application. The application allows the user to run a search against the database. When the search is run, if the user clicks on the back button to go back to it after examining an item brought up by it, they are asked if they would like to resend the query (it uses post). Which would rerun the search in the da...

Why is a "GRANT USAGE" created the first time I grant a user privileges?

I'm new to the admin side of DBMS and was setting up a new database tonight (using MySQL) when I noticed this. After granting a user a privilege for the first time, another grant is created that looks like GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password The documentation says that the "USAGE" privilege means "no privileges,...

What's wrong with this query?

Someone help me: $query = "INSERT INTO tbl_users(user, password, password_def, userid, level , regdate, lastdate, email) VALUES('$username', sha1('$password') , sha1('$password'), '$userid', '0', NOW(), NOW(), '$email');"; $userid is a ramdon md5 id. It gives me this error: posttokenError: Account not created ...

Converting mysqlpp::String to C++ int

Ok, I'm relatively new to using the mysqlpp library that is used in Visual Studio to connect to a MySQL database and am having trouble trying to convert a vector of type mysqlpp::String to a vector of type int. Does anyone have any experience with mysqlpp and would mind helping me out a little? I've posted an example of what I'm basicall...

Combine Multiple Query Results in MySQL (by column)

I have 4 different queries and each of them return individual unique set of Results. I need to combine the Query Results with using a single query. my sample queries are: 1. select cls.* from (calls as cls inner join calls_users as clsusr on cls.id=clsusr.call_id) inner join users as usr on usr.id=cls.assigned_user_id where cls.assigne...

implode warning

Hello all, I am moving to another server and now I am getting an implode warning "Invalid arguments passed", the script was working on the old server, does someone know what I am doing wrong??? My code is: $query ="SELECT keywords,keywords1,keywords2,keywords3 FROM Table "; $result = mysql_query($query); while ($row = mysql_fetch_a...