Jump to content

Mchl

Staff Alumni
  • Posts

    8,466
  • Joined

  • Last visited

Everything posted by Mchl

  1. Try echo mysql_error(); after executing query.
  2. I'm not sure really... The best thing would be to force your hosting company to enable mysqli support. It's been kind of a standard for some time now. It's more secure. And a server can run with both mysql and mysqli extensions enabled at same time (they even can both be used within one script). I can so no reason, why they wouldn't do it, except for laziness. The worse options, is to look for all mysqli functions within script, and to change them to their mysql counterparts. An example: $result = $mysqli->query("SELECT * FROM table WHERE 1"); is equal to: $result = mysql_query("SELECT * FROM table WHERE 1"); In most cases it will be as simple as this, but in others there will be more changes. See for example connecting to database in both cases.
  3. But FPDF can't use existing PDF as an template. It'd be necessary to create a code, that would produce same output as 'template' document.
  4. See date/time functions such us date_parse() (an alternative for explode() GuiltyGear used) or strtotime()
  5. W stands for Windows L stands for Linux That's about it
  6. FPDF won't work for this, but you can ask this question on their forum http://www.fpdf.org/ They've much experience dealing with PHP and PDF
  7. If there are any, they're probably in mysql to mysqli direction.
  8. Then it's not a float anymore, because float, as its name implies has floating point (and variable precision). But this is technical discussion about how types are implemented. Let's have an example, that shows how float and decimal types differ in practice. First a table CREATE TABLE `floatvsdecimal` ( `ID` int(10) unsigned NOT NULL auto_increment, `fl` float NOT NULL default '0', `decm` decimal(5,2) NOT NULL default '0.00', PRIMARY KEY (`ID`) ); Then data: insert 1000 rows like this one. INSERT INTO `floatsvsdecimal` VALUES (null,0.33,0.33); And now select: SELECT sum(`fl`), sum(`decm`) FROM floatvsdecimal; Results: +-----------------+-----------+ | sum(fl) | sum(decm) | +-----------------+-----------+ | 330.00001311302 | 330.00 | +-----------------+-----------+ 1000 rows, and there's a discrepancy on fifth decimal place. You need 1'000'000 rows for it to show up in second decimal place. If the values inserted into a table were more varied as in real life, it's possible that the discrepancy was even larger (or smaller). What's more, it can vary between hardware platforms and operating systems.
  9. Joys of dynamic typing...
  10. try and tell me if it works
  11. Using consistent array indexing actually helps you know... Anyway... if your indexes are within 01 to 99 then function addZero($number) { if ($number < 10) $number = "0".$number; return $number; }
  12. Don't do that. How difficult would it be to hack this into name="approved" and value="yes"? Such variables should be treated server-side.
  13. Store information about pending files in mysql table (together with time when the file was submitted). When the file is accepted/rejected remove it from this table. When displaying queue order files by submit time.
  14. 1. Based on fragments you've posted it should 2. Probably. Most mysqli methods/functions have their counterparts in mysql. If your script isn't using some 'advanced' techniques like stored procedures, then changing to mysql should be possible. 3. Based on fragments you've posted it should
  15. There isn't such a thing as a 'float with a precision of 2'. What you mean is probably a numeric/decimal type. See SQL antipatterns presentation available in mysql forums here on phpfreaks to see the difference between the two.
  16. If id in your table is not autoincrement, you could also try: INSERT INTO table SET id = $id, clicks = 0 ON DUPLICATE KEY UPDATE clicks = clicks + 1;
  17. But why would you need anything else? I can imagine a system that would looad a txt file and then create a lambda function ( create_function() )based on its contents but... what for?
  18. It crashed, but did it give any warning/error? switch/case gets some time to get used to, and perhaps you shouldn't use it right now, if you feel more comfortable with if-else. Your main problem was with getting results from database. Did you succeed at that? <?php $query = 'SELECT * FROM users WHERE pending = 0'; $query = ' SELECT * From users Where type = "PRSpecialist"'; That's part of your code. As you can see, you're assigning diffirent values to one variable. At the end of this code $query holds only SELECT * From users Where type = "PRSpecialist" If you wanted to have two queries on one variable you should do it this way: <?php $query = 'SELECT * FROM users WHERE pending = 0'; $query .= ' SELECT * From users Where type = "PRSpecialist"'; So at the end $query would hold: SELECT * FROM users WHERE pending = 0 SELECT * From users Where type = "PRSpecialist" However mysql_query() does not support multiple queries so it wouldn't work either.
  19. It's not decalred, as no declarations are needed in PHP. But for completness sake you can put $type = NULL; above the code I've written before. <?php $type = NULL; switch($_POST['type_account']) { /*...*/ What's important, is that $type gets its value within switch statement, based on $_POST['type_account'] value <?php /*this example is slightly different than the last one*/ switch($_POST['type_account']) { case "pr_specialist": //if $_POST['type_account'] is equal to "pr_specialist" case "none": //or it is equal to "none" $type = "PRSpecialist"; //$type gets value "PRSpecialist" break; case "students": $type = "Student"; break; case "contractors": $type = "Contractor"; break; default: //this section is executed only if none of the sections above are die("No account type selected, or account type invalid"); } Once the $type has proper value you may use it in your query.
  20. Explain: "PC vs Linux" part I suppose it's "Windows vs Linux". If so, I'm on Windows most of the time, but have Ubuntu installed for compatibility checks.
  21. Do echo $query; to see if it makes sense. (are you aware that you're overwriting first "SELECT WHERE pending = 0" with "SELECT WHERE type='type'" ?) Try also print_r($result); to see what's in it. You might also want to change this if-elseif-elseif... construction to <?php switch($_POST['type_account']) { case "pr_specialist": $type = "PRSpecialist"; break; case "students": $type = "Student"; break; /* more */ } $query = "SELECT * FROM users WHERE pending = 0 AND type = '$type'"; $result = mysql_query($query) or die(mysql_error()); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { /* parse rows */ } ?> Last but not least: are you using mysql or mssql (you're posting in mssql forum, but using mysql functions). I assumed you're using mysql.
  22. Perhaps you should consider using some db abstraction library? See PHP Data Objects for example. Using it you should be able to create a code, that can easily be connected to diffirent db servers by simply changing a driver.
  23. RAID 5 seems to me like an optimal solution for small companies. I didn't have a chance to try it yet, so that's speaking only from reading its specs.
  24. Its similar situation with other software asking you to install diffirent versions of .NET platform. (And hey! If you have .Net v3 it doesn't mean you won't need .NET v2!). NetBeans at least lets you decide which JAVA SDK, SVN client, PHP interpreter etc... you want to use BTW: NetBeans 6.5 Beta is out.
×
×
  • 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.