Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. What is the extra information which causes a problem?  When I click on your link, everything looks fine.
  2. I assume the missing quote is because you edited the password. One problem is here: [code]if ($result = 1)[/code] That will assign the value 1 to $result.  Instead you should use [code]if ($result == 1)[/code] Also, since $result is a mysql row object, you should use: [code]if ($result->privacyid == 1)[/code]
  3. Does autovivify mean to create automatically?  The default in PHP is to create all variables (including levels in multi-level arrays) automatically.  Like: $var['count'] = 2; $var['values'][0] = 0.1; $var['values'][1] = 0.2; I'm not sure if that's what you're talking about though.. If you then say "$values = $var['values']", you will get a copy-on-write copy of that part of the array.  "$values = &$var['values']" will give you a reference to that part of the array. As far as usage goes, it's virtually the same as perl.  I found it easy to switch over. Regarding "gearedness", it's the little things.. in perl you can write "while (<>) { s/..$// }", which is great for processing a text file.  In PHP, you can write "session_start(); $_SESSION['var'] = $_GET['var'];", which is great for a website.  $_SESSION is part of the language specification itself, as is $_GET and $_POST. Once you've got enough skill in either language you can do anything though.  It's just the little things that are handled for you already which make up the gearedness.
  4. When using a profiler, array_push() counts as a function call, but array[] is only syntax.  I haven't noticed any performance difference between them.
  5. Try using $this->CreateMeta() in your constructor
  6. Well, it's not simple :)  But not difficult for an experienced programmer. I would suggest doing some tutorials to learn a bit about php and sql.  Once you've done that, it'll become clearer what is needed for what you're proposing.
  7. For categories you have a loop [code]while($cat = mysql_fetch_array($category)){[/code] But for forums you haven't included the loop.. you just have [code]$showf = mysql_fetch_array($showforums);[/code] This will cause you to only fetch one forum per category.  To fix it, make an inner loop for forums the same as the outer loop for categories.
  8. I don't think a join is a good idea for this, unless you have a very good reason.  Two queries is much simpler. The first query gets the privacy mode of the user being viewed, and if that results in 1, then the second query checks the buddy list.
  9. Without an ORDER BY, the database can just fetch any 20 results and give them to you.  But once you order the results, the database has to fetch ALL results, sort them, then give you the first 20.  That's probably what's slowing you down. To fix it, you can try reducing the amount of data it needs to order.  Instead of ordering by sticky, you can do a seperate query or subquery (using an index) to fetch all the sticky topics.  That should be fast.  But the volume of results for the rest could be quite high.  One way to help is to partition your database, such as having one table for each month worth of topics.  Then you query the first month, see if you have enough topics, if not then you query the previous month, and so on until you get 20 topic worth.  Sticky topics would need their own table too, since stickiness is the most important criterion. Another option is to cache results.  Caching per-forum may be a big win, especially if some forums are not updated often but others are.  Then again, it's the most frequently updated forums that will be the largest. Maybe someone else has some other ideas?  I use postgresql usually, but a lot of the same principles apply.
  10. You can use an entire variable as a variable name like this: [code]$varname = 'brian'; $$varname = "Hello world\n"; print $brian;[/code] But I don't think there's any way to make the variable name inline, like $var_{$othervar}_1.  $name = 'var_{$othervar}_1'; $$name = 'val'; will work though.
  11. The database connection should be [code]$cn=@mysql_connect("host","username","password") or die(mysql_error());[/code] where host, username and password are replaced with the appropriate values for your database. Regarding fetching the data, are you expecting to get several rows of data, or just a single row with many fields?  Your code looks like it expects a single row with many fields.
  12. If there's no '<?', then it's none of php's business.  It'll just treat it as html and not process it at all.  So that's why there's no errors. And yes, we've all made that mistake :)
  13. You could try socket_set_nonblock() if you don't want it to freeze on no data.  I'm not sure if the default is blocking or non-blocking.
  14. This is used by various version control systems, such as CVS, RCS and SVN.  It tells you what version of the file you have, when it was last updated, and who did the update (acydburn updated that file most recently). It's very useful information for developers, since it helps them keep track of code changes, and let's them know exactly which version of the code they are looking at.
  15. Are you getting only one row, or are you getting the same row printed multiple times?  Your loops looks like they should work, assuming class.php does something sensible.
  16. You have specified 31 column names and 32 values to put into them.  Either you missed a column or you added an extra value.  The error message just means that the number of column names and number of values don't match.
  17. I don't recognize the database interface you are using. Can you give us a sample of what var_dump($rows) looks like?  Or an example of how to access the result set?
  18. I think that's the best solution, dirty though it is.  Once you've unioned two result sets, it's impossible to tell which set the data originally came from unless you add a marker like you have there. Another option would be to do two selects and merge them and sort them in php.  Merging and sorting is usually easier in sql though :)
  19. I don't think pconnect allows you to keep transactions between HTTP requests. Instead, you can do application level locking.  Create an entry in a table, and have other competing processes also create the same entry.  If there's a conflict, one process will fail.  Once the entry is successfully created, that represents an exclusive lock for the process which created the table entry.  That'll work as long as all processes which may alter that table respect the application level locking mechanism. How were you planning to end the transaction if the client never fills in the form?
  20. Thanks, I will try that one out :)
  21. Milliseconds?  I guess polling isn't going to work then. What I was suggesting was to have something like [code]mysql_query("UPDATE ... "); touch("/tmp/database_is_updated");[/code] The idea being to actively create/modify a file to indicate that an update has happened.  It could also be done with a trigger depending on your DBMS.  If you can have a trigger which modifies a file whenever the specific field is updated, and a file system watcher which notices that, then that file can be a method of signalling the watcher that a change has occurred.
  22. Has anyone had experience with creating PDF files from PHP?  Are there any good packages for making nice-looking ones? Thanks! Brian
  23. [quote author=slopok link=topic=112735.msg457771#msg457771 date=1161834803] My programmer has the "I am god gretest gift to man kind and computer programming in almost any forms.  My problem with this, is I have to bow down to his words, because I honestly do not know what to believe or not believe. [/quote] Hmmm.. tell him that you asked lots of people and no-one else could fix it.. you have no-one to turn to other than him and his godlike programming skills :)  A big ego can be used to your advantage..
  24. You could do it ajax style, and use javascript to poll regularly.  For example, every 10 seconds you could send a request to a php script which returns "Yes" if there's another record, or "No" otherwise. Or, building on the file system watcher, you could have the process which creates the new database record also create a file (or update a file).  Then your file system watcher can be triggered.
  25. What you're unsetting there is just a local variable.. instead use [code]unset($chkbox_arr[$i]);[/code] That will remove element $i from the array.  Keep in mind that the array will not be renumbered when you do this.. so for your loop afterwards you can do [code]foreach ($chkbox_arr as $element) {   echo "$element  "; }[/code] That removes the dependence on having the array indexed consecutively by numbers. Also try var_dump($chkbox_arr) to see what your array looks like at the end.
×
×
  • 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.