Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. justsomeguy

    easyphp help

    EasyPHP is a development tool, it should not be used to host or support anything online. That's what actual webservers are for. If you intend on hosting internet content on your home computer, the first thing you need is a static IP address. Most ISPs charge considerably more for a static IP address (such as a T1; cable, DSL, modems etc are generally not static), but that depends on where you live.EasyPHP is intended to make installing and setting up a development server easy (hence the name). The alternative to this is something like I have running at home. My computer there is running Microsoft's webserver software (IIS), and I manually installed and configured PHP, MySQL, and phpMyAdmin. It takes a bit of work to do, which is why EasyPHP exists. But even so, I wouldn't even think of opening up my network to incoming internet traffic, a quick look at the server logs at work that show hundreds of login requests from China and South America tells me that I want to worry about development, not securing my server against foreign hackers that I have no legal recourse against.
  2. Configuration options like that are compiler options, you include that when compiling PHP from source code. I believe that the zip package of PHP available on php.net is compiled with support for all of the extensions on php.net, but the Windows installer is not. If you already have a binary of the PHP engine, you don't use those configuration options.Similarly, you only need to have the libxslt library available at compile time, not runtime. Libraries like that are compiled into the PHP binary. If you go to the libxslt site, you will see that it is called the The XSLT C library, it is for the C language and is linked to during compilation. That is why the zip distribution of PHP is so much larger than the Windows installer, because all of those libraries have been included. If you are running off the zip binary (or off a commercial webserver), then you probably already have support. If this code executes, you have support:$xsl = new XSLTProcessor(); Also, try this for performing your transformation: $xsl = new XSLTProcessor();$doc->load($xsl_filename);$xsl->importStyleSheet($doc);$doc->load($xml_filename);echo $xsl->transformToXML($doc); More help is on the php.net pages for XSL functions, although there is no versioning information. Due to the fact that this is an object-oriented extension, it might only work in PHP5.
  3. Checkboxes can take any value. In the "value" attribute of a checkbox, you specify which value you want sent to the server if the checkbox is selected. If the checkbox is not selected, no value is sent (i.e. the variable name is not even part of the request). In the example here, if the checkbox is clicked the server receives a variable called "delbox" with a value of "1". If the checkbox is not clicked, the server doesn't receive the "delbox" variable at all.Now for the code. As Selacius said, you need to give each checkbox a unique name. Hopefully you have an 'id' field or something in the database (using $i alone isn't reliable, in case the list of players changes between the time you view the page and the time you submit it). <form action="url/members_delete.php" method="post" name="members_del"><?php$sql->QueryRow("SELECT * from members ORDER BY player");for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $id = $sql->data[0]; //I'm not sure of the index, if any, of your ID column $player = $sql->data[2]; $class = $sql->data[3]; $profone = $sql->data[4]; $proftwo = $sql->data[5]; $delbox = $sql->data[6];?> <tr> <td width="20%"> <input type="checkbox" value="1" name="delbox_<?php echo $id; ?>"> --------------></td> That will attach the id to the name of each checkbox, so they all have different names.The rest of the HTML is the same.For your PHP page, you need to do something similar. <?phprequire("url/php/db.inc.php");$sql->QueryRow("SELECT id from members");$affected_rows = 0;for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $id = $sql[0]; $delbox = $_POST["delbox_" . $id]; if ($delbox == "1") { $sql2 = new MySQL_class; $sql2->Create("mydb"); $sql2->Delete("DELETE FROM members WHERE id={$id}"); $affected_rows++; }}?> With this, you don't need a page in the middle that updates the value. If you want to delete them, there's no need to update the database, just go ahead and delete them. But this way requires one query per deletion, if you want to group all of them into a single query you could make a list like this: <?phprequire("url/php/db.inc.php");$sql->QueryRow("SELECT id from members");$ids_to_delete = "";for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i); $id = $sql[0]; $delbox = $_POST["delbox_" . $id]; if ($delbox == "1") { if ($ids_to_delete != "") $ids_to_delete .= ","; $ids_to_delete .= $id; }}if ($ids_to_delete != ""){ $sql = new MySQL_class; $sql->Create("mydb"); $sql->Delete("DELETE FROM members WHERE id IN ({$ids_to_delete})");}?>
  4. You can also use PHP to create an image that shows the email address, but it wouldn't be able to be clicked on to email unless you still have javascript that obfuscates the address.
  5. I wasn't sure about that when I asked, I thought that maybe the operators also looked at the forum, or even just the suggestions area. I already emailed Hege Refsnes, so hopefully she can take a second to log into Network Solutions and make the change. Done and done. My suggestion was about the DNS, I just threw in the 1 line about guest accounts because I didn't want to create a forum account just to ask someone to update the DNS server. I didn't realize that would cause what it did, but it's not a big deal to me. It's your forum, you run it how you want.
  6. Interesting. Just for clarity, surround your variable with curly brackets (and add the single quotes): $insert = $_POST["sortorder{$row['id']}"];
  7. OK, let's back up. Post the relevant HTML and PHP code again.
  8. You can always just use a multidimensional array.$values[$x][$y][$z];Where 0 <= $x <= 80 <= $y <= 80 <= $z <= 3
  9. You could also just configure the server to send html files to the PHP engine, but that would slow down response times slightly for html pages. But you wouldn't have to rename anything.You can also use:include()include_once()require()require_once()Depending on what your requirements are (no pun intended).
  10. Wow, I missed a glaring step. Here's your query: $sql = "UPDATE page SET `sortorder` = '$insert' ORDER BY `id` DESC"; You are missing your WHERE clause, so all rows get updated with the same value (whatever the last value was, all rows will have that value). UPDATE queries also do not have an ORDER BY clause. Here you go: $sql = "UPDATE page SET `sortorder` = '{$insert}' WHERE id = '{$row['id']}'";
  11. You can't use fopen to write a file over http. The http protocol doesn't support that. One thing you can do is to create the file locally first, save it and everything, and then open a ftp connection to the subdomain and transfer it across.Here are the FTP functions:http://us2.php.net/manual/en/ref.ftp.phpYou will use functions in this order:ftp_connect (connect to the server)ftp_login (login to the server)ftp_chdir (change to the subdomain folder)ftp_put (upload the file)ftp_close (close the connection)
  12. There are a few things I would change. First, in your html you call the variable 'sortorder', and in the php you just say 'order'. That's an error.One thing I would change is not to use an array to pass post variables, just separate it with an underscore: echo "<td class='alt2'><input type='text' name='sortorder_{$row['id']}' value='{$row[sortorder]}'></td></tr>"; Which makes this part easy (there are a few changes):page.php?action=order: $sql = "SELECT * FROM `page` ORDER BY `id` DESC";$result = mysql_query($sql) or die(mysql_error());while ($row = mysql_fetch_assoc($result)){ $insert = $_POST["sortorder_" . $row['id']]; $sql = "UPDATE page SET `sortorder` = '$insert' ORDER BY `id` DESC"; mysql_query($sql) or die(mysql_error()); echo "<script type=\"text/javascript\">location.href=\"page.php?show=all\";</script>";}
  13. Is there a question there somewhere that I missed?
  14. It should be safe to change this option.I'm not entirely sure how webservers execute PHP (and each host I'm sure can do it however they want), but changing this should not affect others on the shared host. For security risks, there is only a risk if you make the directory world-readable. Make sure that only your account can access it, not the anonymous web account. Also browse to the directory (in a web browser) and make sure it does not show the contents. If it does, you can always add an empty index.php.You need to change the option every time you use sessions, it will not carry over from one execution of PHP to the next. Each time PHP executes, it loads the options from php.ini, so you will have to change it each time. If you have an include file with configuration options that you use on every page, that would be a good place for it.
  15. Wow.All I can say is this:http://us2.php.net/manual/en/install.windows.manual.phpThere's an entire section of the PHP website devoted to this, it's not something that can be listed in 1 post in a forum.
  16. Well, you can actually dynamically set where session info is stored. This is the ini option:session.save_pathYou can use the ini_get function to see the current value (ini_get("session.save_path")), and you can also use session_save_path to get/set this option:http://us2.php.net/manual/en/function.session-save-path.php (see the comments on that page as well)Just make sure you set the save path before any calls to session_start are made.
  17. Dan is correct, you are sending the javascript code before you send the actual page. You will want to send all of the page information, and display the javascript last (ideally, you will want the javascript to appear before the closing </body> tag, so you may need to indicate an error in message_rep.php, but have message.php or index.php check if an error occurred and actually send the javascript). This is the reason why both the page is blank and the content is misaligned - the browser doesn't know how to handle the javascript code coming first. If you want the popup over the page with the content already on it (not a blank page), send the page first, then send the javascript code.
  18. Hmm.. well, depending on what kind of access you have to the server, you could probably locate the directory where PHP is storing the session information (specified in php.ini), and simply delete all the files. You can go one step further, and get your own session ID, and delete all other files, so that you stay logged in. Of course, you can also just manually delete the files.
  19. I'm not quite sure I'm understanding correctly. I think though that you can only destroy sessions you have created, you don't have access to destroy a session that you haven't created.
  20. What you have: $query = "SELECT * FROM challanges WHERE (challanger = '$user' OR challanged = '$user') AND declined != '$user' ORDER BY id DESC";$result = mysql_query($query)or die(mysql_error());while($row = mysql_fetch_array($result)) {extract($row);echo "<a href='console.php?p=EditChallenges&cid=$id'>$challanger vs. $challanged</a> - $date<br>";} When you make the query, and start the while loop, you are using mysql_fetch_array, which results in $row[0], $row[1], $row[2], etc. If you want $row['id'], $row['challanger'] (btw, it's "challenger") you need to use mysql_fetch_assoc instead. Try this: $query = "SELECT * FROM challanges WHERE (challanger = '$user' OR challanged = '$user') AND declined != '$user' ORDER BY id DESC";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_assoc($result)) { extract($row); echo "<a href=\"console.php?p=EditChallenges&cid={$id}\">{$challanger} vs. {$challanged}</a> - {$date}<br>";} You can also do this: $query = "SELECT * FROM challanges WHERE (challanger = '$user' OR challanged = '$user') AND declined != '$user' ORDER BY id DESC";$result = mysql_query($query) or die(mysql_error());while($row = mysql_fetch_assoc($result)) { echo "<a href=\"console.php?p=EditChallenges&cid={$row['id']}\">{$row['challanger']} vs. {$row['challanged']}</a> - {$row['date']}<br>";}
  21. Also take a look here:http://www.php.net/manual/en/features.file-upload.php
  22. You need a webserver to execute your PHP files and send the result to the browser. When you have your browser visit an address that ends in .php (like you are now), your browser asks the server for that PHP file. The server in turn executes the PHP code, and instead of sending your browser the PHP code, the server sends the browser what PHP tells it to.The easiest thing to do in your case, unless you want to install your own webserver for testing (Windows does include one you can use), and then install PHP on the server, is rent a server online (or find someone willing to let you use theirs). Here's a good host for $2/month:http://geekhosting.com/Then what you have to do is connect to the server through FTP, upload your PHP files, and visit them in your browser. If your site is called mysite.com, and your PHP file is page.php, you would FTP to mysite.com, upload page.php, and then in your browser visit http://mysite.com/page.php to see the result. ASP works the same way, except it only works on Microsoft servers. If you want to learn PHP well, I can recommend this book:http://www.oreilly.com/catalog/progphp/
  23. justsomeguy

    SQL or PHP?

    If you are using MySQL:http://www.php.net/manual/en/function.mysql-error.phpAlso, it would be helpful to describe what happens when you execute the code instead of saying that it doesn't work.
  24. justsomeguy

    PHP Editors...

    Notepad is terrible for coding.I prefer ConTEXT (http://www.context.cx/), but I also like some of the features of PSPad (http://www.pspad.com/). It's hard to beat a logo that features a dog with a butthole.
×
×
  • Create New...