NineChime forum

Furry stuff, oekaki stuff, and other stuff.

You are not logged in.

Post a reply

Write your message and submit
Options
Humanity test

What is four + one?

Go back

Topic review (newest first)

Waccoon
07-09-2005 03:37:14

Before OekaiPoteto, I was strictly a Perl coder.  OP really gave me a head-start with PHP, and taught me very early what to do and NOT to do.

The PHP website is a terrific reference.  Syntax explanations are lacking and the warning about registered globals is very deeply burried, but all in all, reading the website alone will give you most of what you need to get started.

I'd recommend Drupal as a guideline for coding style and overall design.  The code quality is exceptional, and my new Oekaki board will likely be based on that project.

mixel
07-09-2005 01:55:52

You've been a real help. big_smile Thanks a lot! I might have to buy a book to help me learn PHP quicker. I keep getting apps and editing them a *tiny* bit without actually knowing what I'm doing at all.

I might have a couple of ideas/suggestions, but I'll give them their own thread.

Waccoon
07-03-2005 14:05:40

It's just a formality, as PHP closes the connection automatically when the script finishes.  It can, however, assist in debugging and tracking down odd database behavior.  It's also formal to provide the database handle ($dbconn).  Many scripts just call mysql_close() with no handle and that can cause some weird things to happen, too.

SQL is pretty easy to learn.  When you do a SELECT *, it means to select everything.  WHERE something='value' narrows down the search so the database doesn't blow up.  mysql_fetch_array() is used to get a lot of information from the database, but you may want to check out how that function works on http://www.php.net if you're serious about getting more detailed information.

Oh yeah, and PHP parses strings with double quotes, and uses literals with single quotes.  In other words, assuming the $name variable is 'Henry', echo 'MyName = $name' will print MyName = $name, whereas echo "MyName = $name" will print MyName = Henry.  I try to write my SQL statements with double quotes and use single quotes to delimit values in the SQL itself, such as $result = " SELECT * FROM {$OekakiPoteto_MemberPrefix}oekaki WHERE usrname='$name' ";  There's a lot of code still in Wacintaki that uses single quotes tacked together with periods and backslashes, and that's much less readable.

If there's other code you want to modify, just gimme a holler.  smile

mixel
07-02-2005 22:52:05

Thanks.. big_smile with that i've been able to set it up fine..

That's odd though.. If i hadn't been closing my sql connections, is there any chance it'd be slowing my site down? Or would it not really do much?

Waccoon
07-02-2005 06:03:03

First, you need to include the "dbconn.php" file, as it connects to the database and sets the database prefix.  Then, you need this somewhere:

$whoonline  = mysql_query ("SELECT COUNT(onlineusr) FROM {$OekakiPoteto_MemberPrefix}oekakionline");
$onlinerows = mysql_result($whoonline, 0);

The first line tells SQL to count the number of rows that exist for the field "onlineusr", and put a database handle into the $whoonline variable.  The second line uses the handle to actually get the result (row 0, or the first row of the result), and puts it into $onlinerows.  $onlinerows is the actual count you can use in your web page.

Tip:  it's proper to close the database connection after you're done with it, so add the line "mysql_close($dbconn);" somewhere at the end of your web page.

mixel
07-01-2005 13:04:25

Hi..

Thanks for all the work on wakintaki.. It's good to see OP getting useful additions again..

This is a bit of a dumb question for anyone who knows php.. I'm trying to have my 'users online' count displayed on another php page..

I can't work out how to print a simple SQL query. I know, lame. Sorry.

If anyone could post the code to do it i'd be very grateful. smile thanks..

Board footer

Yep, still running PunBB
© Copyright 2002–2008 PunBB