Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. sorry but i'm not sure what you mean by table description table schema.. description... definition... same thing .... the CREATE TABLE sentence
  2. ^^^ and that should be a better and more flexible design/solution
  3. transform your tables job_done and job_failed in only one table for better design,,, after that your queries will be easier
  4. could you post your tables and what are you trying to do exactly?.... a first glance and based only in the small piece of information that you posted the design seems very curious imho
  5. debug your code echoing your variables before the if, and see if they have the values that you expect... other than that we can only guess
  6. why?.... be more specific... we don't see what you are seeing
  7. suggestions: - Check that the user that you have in the DB is DANI and not dani (... according to the errors shown that is the user (and no root) that you are using to login). - Check that the user has the proper GRANTS for the DB/tables.
  8. good... at least you fixed the UPDATE error that was posted originally... sanitize/cast/validation for your POST values still an issue... and also you should remove those '@' from your code... with those in place you are just hiding possible errors and not controlling them as you should. In a further optimization of your code you could look into the INSERT... ON DUPLICATE KEY UPDATE syntax
  9. did you test all your code? an UPDATE like the one that you have posted shouldn't work $sql="UPDATE troop (rookie_gun, rookie_flak, rookie_anti, vet_gun, vet_flak, vet_anti, elite_gun, elite_flak, elite_anti, rookie_tank, rookie_truck, rookie_cannon, vet_tank, vet_truck, vet_cannon, elite_tank, elite_truck, elite_cannon, rookie_fighter, rookie_bomber, vet_fighter, vet_bomber, elite_fighter, elite_bomber) VALUES ('$_POST[rookie_gun]', '$_POST[rookie_flak]', '$_POST[rookie_anti]', '$_POST[vet_gun]', '$_POST[vet_flak]', '$_POST[vet_anti]', '$_POST[elite_gun]', '$_POST[elite_flak]', '$_POST[elite_anti]', '$_POST[rookie_tank]', '$_POST[rookie_truck]', '$_POST[rookie_cannon]', '$_POST[vet_tank]', '$_POST[vet_truck]', '$_POST[vet_cannon]', '$_POST[elite_tank]', '$_POST[elite_truck]', '$_POST[elite_cannon]', '$_POST[rookie_fighter]', '$_POST[rookie_bomber]', '$_POST[vet_fighter]', '$_POST[vet_bomber]', '$_POST[elite_fighter]', '$_POST[elite_bomber]')"; here is the right syntaxes for UPDATES also... you should sanitize/cast/validate your $_POST[] variables before to use them directly in your queries.
  10. why something random and not just simply $target = $target . basename( $_FILES['uploaded']['name']) . "_".date("Y-m-d_H-i",time()); Mj beat me with it
  11. no is not... ' are not the same as `
  12. http://www.php.net/manual/en/mysqli.overview.php
  13. that is a design calling for problems... one example: what about if one person own: 1 Dog, 1 Bird and 2 Cats ... that will add-up 8 right?..... so now... how you can tell what exactly he own?... all those pets or just a Fish? you will be better if you create a new table that represent the relationship between the pets and the owners... like per example: Pets_by_owner Pet_id Owner_id with that you can have with simple SELECT the exact data that you need
  14. Huh?.... don't follow.... (and I'm not talking about your number problem)... why you don't explain what exactly you are trying to accomplish with a design like the one you described... your tables schema and data examples will help to offer you suggestions.
  15. @troelss Try this: SELECT a.tid,a.name FROM teacher_subjects t JOIN teachers As a ON a.tid = t.tid WHERE t.sid IN (60,72) GROUP BY a.tid HAVING count(a.tid) > 1; // here you must use a variable instead of 1, with value = #subjects searched - 1
  16. just for a start ... ??? INSERT is not the same as UPDATE $query="Update INTO AccountNumber VALUES (" .$dno . ", '" . $dname . "','" . $location . "')"; if(!mysqli_query($con, $query)) echo mysql_error($con);
  17. only if your storage engine is Innodb: - Define Foreign KEY in table 2 and 3 to table 1 and use ON DELETE CASCADE
  18. Just to share some alternative to this CSV file creation script.... another alternative way to do it is just using the syntax: SELECT .... INTO OUTFILE ... only requirement is that the user must have FILE privileges in the DB... a working example: <?php // Define how to display/report errors in your development environment error_reporting(E_ALL); ini_set("display_errors", "1"); $host = 'localhost'; $user = 'yourusername'; $pass = 'yourpassword'; $db = 'yourdb'; $table = 'yourtable'; $file = "path where you want your file" // p.e: "C:\\\stats-export2.csv"."_".date("Y-m-d_H-i",time()); $link = mysql_connect($host, $user, $pass) or trigger_error("Can not connect." . mysql_error(), E_USER_ERROR); mysql_select_db($db) or trigger_error("DB not selected." . mysql_error(), E_USER_ERROR); $query = "SELECT * INTO OUTFILE '{$file}' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\n' FROM $table"; // var_dump($query); // for debugging purposes only $values = mysql_query($query) or trigger_error("Error : ".mysql_error(), E_USER_ERROR); if ($values) { // File Generated OK echo "Ok"; } else { // Something was wrong echo "No-OK"; } ?>
  19. I will guess that is most likely because your scripts are inserting an empty string into the field ( '' ) and not a NULL value... default property is good but you always must validate that you are inserting the right thing in your fields
  20. I'm not an expert in mssql but a quick search for mssql_get_last_message() shows me that the function doesn't need parameters.. also noticed that in other parts of your code you are using it without parameters... why are you using it differently here?... could be that the cause of your problem? ... why you don't try it without parameters ?
  21. more simple: mysql_query("UPDATE table_name SET username = 'Anonymous' WHERE username IS NULL OR username = '' ") or trigger_error('Update Failed : ' . mysql_error(), E_USER_ERROR); just one query... no need to select the records first. if you only use PhpMyAdmin run the provided UPDATE in a SQL tab. you can also alter the table and define 'Anonymous' as the DEFAULT value for that field, in that way you don't need to run the UPDATE every time that a new record is inserted with that field null.
  22. had you try to debug your code with errors report/display enabled? <?php // Define how to display/report errors ini_set("display_errors", "1"); error_reporting(E_ALL); require('../assets/mssql_connect.php'); // BUILD NEW QUERY FOR ORDERS $orders = mssql_query("SELECT TOP 10 * FROM MainJobDetails WHERE InvoiceCustomerCode='$code'") try that and see if you get some error
  23. mysql_query("UPDATE studenti SET k1O = '$kol1' AND k2O = '$kol2' AND k3O = '$kol3'") or die(mysql_error()); is not the update problem clear?
  24. why?... works for me with your data... results: 1, 'Roland', 100, 23, 123 2, 'Marylin', 300, 2330, 2630 3, 'Clint', 250, 340, 590
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.