Jump to content

codeprada

Members
  • Posts

    23
  • Joined

  • Last visited

    Never

About codeprada

  • Birthday 02/13/1991

Profile Information

  • Gender
    Male
  • Location
    Antigua and Barbuda

codeprada's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Don't practice throwing data from the user directly into your queries. It makes your database vulnerable to SQL injections. I'd suggest using Prepared Statements offered by MySQLi and PDO. They're immune to SQL injections and will save you a lot of headache. I'm assuming owner_name is a string so therefore it must have single quotes around the value. This is basically you're query. Let's use my username for example SELECT `car_year`, `car_name`, COUNT(*) as `total` FROM `company_inventory` WHERE owner_name = codeprada AND warehouse_id = 444 GROUP BY `car_name`, `car_year` ORDER BY `car_name` ASC If the warehouse_id is an integer type then it's ok but owner_name fill cause the query to fail. Prepared statements also place the quotes around your values automatically if necessary.
  2. Your SQL query is wrong because your missing the WHERE clause and the AND ... isn't suppose to be there. SELECT COUNT(user_id) AS Num FROM liked WHERE user_id = $x
  3. A query that selects the car's year and name and also the result of COUNT(*) while grouping the data by the car's year and name should do the job. SELECT `year`, `car_name`, COUNT(*) AS `total` FROM `table` GROUP BY `car_name`, `year` ORDER BY `total` DESC
  4. Learn to refer to the manual. http://pear.php.net/manual/en/package.database.mdb2.intro-execute.php
  5. You have 2 currencies in your MySQL? You should really only have one standard. For instance either USD or EURO. Then it only takes a simple multiplication operation to convert to another currency on the fly. You now have the job of find the rates relative to your standard. These rates should be stored in a separate table. Rates --USD -2.00 --XCD -500 .... You can then select the appropriate rate and then multiply the corresponding value to make the conversion.
  6. You're entering the Company Name in the ID column. You should make ID an auto_increment INT.
  7. '\n' is not the newline character but a string of '\' and 'n'. Note the single quotes as you have. Use double quotes so that PHP will parse it as a new line character.
  8. You're trying to enter duplicate keys (primary, unique, composite). Do you have an auto incremented ID in the company table?
  9. Your regular expression should be enclosed in delimiters. A delimiter would be any character used to determine the beginning and end of the regular expression. Example - # would be the delimiter '#regex_here#'
  10. Don't include PHP files via an HTTP path. Use either the absolute or relative path on the filesystem. From the looks of it LIB_PATH is in the root folder so therefore a path like this should suffice. defined('LIB_PATH') ? null : define('LIB_PATH', DIRECTORY_SEPARATOR . 'includes'); Placing the directory separator before the path indicates that the path is relative to the root directory. Also PHP has a constant called DIRECTORY_SEPARATOR which should be of use to you.
  11. You only really need to look for (Gå since it's starts your pattern and then match everything until you've reached the closing parenthesis. Consider this.... #\(Gå[^\)].+?\)#
  12. Yes you do need (should have) an HTML form for a number of reasons. They provide a means to get input from the user You can control data much easier.
  13. The problem isn't PHP but your HTML\CSS. You need to set the overflow to hidden.
  14. Mysqp_real_escape_string works to some effect but it's still vulnerable to SQL injections. You really don't need to be manually checking replacing anything in your query. Look into Prepared Statements, which are immune to injections if used properly. Offered by MySQLi and PDO. One reason why you should drop MySQL.
  15. To show errors place this at tthe top of your code error_reposting(E_ALL)
×
×
  • 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.