Jump to content

mikosiko

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by mikosiko

  1. and expanding requinix questions: - Which is the size of tables profiles and area_served ? (row number) - Are they indexed?... which columns?
  2. +1 with Ignace answers, but also considering your project description "Site to allow a user to register, upload a document and tag the document with relevant tags to the content, which would allow other users to search for relevant material using these tags" maybe you should consider to use Drupal or Joomla
  3. you are using ' instead of backtics here: $Sql = "INSERT INTO events ( 'EventTypeID', 'EventPictureDescription', 'EventPictureTakenLocation', 'EventPictureTakenDate', 'EventPictureImagePath') your options: a) change the ' for backtics as in: $Sql = "INSERT INTO events ( `EventTypeID`, `EventPictureDescription`, `EventPictureTakenLocation`, `EventPictureTakenDate`, `EventPictureImagePath`) or, considering that none of those fieldname is a mysql reserver word you can eliminate the backtics and just use the field name $Sql = "INSERT INTO events ( EventTypeID, EventPictureDescription, EventPictureTakenLocation, EventPictureTakenDate, EventPictureImagePath)
  4. I personally like using JOINS instead of a correlated query when possible, and after analyze both Explain plans Normally RDBMS are optimized for JOIN operations, therefore the query optimizer will try to rewrite statement to use JOIN operations behind the curtains, and most likely in the majority of cases you are better off using the JOIN approach. But, as always, it depends on the particular situation and what the Explain plans shows. $query = mysql_query("SELECT a.*, b.UserFirstName, b.UserLastName, c.UserFirstName AS OnBehalfOfUserFirstName, c.UserLastName AS OnBehalfOfUserFirstName, d.BillableRate FROM Notes AS a LEFT JOIN Users AS b ON b.UserID = a.UserID LEFT JOIN Users AS c ON c.UserID = a.WhosUserIDForBillableRate LEFT JOIN FilesAndBillableRates AS d ON d.UserId = a.WhosUserIDForBillableRate WHERE a.FileID = '$_SESSION[FileID]'");
  5. here you go http://blogs.sitepoint.com/hierarchical-data-database-2/ P.S: read pages 1 and 3 too
  6. do a simple test... $sql ="SELECT * FROM articles WHERE articlename LIKE '%phrase%'"; // assuming that you already changed this line as Pica suggested echo "** The SQL is : " . $sql; // add this line and post what your get $result =$conn->query($sql) or die('Sorry, could not get any articles at this time'); also.. is good idea to include this 2 lines at the beginning of your code for debugging: error_reporting(E_ALL); ini_set("display_errors", 1);
  7. easy way WHERE date_format(`lastUpdated`, '%Y%m') = date_format(now(), '%Y%m');
  8. Are there any security issues related to using this method, e.g., more vulnerable to sql injection attacks? This is just a logging method; security concerns must be addressed before the query reach the DB
  9. I see a bigger problem in your code... you are altering your resultset ($res) inside of your main loop (first while).. that could generate all kind of inconsistence... and your second while while ($row = mysql_fetch_array($res)){ $user_id = $row['User_ID']; seems to be using the wrong resultset and variables... and also looks out-off-place (if validating num_rows inside the loop???)
  10. can you show more code?... I don't see any echo in the posted one (not saying that you don't have it)
  11. even when requinix is giving you some manual option to log activity on your DB, should be a lot easier just to enable the "query log" in your Mysql instance instead of write code yourself. how?... this is an option: - Stop your Mysql Instance - Edit your my.ini (or whatever name your mysql init file has) and add this line: log=<path & name of the login file> p.e: log=Sql-LoginFile or log="C:/logs/Sql-LoginFile" (if under Windows) - Re-start your Mysql Instance. this assuming that you have access to your mysql ini file
  12. "analyze" != "just do it" - did you debug your code? - did you run the query alone (PhpMyadmin or Mysql)? ... it return results? - are you controlling that this $fieldsResult = mysqli_query ( $dbc, sprintf($fieldsQuery,$row['ID']) ); is not failing? that just for a start
  13. analyze if, instead of have 2 separates queries for fields and fieldcontents a single query using a JOIN between the tables simplify your problem (it should)
  14. echo, var_dump or print_r $GLOBAL['path'] to see what is on it and check if the value make sense in that code
  15. "is when its getting the content for the field it needs to get the ID of the field that way it can get the content of the field" ... what? explain what error do you get or what are you trying to do and which are the expected results... I just see 2 pieces of code without any connection... hard to help you in that way
  16. DESCRIBE = Short version of SHOW COLUMNS
  17. @Muddy.. read again http://php.net/manual/en/function.mysql-num-rows.php mysql_affected_rows is the correct way to do it as @analog said
  18. "the mysqli is not working correctly" ..... you think so? mysql ('select profissao from empregos where profissao like "'.$consulta .'%"') mysqli 'select profissao from empregos where profissao like ?' see the difference? and what the next post say too
  19. without see your whole relevant code the only guess as I said... variable scope... and the final idea that I can offer is an old one... "debug your code"... echo is your very best friend a lot of times
  20. the error that you are getting make reference to the file runtime.php you just only mentioned header.php/dbconfig and page.php
  21. http://php.net/manual/en/language.variables.scope.php Dcro2 made you an important question related to that
  22. also you can face problems with ereg_replace that is profusely used in the code that you shown. http://php.net/manual/en/function.ereg-replace.php
  23. +1 with Maq answer... and for the &&, AND and OR operators and precedence you can read: http://dev.mysql.com/doc/refman/5.0/en/expressions.html and http://dev.mysql.com/doc/refman/5.0/en/operator-precedence.html
  24. an option.... use CONCAT(field1,field2) AS XX, COUNT(id) and GROUP BY XX having COUNT(*) > 1 just one SELECT... NO JOIN.... no tested on my side but should work I think
  25. this have a very short answer.... JOIN manual: http://dev.mysql.com/doc/refman/5.0/en/join.html example: http://www.tizag.com/mysqlTutorial/mysqljoins.php
×
×
  • 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.