Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Posts posted by justsomeguy

  1. I know what you're saying, but eating with my feet doesn't make me appreciate my hands any more. It just makes me feel like a dirty ###### for eating with my feet.Edit: Please don't use bad language, we have members a young as 10 and 11 years old.Edit edit: I didn't realize the term for a son who doesn't know who his father is was considered bad language. Sorry.Edit Edit Edit: Well, it could be used that way, but then there's another application, and most young users will think of that. Plus the forum beeps it out anyway, and doesn't care how you've used the word. Thanks. ( I like edit contests :))

  2. Right - so you count the number of line breaks, and add one.This file:

    line1\nline2\nline3

    Has 2 line breaks, and there are three lines. Count the number of line breaks. You can explode the string on a newline and count the number of array elements, use substr_count to determine how many there are, or just walk through the string and count up the newlines. However you want to accomplish it, that's what you do, I'm telling you.

  3. You should be able to keep track of their order in a cookie, and then when they actually pay clear out the cookie. That way if they go back, they won't have an order in the cookie.But a programmer has to draw the line somewhere. If a user wants to keep hitting back and charging himself over and over, that's not really your problem. Just make sure that hitting back alone will not charge the user, there needs to be another step. From the time they get charged to when they see the results, have it go through a third page in the middle that redirects them to the result page. That way if they are on the result page and hit back, they go to the middle page, not the charge page.

  4. Also, tables have to be completely downloaded in order to be displayed while <div>s are displayed immediatly when they are closed
    That's not entirely true, it depends on the browser. Opera, for example, will render things as it receives them. If I have a large, dynamic table being filled in, Opera will render the table as the code comes through, it won't wait until it has everything. IE, on the other hand, will only render the page once it has all the data, regardless of if you're using a table or a div.One other thing I don't like about CSS layouts is the rendering performance. When I have to render a heavy CSS page, using most browsers, scrolling especially will not be smooth at all, it looks clunky like it has to constantly calculate positions, etc. That's one major benefit of tables: they have had browser support since very early on, and as a result they work well today. One major beef I have with the people designing CSS is they seem to think that the whole web should be made of div boxes starting in the upper-left corner. Support for centering (horizontally and vertically), aligning page content on the bottom of the screen (footers) etc is sorely lacking.
  5. I'm not sure what you are working with there. This is the error message:The Microsoft Jet database engine could not find the object 'Book1$'. Make sure the object exists and that you spell its name and the path name correctly.This means that it is looking for something called "Book1" that could not be found. I assume that applies to the XLS file. If you need more help, you probably need to look up a reference for using SQL queries with office, look up help on the openrowset function.

  6. Of course it's possible, you can run anything you want. If this is the code:$id = $_GET['id'];$sql = "SELECT * FROM table WHERE id=$id";Consider this:page.php?id=0%3BDELETE%20FROM%20table%20WHERE%201the query becomes:$sql = "SELECT * FROM table WHERE id=0;DELETE FROM table WHERE 1"

  7. There's a big difference between a recommendation and a requirement. There's no programmatic way to tell if the content a table is displaying is an Excel sheet or not. I would hardly say it's a violation of the spec to use a table to layout a page if you want to make sure the page looks right. I wouldn't say that divs are easier to read in the code. All it takes is one guy who doesn't know what he's doing to put floating divs all over the page, and then you get source code where the items appear in code in a different order than they do on the page. And we can tell from all the posts in places like this that it is not easy to get your divs to look the way you want them across browsers.It seems like the argument is that you can either have easier maintainability through stylesheets with divs, or you can have it actually work with tables.

  8. PHP handles database connections totally different than ASP does. But this depends on which database you are using. If you are using MySQL:

    <?php$cid = $_GET['cid'];mysql_connect($database_server, $database_user, $database_password);mysql_select_db($database_name);$sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID='" . mysql_escape_string($cid) . "'";$result = mysql_query($sql);echo "<table>";while($row = mysql_fetch_assoc($result)){  echo "<tr><td><b>".$row['name']."</b></td>";  echo "<td>".$row['value']."</td></tr>";}echo "</table>";?>

    You also need to protect against SQL injection, it is a terrible idea to take things directly from GET or POST and use them in database queries (that's the point of the mysql_escape_string function above). That's a great way to allow someone to delete your entire database.

  9. Why don't you just use a table? Is there some reason that everyone is on a CSS div kick? This is exactly what tables do, they display content that is all the same height, and they have been doing it for years in every browser. What's the problem? Is there some inate fuzzy feeling that happens when you don't use a table?

  10. I use ConTEXT for everything. There's no reason to use Notepad when there are all these free text editors around. Notepad is terrible. If it had syntax highlighting (or at a very, very minimum, auto-indenting) I guess I would consider it, but all Notepad does is write text. It wastes a lot of time by not helping the programmer out with auto-indent or highlighting. ConTEXT also has code templates so that you can paste in commonly used blocks of code. I keep the ConTEXT installer on my keychain, never know when I might need it.

  11. I don't know why they want to get rid of the style attribute. Sometimes inline styles are a good way to go, they are messing with the cascading nature of CSS when they remove that. Styles are applied in this order:Browser defaultExternal style sheetInternal style sheet (inside the <head> tag)Inline style (inside an HTML element)So they want to remove the last one, and screw up the cascading order? So if we want one element with different style, it needs its own class?

  12. You can use meta tags to set the expire date for each page to an earlier date, and it would force the browser to get the page each time (no caching). But different browsers do Back differently. Things like Opera just load the page that's already in cache and display exactly what you were looking at, but IE tries to reload the page generally. What are you trying to accomplish?

  13. You need quotes around the attributes. Ideally, all of your attributes should have quotes around them. Do either of these:

    <?php echo "<input type=\"hidden\" name=\"message\" value=\"{$StartText}\">";?>

    <input type="hidden" name="message" value="<?php echo $StartText; ?>">

  14. You need this for your post page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title></head><body><?phpif(isset($_POST['add'])){  include 'library/config.php';  include 'library/opendb.php';  $username = $_POST['username'];  $post = $_POST['post'];  $result = mysql_query("SELECT userid FROM houndusers WHERE username='" . mysql_escape_string($username) . "'") or die(mysql_error());  if(mysql_num_rows($result) == 0)  {    mysql_query("INSERT INTO houndusers (username) VALUES ('$username')");    $userid = mysql_insert_id();  }  else  {    $row = mysql_fetch_assoc($result);    $userid = $row['userid'];  }  mysql_query("INSERT INTO houndposts (post, userid) VALUES ('" . mysql_escape_string($post) . "', '{$userid}')") or die('Error, insert query failed');  include 'library/closedb.php';  echo "New Post Added";}else{?><form method="post" enctype="multipart/form-data"> <table align="center" cellspacing="15">   <tr>     <td align="left" valign="top">Username: <input name="username" type="text" id="username"></td>   </tr>   <tr valign="top">     <td align="left">Post:<br /> <br /> <textarea name="post" type="textarea" cols="75" rows="10" id="post"></textarea></td>   </tr>  <tr align="center">     <td valign="top"> <input name="add" type="submit" id="add" value="Add New Post">         <input name="Reset" type="reset" value="Reset">     </td>   </tr> </table></form><?php}?></body></html>

    Look at the differences between that one and yours, you can look on php.net for help about the functions used or ask about them here.To order a result set, you need an 'ORDER BY' clause, where you tell it what to order on. If you want to order by user id, you say 'ORDER BY userid'. If you want to order by username, it's 'ORDER BY username'. You can put ASC or DESC after that. So something like 'ORDER BY username DESC'. ORDER BY goes at the end of your SQL statement.

    Log in

    Yeah, of course. You should think of your page in terms of sections, or boxes. You probably have a top header or something, which never changes from page to page or if you're logged in or not. Then maybe you have a box on the left side, where you have your page menu. That's another box. Then you have the main page content itself, and maybe a box somewhere to handle the login/welcome stuff. Each of these is its own box, or section.It sounds like you have everything else working, except the login box will kill the page if the user is not logged in. That's just because you threw in a "die()" in the code if they are not logged in, the die function stops page execution at that point. All you need to do is restructure the page to remove the die, which will require an if/else statement (you already have the 'if' part).I pasted the code below. All I did was take the last code I posted above, and I restructured it a little. The way the code works now, is that it builds a message based on if the user is logged in or not (the message is either a login form or a welcome message), and then displays that one message in the spot where it goes.

    <table width="700" height="100" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#00FF00">  <tr>    <td height="81" colspan="4" background="images/header-700-81.jpg"> </td>  </tr>  <tr>    <td width="62" height="19"><?php$msgbox = "";if (!$_COOKIE['id']){  $msgbox .= "<a href=\"signup.html\">Register</a>";  $msgbox .= "  ";  $msgbox .= "<a href=\"login.html\">Log In</a>";}else{  $msgbox .= "Welcome - ";  // Connect to the database  $server = "localhost";  $dbuser = "user";  $dbpass = "pass";  $dbname = "bd_name";  mysql_connect($server,$dbuser,$dbpass) or die ("connection error"); // make connection  mysql_select_db($dbname); // select database  // Get users information  $result = mysql_query("SELECT * FROM users WHERE id='".mysql_escape_string($_COOKIE['id'])."'");  $r=mysql_fetch_assoc($result);  $msgbox .= $r["username"];}echo $msgbox;?>    </td>        <td width="212" height="19"> </td>    <td width="212" height="19"> </td>    <td width="214"> </td>  </tr></table>

  15. You need to create a table in the database to hold all of the user information. You need to figure out which fields you want to keep track of, and put all of the fields in the database. You probably want your password field to be 40 characters wide so you can encode passwords with either MD5 or SHA-1. You need to write a register page that collects all of the information and makes sure everything is right, and then inserts the user in the database. Then you need a login page to check with the database if the correct user name and password were entered, and keep track of the user using the session (cookies).Check the references for ASP to learn how to connect to and query the database.

×
×
  • Create New...