802 Posted Topics
Re: Strange indeed. Run a complete log (change the logging configuration in my.ini and restart the server) to see where and why the update occurs. Do you have any active triggers which do anything the the user table? | |
Re: I did not study the code thoroughly, but noticed this assignment [CODE]if ($check2 = $thenumbar)[/CODE] which should probably be a comparison instead [CODE]if ($check2 == $thenumbar)[/CODE] | |
Re: It's a question of security. If all domains share the same mysql user you have to define this user's access right's to the database only once. This makes it more manageable that a bunch of users, especially since mysql does not have a concept of user groups. If all domains … | |
Re: Your problem is bad database design. By which value would you like the aggregate row with idNo 12 to be sorted - 12, 13, or 14/02/2011? You cannot have distinct rows as a GROUP BY result and at the same time retrieve the non-grouped values separately. The non-grouped values disappear … | |
Re: How do you decide if a clause is needed in a query or not? If you have a rule for that, you can code it. But from your example this rule would have to rely on semantic knowledge rather on formal aspects of the query. | |
Re: [QUOTE]Just understand this code that how it works and your problem will be solved- [/QUOTE] Of course you will have to check first if the table already exists, maybe include a DROP TABLE statement, sanitize the input so that no malicious user can compromise or erase your whole database, and … | |
Re: Use two queries and bracket them into a transaction. That makes them from a logical and database point of view only one query in two chunks. If you don't like that, use this inefficient solution: [CODE]UPDATE runquery.table1, runquery.table2 SET runquery.table1.`Column1` = if(itemid=3,(runquery.table2.`Col1`/runquery.table2.`Col2`*100),Column1), runquery.table1.`Column2` = if(itemid=5,(runquery.table2.`Col1`/runquery.table2.`Col2`*100),Column2) where runquery.table1.`Userids` = runquery.table2.`userid`; [/CODE] | |
Re: Write a script which imports all CSV data into a separate database. Use the mysqlimport command line utility for that purpose. Then write an SQL script which compares the imported CSV data with the data in place and updates them as necessary. Store this script as a stored procedure so … | |
Re: To prevent illicit downloads you have to protect your files on the server level. Otherwise any wisecrack who can guess how a link looks like will be able to download. Tur2tlive's solution is dangerous because it makes you believe that your data are safe while they are definitely not. To … | |
Re: You can't do that in PHP. Log the submissions to a text file and view it with [ICODE]'tail -f theLogFile.txt'[/ICODE] from a console window (assuming you are using linux). | |
Re: What syntax error do you get? I assune it's because the column names in your query are bracketed in apostrophes, which the should not be. Try instead: [CODE]mysql_query ("INSERT INTO members(ID,Name,Surname,Phone,Email,Cemail,Username,Password,Cpassword) VALUES (NULL, '$Name','$Surname','$PhoneNo','$Email','$Cemail','$Username','$Password','$Cpassword'") or die (mysql_error()); [/CODE] | |
Re: Bracket the whole order process with START TRANSACTION and COMMIT respectively ROLLBACK in case of any errors. | |
Re: Maybe there is a mysql process still blocking the 3306 port. Restart the machine or kill this process (if you find it). I don't know how close MacOS sticks to its ancestor linux. With linux the advice would be, look under /var/log/messages to find info as to why mysqld would … | |
Re: Your query makes no sense, since it is an union of a set and a subset of this set. This query will always return the whole set - the entire view. The desired result makes no sense, either. What are the selection criteria so that user 1 (Ademole Adebayo) shall … | |
Re: If you do not specify an AS clause in your field content description, the row index will be the same as the content description itself. But your query does not make sense in the first place. Test it against your database without PHP (from the command line) and you will … | |
Re: [QUOTE]how to do this[/QUOTE] Don't. Do not store calculated values in your database. If Hra and DA are percentages of another database field, create a view which calculates them instead of storing them. | |
Re: Use the mysqldump command line tool. You need something like [ICODE] mysqldump -u[I]user[/I] -p[I]password[/I] [I]database[/I] --tab [I]filename[/I][/ICODE] See mysqldump --help for a complete option list. | |
Re: Use a javascript OnKeyUp() function. You cannot do it in PHP without a submit. | |
Re: Make sure that your query is using indexes. What does "EXPLAIN <your-update-query>" tell you? | |
Re: 1. What does "The last query doesn't work" mean? Do you get an error message or what? 2. Isolate your problem and present exactly the query which does not work and tell us in which way it doesn't work. 3. The clause "WHERE position <= $position AND position <= $position" … | |
Re: Use the "text" data type to store long texts. If you are stuck with the varchar type you can either store longer texts in external files and store the file names in the database, or you can set up a system of linked varchar entries which you concatenate to get … | |
Re: Quote from [url]http://stackoverflow.com/questions/658937/cache-re-use-a-subquery-in-mysql:[/url] [QUOTE]See what EXPLAIN EXTENDED says. If it says DEPENDENT SUBQUERY or UNCACHEABLE SUBQUERY, then it will be reevaluated each time it's used. This happens if the subquery uses session variables or is a correlated subquery. If it doesn't, it most probably will be cached. [/QUOTE] | |
Re: [CODE]SELECT Course.courseID,courseName,courseInstructor,if(103 in (select studentID from studentLink s where studentID=103 and s.courseID=Course.courseID),103,NULL) as ID from Course; [/CODE] There must be a better solution, but I'm too tired. Have a look at the EXISTS clause in select statements. | |
Re: You have to do it in several steps: 1) Check if there is a link with position 2 in the database. 2) If it is, [ICODE]UPDATE pages SET position=position+1 WHERE position >= 2[/ICODE] 3) Now do your INSERT query | |
Re: MySQL has a date type called timestamp which records the time of the last update of a row. Add such a field to your table. This field changes with every update, though. If you want to keep the insertion time, use a datetime field and a trigger which updates this … | |
Re: You can group the whole query by the team.id and use the count function on this aggregate. For further help submit the explicit data structures and your query. | |
Re: Use the one which you understand better. From the MySQL point of view it makes no difference. | |
Re: Use standard input/output direction from the console window. If your script resides in myscript.sql and your output should go in output.txt, enter [ICODE] mysql -u[I]username[/I] -p[I]password[/I] [I]database[/I] < myscript.sql > output.txt [/ICODE] on the command line. | |
Re: Depending on the situation it might be more efficient to use the substring() function in the database query: [CODE]$result = mysql_query( 'select substr(myfield,1,10) from mytable' );[/CODE] ![]() | |
Re: You have to define the referenced (foreign) tables first before you can define a table which contains a foreign key. So create the rental tables as the last one. | |
Re: go along those lines: [CODE]$q = mysql_query( 'select * from stock' ); while ($object = mysql_fetch_object($q)) { if (mycheck($object) < 3) echo "sell at once $object->ticker!"; }[/CODE] | |
Re: Set up one table for vehicles, one for tyres. Add a "position" column to the tyres table. Establish a 1:n relation from vehicles to tyres. Set up a unique index on vehicle_id and position in the tyres table to avoid duplicates. | |
Re: How do you keep track of your members? Via mysql or another database? Or with plain text files? Or are they system users? | |
Re: Your example is too scarce to give a general solution. Do all your entires look like "xxx_yyy"? Do you want to search only the part before the underscore? Then use the mysql substr() and locate() function to isolate that part and apply the like operator on it. | |
Re: It's quite unclear what you want. Do you want all records with a field_id=1? Then just select them. Or do you want all records in which a text field contains the string representation of the number 1? In this case use a regular expression: [CODE]select * from mytable wher field_id … | |
Re: You have to grant privileges separately to any localhost users. By default there is a rule in the privileges table which denies all privileges to any user at localhost. To grant privileges to localhost users you have to grant them explicitly with "GRANT ... TO `someone`@`localhost`". And don't forget the … | |
Re: [CODE]SELECT id FROM members ORDER BY score desc LIMIT 6, 1[/CODE] | |
![]() | Re: Do it in an orderly fashion with one table for users, one table for permissions, one table which links both and a group_concat function which helps you with your string search. If you stick with your solution, just do a preg_match for '/(^|,)mila(,|$)/' in row 2 to check if mila … ![]() |
Re: Looks great. Thanks for the hint. | |
Re: @debasidas: The question was not how to code a partition but about the behaviour in absence of such explicit coding - which I would also like to know. | |
Re: MySQL wildcard comparison needs the "like" operator: [CODE]if ($_POST[district_zone] == "0") { $receivezone = [COLOR="Red"]"like '%'"[/COLOR]; } else {$receivezone = [COLOR="Red"]"= " . $_POST[district_zone][/COLOR];} $query_rs_district = "SELECT property_districts.district_zone, property_districts.district_name FROM property_districts WHERE property_districts.district_zone '$receivezone' ";[/CODE] | |
Re: You're barking up the wrong tree. Try to build a query which contains all data to be displayed and then loop through it. Do not use 5 queries - it makes your code illegible. And regarding your code style: avoid redundancies. If mysql_query() goes with "or die..." whereever it occurs … | |
Re: Try another interface than phpMyAdmin, e.g. command line mysql. I assume that phpMyAdmin twiddles your query. Look in the server log what the actual query is which the server complains about. | |
Re: <?php $query= "SELECT * FROM table"; $result=mysql_query($query) or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows > 0) { echo "<table>"; while($row = mysql_fetch_array($result)) { [COLOR="Red"]$num_rows--;[/COLOR] echo "<td>" . $row['data'] . [COLOR="Red"]($num_rows > 0 ? "," : "")[/COLOR] . "</td>"; } echo "</table>"; } ?> ![]() | |
Re: Make sure that you have an index for all search criteria. And combined indexes for combined search criteria. Let MySQL EXPLAIN your query to optimize it. Add more RAM to your server. Increase the key buffer and other cache variables in my.ini. | |
Re: If you have wamp installed you can run php from the command line. In my system it's c:[ICODE]\xampp\php\php <filename.php>[/ICODE] You won't have any server variables or HTTP properties like cookies, though. If you can run it that way but not under apache, then probably apache is not configured correctly. Check … | |
Re: You have to establish a connection first with mysql_connect(). Try [CODE]$rst = mysql_query($sql) [COLOR="Red"]or die(mysql_error())[/COLOR];[/CODE] to learn more about the problem. |
The End.