mysql

How can I allow NULL values in MySQL

I was wondering how can I allow NULL values in the following code below along with keeping WHERE username = '$username'. here is the mysql code. "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'" I'm trying to check for usernames with the same username but I want all users to have a NULL value if they...

Error in SQL Syntax ERROR1064

Hi, Everytime I try to create the following table in MySQL command line: CREATE TABLE book( `book_id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `isbn` char(20), `title` char(20), `author_f_name` char(20), `author_l_name` char(20), `condition` ENUM("as new","very good","good","fair","poor"), `price` decimal(8,2), ...

PHP & MySQL form question.

How do I allow all users to have their username field empty without having them need to enter a username when they submit the form using PHP and MySQL? Here is part my PHP and MySQL code. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); if(isset($_POST['username'])) { ...

mysql_connect()

I am trying to connect to mysql and am getting an error. I put my servers ip address in and used port 3306 whihch post should be used? <?php $connection = mysql_connect("serer.ip:port", "user", "pass") or die(mysql_error()); if ($connection) {$msg = "success";} ?> <html> <head> </head> <body> <? echo "$msg"; ?> </body> </html> ...

MySQL to AppEngine

Hi Nick! How are you? I'm from Brazil and study at FATEC (college located in Brazil). I'm trying to learn about AppEngine. Now, I'm trying to load a large database from MySQL to AppEngine to perform some queries, but I don't know how i can do it. I did some testing with CSV files,but is there any way to perform the direct import from My...

mysql concat all field table

Is there a way we can concat all field in the table(1 sql statement)(automatic) ? The reason was before user updated or delete a record,the record will push to another table for future reference. ...

Sql query to get this result..

Consider i have a user table and I have three columns mobilePhone,homePhone and workPhone... I have to select homePhone for every user as first pref if there is no value    I'll go for mobilePhone and    if there is no value for it       I ll go for workPhone.... Any suggestion how it can be done in mysql.. ...

MySQL ERROR plz solve

Error MySQL said: 2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) i am getting this erro plz let me know how to solve this with regards Jungle_Hacker ...

How to get this done in mysql?

Consider i have a registartion table and there is field prefLocationId and it contains value like this 1,2,3,2,1,4 and so many.... And i have a table prefLocation which looks like this Id LocationName 1 Chennai 2 Mumbai 3 Kolkatta 4 Delhi and i want to select record of users and show values like Chennai,Mumbai,Kolkatta,Mumbai,Che...

dynamic insert php mysql and performance

I have a folder/array of images, it may be 1, maximum of 12. What I need to do is dynamically add them so the images are added to an images table. At the moment I have $directory = "portfolio_images/$id/Thumbs/"; $images = glob("" . $directory . "*.jpg"); for ( $i= 0; $i <= count($images); $i += 1) { mysql_query("INSERT INTO pr...

wanted to get all dates in mysql result

I have mysql table called user(id, name, join_on) join on is a date field what I want is to show in each day how many uses has been created I can use group by but it will only give me the dates when users get added like if date 4/12/10 5 users added 4/13/10 2 users added 4/15/10 7 users added here date 4/14/10 is missing and I wa...

current_date casting

Hi. string selectSql = "update " + table + " set state_" + mode + "_id=1 WHERE stoping_" + mode + " < current_date;"; when i call current_date, it return yyyy-MM-dd format, but i want to return dd.MM.yyyy format, how can i do that. please help. my program works fine when i am trying string selectSql = "update " + table + " set state...

piece of php code for prevent hacking.

Hi friends, I have a php file at my site, and I connect to db, get some records and list them in same file. mysql_connect("localhost", "blabla", "blabla") or die(mysql_error()); mysql_select_db("blabla") or die(mysql_error()); $blabla1 = mysql_query("SELECT * FROM gallery WHERE id_cat=1"); $blabla2 = mysql_query("SELECT * FROM gallery...

getting only certain data from table

Hello, I have a field that is in this format 5551112391^HUMAN^HUMAN-800-800^6-main^^ The "5551112391" before the ^ is the number. How would I grab only that and not any of that other data? Would you do this with regex? Let me know! Thanks. ...

Do all databases use the USE statement to switch databases?

MySQL uses the USE database_name to change the active database. Does that work on all databases? EDIT: By databases I mean DBMS. Thanks for bringing it to my attention. ...

Find and replace braced tags within a MySQL table

I have about 40000 records in that table that contains plain text and within the plain text, contains that kind of tags which its only characteristic is that they are braced between [ ] [caption id="attachment_2948" align="alignnone" width="480" caption="the caption goes here"] How could I remove those? (replace by nothing) I could ...

MySQL Connection Error in PHP

I have set the password for root and grant all privileges for root. Why does it say it is denied? ****mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\photo_gallery\includes\database.php on line 56 Warning: mysql_query() [function.mysql-query]: A link to the server ...

Drupal db_query error need help

Hi drupal pals, im using drupal 6.15 and doing my first project in drupal . i got an issue while running the below query with db_query i have drupal,delhi keywords in column 'tag' with table name tagging. db_query(SELECT * FROM {tagging} WHERE tag LIKE '%drup%') wont retrieve the correct output. it show null but the query modified li...

Is mysql_query under PHP a blocking function?

Suppose I am executing several queries on the server using mysql_query. The results of every query affect the subsequent query. Will every call of mysql_query be completely executed before control moves on to the next one? Edit: I forgot to mention, I am not using a transactional storage engine. ...

I need to calculate the date / time difference between one date time column

Details. I have the notes table having the following columns. ID - INT(3) Date - DateTime Note - VARCHAR(100) Tile - Varchar(100) UserName - Varchar(100) Now this table will be having NOTES along with the Titles entered by UserName on the specified date / time. I need to calculate the DateTimeDifference between t...