Search Results

Search found 36111 results on 1445 pages for 'mysql update'.

Page 93/1445 | < Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >

  • Read tab delimited text file into MySQL table with PHP

    - by Simon S
    I am trying to read in a series of tab delimited text files into existing MySQL tables. The code I have is quite simple: $lines = file("import/file_to_import.txt"); foreach ($lines as $line_num => $line) { if($line_num > 1) { $arr = explode("\t", $line); $sql = sprintf("INSERT INTO my_table VALUES('%s', '%s', '%s', %s, %s);", trim((string)$arr[0]), trim((string)$arr[1]), trim((string)$arr[2]), trim((string)$arr[3]), trim((string)$arr[4])); mysql_query($sql, $database) or die(mysql_error()); } } But no matter what I do (hence the casting before each variable in the sprintf statement) I get the "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1" error. I echo out the code, paste it into a MySQL editor and it runs fine, it just won't execute from the PHP script. What am I doing wrong?? Si

    Read the article

  • How can I enable MySQL's slow query log without restarting MySQL?

    - by mmattax
    I followed the instructions here: http://crazytoon.com/2007/07/23/mysql-changing-runtime-variables-with-out-restarting-mysql-server/ but that seems to only set the threshold. Do I need to do anything else like set the filepath? According to MySQL's docs If no file_name value is given for --log-slow-queries, the default name is host_name-slow.log. The server creates the file in the data directory unless an absolute path name is given to specify a different directory. Running SHOW VARIABLES doesn't indicate any log file path and I don't see any slow query log file on my server...

    Read the article

  • Basic Login Script using php and mysql inquiry

    - by Matt
    Attempting to write a check for a login script to see if the username is available. Would the best way to write this query be to check if isset(!_POST[]) for both values (nick and pass) then connect to database WHERE the mysql database for the usernick requested return the user id if the usernick exists evaluate if isset($id) to see if the user name is taken and use that to continue to creating an entry Does this logically sound like a method to check for login without using excessive code sorry for not posting the code, it is on another computer and this computer is locked down by my administrator at work... Also, is there another way to evaluate if a value exists in the database? For instance, instead of setting $id to the return value of the mysql database can i just ping the mysql database for the information and have it return a Boolean result so I am not putting out any user information. Thanks, Matt

    Read the article

  • Deleting rows with MySQL LEFT JOIN

    - by fabrik
    Hello! I have two tables, one for job deadlines, one for describe a job. Each job can take a status and some statuses means the jobs' deadlines must be deleted from the other table. I can easily SELECT the jobs/deadlines that meets my criteria with a LEFT JOIN: SELECT * FROM `deadline` LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szamlazva' OR `status` = 'szamlazhato' OR `status` = 'fizetve' OR `status` = 'szallitva' OR `status` = 'storno' (status belongs to job table not deadline) But when i'd like to delete these rows from deadline, MySQL throws an error. My query is: DELETE FROM `deadline` LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szamlazva' OR `status` = 'szamlazhato' OR `status` = 'fizetve' OR `status` = 'szallitva' OR `status` = 'storno' MySQL error says nothing: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN `job` ON deadline.job_id = job.job_id WHERE `status` = 'szaml' at line 1 How can i turn my SELECT into a working DELETE query? Thanks, fabrik

    Read the article

  • utf8 and unicode getting warning messages in mysql

    - by BufordTaylor
    I have a mysql table. When I try to insert, I get this: Warning: Incorrect string value: '\xAE</...' for column 'value' at row 1 mysql> show create table Configurations; | Configurations | CREATE TABLE `Configurations` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) NOT NULL, `ckey` varchar(255) NOT NULL, `value` mediumtext, PRIMARY KEY (`id`), KEY `ckey` (`ckey`), ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8 | mysql> SHOW VARIABLES LIKE 'coll%'; +----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+ I googled the hell out of the error, and it all seemed to boil down to utf8 being set as my default character set. I've been like that for a while. I'm not sure what else to do. Help?

    Read the article

  • MySQL or SQL Server

    - by user203708
    I'm creating an application that I want to run on either MySQL or SQL Server (not both at the same time) I've created two PHP classes DatabaseMySQL and DatabaseSQLSVR and I'd like my application to know which database class to use based on a constant set up at install. define(DB_TYPE, "mysql"); // or "sqlsrv" I'm trying to think of the best way to handle this. My thought is to do an "if else" wherever I instantiate the database: $db = (DB_TYPE == "mysql") ? new DatabaseMySQL : new DatabaseSQLSVR; I know there has to be a better way of doing this though. Suppose I want to add a third database type later; I'll have to go and redo all my code. Yuk!! Any help would be much appreciated. Thank

    Read the article

  • Problems using MySQL instead of MySQLi

    - by vaibhav
    I have a blog, which is on Drupal v6.14. Recently I changed my web hosting provider. My new hosting provider does'nt support MySQLi. So I have to use MySQL instead of MySQLi. All things worked fine for some days. But on a very fine morning, I found my blog is down and the error message was Mysql: Too Many Connections to the server. And this problem occurs several times a day now. I contacted my web hosting provider, they said, its a problem in your database. I don't trust this. My blog was working fine at old web server. Can it be a problem because of I moved to MySQL from MYSQLi.

    Read the article

  • Creating a MySQL trigger to verify data on another table

    - by Danny Herran
    I am trying to set up a MySQL trigger that does the following: When someone inserts data into databaseA.bills, it verifies if databaseB.bills already has that row, if it doesn't, then it does an additional insert into databaseB.bills. Here is what I have: CREATE TRIGGER ins_bills AFTER INSERT ON databaseA.bills FOR EACH ROW BEGIN IF NOT EXISTS (SELECT 1 FROM databaseB.bills WHERE billNumber=NEW.billNumber) THEN INSERT INTO databaseB.bills (billNumber) VALUES (NEW.billNumber) END IF END;// DELIMITER ; The problem is, I can't create it through mysql console or phpMyAdmin. It returns syntax errors near END IF END, and I am sure it's a delimiter problem. #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF END' at line 6 What am I doing wrong?

    Read the article

  • php mysql flex unicode

    - by JonoB
    I have a problem with saving the £ symbol to a mysql database. I am running a flex front end, with a php + mysql backend When I save a record from flex, the string gets sent to the server as "This amount is £10" php views the string as above, and when it gets saved into the DB, it gets saved as "This amount is £10". My understanding is that this is correct based on MySQL or PHP is appending a  whenever the £ is used I now retrieve the above record, and it gets sent to flex as "This amount is £10". Flex correctly displays this in a textarea as "This amount is £10" I change another field in the same record in flex, and re-save the transaction. The string now gets sent to the server as "This amount is £10" The record is now saved into the DB as "The amount is £10". Each time the record is re-saved, this effect snowballs. Thanks for any advice you can give.

    Read the article

  • MySQL Locking Up

    - by Ian
    I've got a innodb table that gets a lot of reads and almost no writes (like, 1 write for every 400,000 reads approx). I'm running into a pretty big problem though when I do INSERT into the table. MySQL completely locks up. It uses 100% cpu, and every single other table (in other databases even) have their statuses set to "Locked" until the INSERT is done. This is a big problem because MySQL stays locked up for up to 4 minutes. I'm using version 5.1.47 (rpm from mysql.com). Any ideas?

    Read the article

  • The use of GROUP BY in MySQL

    - by Gustav Bertram
    I'm fishing for a comprehensive and canonical answer for the typical "mysql group by?" question. Here is some sample data: TABLE A +------+------+----------+-----+ | id | foo | bar | baz | +------+------+----------+-----+ | 1 | 1 | hello | 42 | | 2 | 0 | apple | 96 | | 3 | 20 | boot | 11 | | 4 | 31 | unicorn | 99 | | 5 | 19 | pumpkin | 11 | | 6 | 88 | orange | 13 | +------+------+----------+-----+ TABLE B +------+------+ | id | moo | +------+------+ | 1 | 1 | | 2 | 99 | | 3 | 11 | +------+------+ Demonstrate and explain the correct use of the GROUP BY clause in MySQL. Touch upon the following points: The use of MIN, MAX, SUM, AVG The use of HAVING Grouping by date, and ranges of dates Grouping with an ORDER BY Grouping with a JOIN Grouping on multiple columns Bonus points for references to other great answers, the MySQL online manual, and online tutorials on GROUP BY.

    Read the article

  • MySQL encoding problem

    - by heffaklump
    I use Java and JDBC to save japanese characters and it works perfectly on my local MySQL. But when I tried doing the same thing on my web hotels MySQL i get ????? instead of japanese characters. I have made the exact same tables and use exact same code. The only difference I have found is SHOW VARIABLES LIKE 'CHAR%' character_set_client utf8 character_set_connection utf8 character_set_database latin1 character_set_filesystem binary character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir /s/usr-local/share/mysql/charsets/ character_set_datbase is set to latin1. But I can't change it! Any tips?

    Read the article

  • Sphinx + tokyo Tyrant + mysql

    - by stunti
    I'm looking at creating a full text search engine for one of my projects. We have a Mysql, Tokyo Tyrant and file documents that need to be indexed. I'm looking at Sphinx right now but I can't figured out if I can use it to index every document. I know it's possible to let Sphinx to use Mysql but I'm looking at a way to let Sphinx index and query Tokyo Tyrant as well as index file documents. It could be Sphinx or Xapian or another one but no JAVA (Lucene is out) but something that can be used with PHP and run on Linux. Any idea of a search engine that can accept more that Mysql as the source? Thanks

    Read the article

  • php/mysql show data from chosen checkboxes

    - by Michael
    Hi. I have a table called FRUIT id type daysold 1 banana 5 2 apple 6 3 apple 4 4 peach 2 5 banana 6 What I would like is to have 3 checkboxes: Banana [ ] Apple [ ] Peach [ ] SUBMIT Then if I've only checked "Banana" and "Peach" the mysql output should only show me the rows that matches those two types. And the checkboxes should remain checked to highlight what was chosen. I can make the checkboxes but then that's about it really. I don't know how to properly get the info from the checkboxes and down to the WHERE argument in the MYSQL-code. Especially not with two types chosen. If it was just a dropdown menu with a single choice then I'd add the choice to the url and put WHERE type='$choice' - but I'm struggling with the multiple choices. I'm a bit of a novice at both php and mysql, so I'm a bit lost on this one.

    Read the article

  • migrate database from sybase to mysql

    - by jindalsyogesh
    I have been trying to migrate a database from sybase to Mysql. This is my approach: Generate pojo classes from my sybase database using hibernate in eclipse Use these pojo classes to generate the schema in mysql database Then somehow migrate the data from sybase to mysql I guess this approach should work??? Please let me know if there is any better or easier approach. The thing is I am not even able to get the first step done. I added hibernate plugin in eclipse from this link: [http://download.jboss.org/jbosstools/updates/stable/][1] I added sybase jar file to my project classpath Then I added hibernate console configuration file Then I added hibernate configuration file Then I added hibernate code generation configuration When I try to run the code generation configuration file, I am getting java.lang.NullPointerException and I have no idea how to fix it. I searched a lot of forums, tried to google it, but I not able to find any solution. Can anybody tell me what mistake I am making here or point to some hibernate tutorial for eclipse??

    Read the article

  • SQL vs MySQL: Rules about aggregate operations and GROUP BY

    - by Phazyck
    In this book I'm currently reading while following a course on databases, the following example of an illegal query using an aggregate operator is given: Find the name and age of the oldest sailor. Consider the following attempt to answer this query: SELECT S.name, S.age FROM Sailors.S The intent is for this query to return not only the maximum age but also the name of the sailors having that age. However, this query is illegal in SQL--if the SELECT clause uses an aggregate operation, then it must use only aggregate operations unless the query contains a GROUP BY clause! Some time later while doing an exercise using MySQL, I faced a similar problem, and made a mistake similar to the one mentioned. However, MySQL didn't complain and just spit out some tables which later turned out not be what I needed. Is the query above really illegal in SQL, but legal in MySQL, and if so, why is that? In what situation would one need to make such a query?

    Read the article

  • Intentionally get a "MySQL server has gone away" error

    - by Jonathan
    I'm trying to cope with MySQL's error MySQL server has gone away in a django env. The quick workaround was to set the global wait_timeout MySQL variable to a huge value, but in the long run this would accumulate to many open connections. I figured I'll get the wait_timeout variable and poll the server in smaller intervals. After implementing this I tried to test it but am failing to get the error. I set global wait_timeout=15 and even set global interactive_timeout=15 but the connection refuses to disappear. I'm sure I'm polling the database in larger intervals than 15sec. What could be the cause for not being able to recreate this error?

    Read the article

  • MySQL load data null values

    - by SP1
    Hello, I have a file that can contain from 3 to 4 columns of numerical values which are separated by comma. Empty fields are defined with the exception when they are at the end of the row: 1,2,3,4,5 1,2,3,,5 1,2,3 The following table was created in MySQL: +-------+--------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+-------+ | one | int(1) | YES | | NULL | | | two | int(1) | YES | | NULL | | | three | int(1) | YES | | NULL | | | four | int(1) | YES | | NULL | | | five | int(1) | YES | | NULL | | +-------+--------+------+-----+---------+-------+ I am trying to load the data using MySQL LOAD command: load data infile '/tmp/testdata.txt' into table moo fields terminated by "," lines terminated by "\n"; The resulting table: +------+------+-------+------+------+ | one | two | three | four | five | +------+------+-------+------+------+ | 1 | 2 | 3 | 4 | 5 | | 1 | 2 | 3 | 0 | 0 | | 1 | 2 | 3 | NULL | NULL | +------+------+-------+------+------+ The problem lies with the fact that when a field is empty in the raw data and is not defined, MySQL for some reason does not use the columns default value (which is NULL) and uses zero. NULL is used correctly when the field is missing alltogether. Unfortunately, I have to be able to distinguish between NULL and 0 at this stage so any help would be appreciated. Thanks S.

    Read the article

  • PHP & MySQL form question.

    - by peakUC
    How do I allow all users to have there username field empty without having them 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'])) { // Make sure the username address is available: $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'"; $r = mysqli_query ($mysqli, $u) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($mysqli)); if (mysqli_num_rows($r) == TRUE) { // Unavailable. echo '<p class="error">Your username is unavailable!</p>'; $username = NULL; } else if(mysqli_num_rows($r) == 0) { // Available. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); } }

    Read the article

  • mysql ignores not null constraint?

    - by Marga Keuvelaar
    I have created a table with NOT NULL constraints on some columns in MySQL. Then in PHP I wrote a script to insert data, with an insert query. When I omit one of the NOT NULL columns in this insert statement I would expect an error message from MySQL, and I would expect my script to fail. Instead, MySQL inserts empty strings in the NOT NULL fields. In other omitted fields the data is NULL, which is fine. Could someone tell me what I did wrong here? I'm using this table: CREATE TABLE IF NOT EXISTS tblCustomers ( cust_id int(11) NOT NULL AUTO_INCREMENT, custname varchar(50) NOT NULL, company varchar(50), phone varchar(50), email varchar(50) NOT NULL, country varchar(50) NOT NULL, ... date_added timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (cust_id) ) ; And this insert statement: $sql = "INSERT INTO tblCustomers (custname,company) VALUES ('".$customerName."','".$_POST["CustomerCompany"]."')"; $res = mysqli_query($mysqli, $sql);

    Read the article

  • Self referencing update SQL statement for Informix

    - by CheeseConQueso
    Need some Informix SQL... Courses get a regular grade, but their associated labs get a grade of 'LAB'. I need to update the table so that the lab grade matches the course grade. Also, if there is no corresponding course for a lab, it means the course was canceled. In that case, I want to place a flag value of 'X' for its grade. Example data before update: id yr sess crs_no hrs grd 725 2009 FA COLL101 3.000000000000 C 725 2009 FA ENGL021 3.000000000000 FI 725 2009 FA ENGL021L 1.000000000000 LAB 725 2009 FA ENGL031 3.000000000000 FNI 725 2009 FA ENGL031L 1.000000000000 LAB 725 2009 FA MATH010 3.000000000000 FNI 725 2010 SP AOTE101 3.000000000000 C 725 2010 SP ENGL021L 1.000000000000 LAB 725 2010 SP ENGL031 3.000000000000 FI 725 2010 SP ENGL031L 1.000000000000 LAB 725 2010 SP MATH010 3.000000000000 FNI 726 2010 SP SPAN101 3.000000000000 FN Example data after update: id yr sess crs_no hrs grd 725 2009 FA COLL101 3.000000000000 C 725 2009 FA ENGL021 3.000000000000 FI 725 2009 FA ENGL021L 1.000000000000 FI 725 2009 FA ENGL031 3.000000000000 FNI 725 2009 FA ENGL031L 1.000000000000 FNI 725 2009 FA MATH010 3.000000000000 FNI 725 2010 SP AOTE101 3.000000000000 C 725 2010 SP ENGL021L 1.000000000000 X 725 2010 SP ENGL031 3.000000000000 FI 725 2010 SP ENGL031L 1.000000000000 FI 725 2010 SP MATH010 3.000000000000 FNI 726 2010 SP SPAN101 3.000000000000 FN I worked out a solution for this, but it required a lot of on-the-fly composite foreign keys built from concatenating the id, yr, sess, and substring'd crs_no. My solution is not only overkill, but it has gaps in it and it takes too long to process. I know there is an easier way to do this, but I've gone so far down one road that I am having trouble thinking of a different approach.

    Read the article

  • MySql / Odbc connection problem

    - by Ingvald
    I'm accessing a MySql database via ODBC. It normally works fine, but if the database is stopped and restarted I have to restart my application in order to reconnect to the database. The code for accessing the database is like this: OdbcConnection connection = new OdbcConnection(connectString); OdbcCommand command = connection.CreateCommand(); command.CommandType = CommandType.Text; command.CommandText = "select * from cds"; OdbcDataAdapter dataAdapter = new OdbcDataAdapter(command); DataSet dataSet = new DataSet(); connection.Open(); dataAdapter.Fill(dataSet); connection.Close(); After a restart of the database, I get a 'MySql server has gone away' exception in dataAdapter.Fill method. Is there any way I can reconnect to the database when I detect that the connection has broken? I use VS2008 and MySql 5.1.30.

    Read the article

  • Syntax Error with MySQL 5.1 Server

    - by Mr.Z
    I am trying to connect to a server remotely using the command line client window. I am using MySQL 5.1 and I do not know why I am getting syntax error. If you can help me, that would be much appreciated. username as user password as pass hostname as example.com I have tried: mysql> -u user -h example.com -p ; mysql> -h example.com -u user -p ; I have looked at the reference manual and other verisons of remote connection with Server 5.1 but I can't see the syntax error.

    Read the article

  • MySQL Cluster data nodes - slow SELECTs

    - by Boyan Georgiev
    Hi to all. First off, I'm new to MySQL Cluster. This is my pain: I've managed to setup a MySQL Cluster with two data nodes, two SQL nodes and one management server. Everything works pretty well, except the following: my data nodes are spread across an intranet link which incurs latency into communications between the data nodes. Apparently, due to MySQL Cluster's internal partitioning schemes, when my PHP application pulls data from the cluster via SELECT queries, parts of the data are pulled from both data nodes. This makes the page appear onscreen REALLY slowly. If I bring one data node offline, the data can only be pulled from that single remaining data node, and thus, the final result (HTML output) appears on the screen in a very timely fashion. So, my question is this: can the data nodes/cluster be told to pull data from partitions stored only on a particular data node?

    Read the article

  • mysql foreign key problem.

    - by JP19
    Hi, What is wrong with the foreign key addition here: mysql> create table notes ( id int (11) NOT NULL auto_increment PRIMARY KEY, note_type_id smallint(5) NOT NULL, data TEXT NOT NULL, created_date datetime NOT NULL, modified_date timestamp NOT NULL on update now()) Engine=InnoDB; Query OK, 0 rows affected (0.08 sec) mysql> create table notetypes ( id smallint (5) NOT NULL auto_increment PRIMARY KEY, type varchar(255) NOT NULL UNIQUE) Engine=InnoDB; Query OK, 0 rows affected (0.00 sec) mysql> alter table `notes` add constraint foreign key(`note_type_id`) references `notetypes`.`id` on update cascade on delete restrict; ERROR 1005 (HY000): Can't create table './admin/#sql-43e_b762.frm' (errno: 150) Thanks JP

    Read the article

< Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >