mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
and?.... what is the problem with that Keith?.... I've DB's with a lot.. and I mean ... a lot.... of triggers/stored procedures and never I have had any problem with that... works like a charm for me... but again that is JMHO. Miko
-
did you try to create the trigger manually in your DB?... using MySQLQuery per example?... does it works? and also... are you using mysql or mysqli extension to run that multi-query?
-
do you have your error reporting enabled? try to include this lines in your script.... error_reporting(E_ALL); ini_set("display_errors", 1); I bet that you will see an error message regarding that trigger grants. to solve it... look for how to grant TRIGGER permissions to the user that you are using in your script. GRANT TRIGGER ON your_database_name.* TO <your_user>; this GRANT must be executed as a superuser.
-
you got an answer in the other post.... the182guy gave you a good start.... just continue reading/posting there
-
agree... but is not evil just a wild horse to need to be controlled some people prefer that syntax because make your code more portable/standard. At the end, you normally could face the probability of be in need of modify your JOIN's to comply with the specifics of the DB Engine that you will be working with (more less frequent nowadays). I personally I have been using both syntaxes without mayor problem for looooong time the point for the OP is to learn that both syntaxes are equivalent and each one present pros/cons that he need to evaluate and decide which one (or both) he want to learn/use. (I suggest to learn/use both... but that is JMHO).
-
Example to try.... (no tested fully)... replace variables/table names as required: $link1 = mysql_connect($hostname, $username, $password) or die(mysql_error()); // NEW DB $link2 = mysql_connect($hostname2, $username2, $password2) or die(mysql_error()); // OLD DB // Select Database 1 (Your New DB) $db1 = mysql_select_db('database1', $link1) or die(mysql_error()); // Select Database 2 (YOUR OLD DB) $db2 = mysql_select_db('database2', $link2) or die(mysql_error()); // Clone your table Data $query = "CREATE TABLE $db1.final_tablename AS SELECT * FROM $db2.source_tablename"; mysql_query($query, $link1) or die(mysql_error()); mysql_close($link1); mysql_close($link2);
-
maybe will be good if you further elaborate on that fenway
-
I don't follow either... but to answer what you posted below You ARE using JOIN in the select that you posted... the fact that you are not using the word "JOIN" doesn't mean that you are not using it... that is called "implicit JOIN"... in other words... this 2 sentences are exactly the same and equivalents: // JOIN USING IMPLICIT NOTATION select a.field1, b.field2 FROM table1 a , table2 b WHERE a.id = b.id // JOIN USING EXPLICIT NOTATION select a.field1, b.field2 FROM table1 a JOIN table2 b ON a.id = b.id
-
reading your post seems that you have a database model design problem there.... looks like you at least need: - An Employee table - a Monthly transaction table which should be related to the employee table (employee 1:n to transactions) posting your table(s) definition will help to give you a better answer
-
in your second script you are not checking that you effectively are getting values in your $_POST variables... you must check it: simplified example: IF (isset($_POST['var'])) { // here the code that send the email { else { echo "Error : You must fill the form... or what ever you want";}
-
Back To Topic: If you are talking about storing fields in the database with special characters on them, you should read about mysql_real_escape_string(), addslashes(), and stripslashes() at minimum in a direct string as the one that you showed the additional " need to be escaped... "this is a \"testing\" .... etc... "
-
always trying
-
You can't figure out why?..... just look your $info variable and the what is printing.... what do you think is happening?
-
Use ORDER BY DESC and LIMIT clauses
-
and a possible slightly different alternative could be SELECT a.agentname, SUM(IF(a.status='Prospect',1,0)) AS TProspect, SUM(IF(a.status='Insured',1,0)) AS TInsured FROM clients a JOIN members b ON a.agentname = CONCAT_WS(' ', b.firstname, b.lastname) AND b.office = '$office' WHERE a.status IN ('Prospect', 'Insured') AND a.agency = '$agency' GROUP BY a.agentname
-
what code have you wrote already?....
-
you have any reason to write 3 query?... something like this should replace your 3 first querys (no tested completly) SELECT a.agentname, a.status, count(a.status) AS Cstatus FROM clients a JOIN members b ON a.agentname = CONCAT_WS(' ', b.firstname, b.lastname) AND b.office = '$office' WHERE a.status IN ('Prospect', 'Insured') AND a.agency = '$agency' GROUP BY a.agentname, a.status your 4th query doesn't seems to have any relation with the previous ones, therefore I don't see why it should be in the loop
-
I know that mysql extension have the mysql_data_seek() function that possible could solve the issue... the mysqli equivalent is mysqli_stmt_data_seek ... never used/tested it myself... you can look the manual and see if will work for you http://www.php.net/manual/en/mysqli-stmt.data-seek.php other option could be load the data in an array using your while loop and process the array after that
-
time to read a bit then http://www.rustyrazorblade.com/2006/09/mysql-triggers-tutorial/ and http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html
-
in addition... - check what do you have in "$balltype = 8" is not showing the 8 - take a look also to the SWITCH() function - all your lines mysql_xxx can be replaced just for 1 line... is just a matter to manage the second VALUE in your insert and the color as variables (this is an improvement for version 2 )
-
to answer your original question... No.. is not possible. If you need to create/store your column C with A+B (concatenate) you must use triggers (2 .. 1 for Insert and 1 for update) as thorpe suggested.
-
no clear for me if you mean that the users export that content in a "field" or a CSV "file" both have totally different solutions/approach... will help if you post the table description where you want to insert those values.
-
selecting a name from table 2 but get no returns
mikosiko replied to jeff5656's topic in PHP Coding Help
the simple and more clear way is assigning row alias directly in your query, in that way you don't have to worry about fieldname differentiation later in your code... per example.. $query = "SELECT a.name AS Aname, b.name AS Bname FROM table1 a JOIN table2 b ON a.id = b.id"; $return = mysql_query($query); while ($row=mysql_fetch_assoc($return ) echo $row['Aname'] . " - " . $row['Bname']; -
because you are reading only the first result and nothing else your code should be something like $empget = mysql_query("SELECT * FROM members WHERE office = '$office' AND agency = '$agency'") or die(mysql_error()); while ($emp = mysql_fetch_array($empget)) { $emplist[] = $emp['member_id']; } print_r($emplist); the last line will print the complete array... if you want to work with that array you need to do it with a loop (for loop or foreach)
-
good.... but I'm still don't like it as a solution.... what is going to happens if tomorrow you have another "statez" ... your query is going to return an additional row and your code will need to be manually adjusted... not good.... you should try to review your code and make it work automatically with a loop... that is the right way IMHO.