Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. Usually "Book#" applies to the workbook and "Sheet#" applies to each worksheet.The syntax is fine, the error is not about syntax, the error says it can't find "Book1".
  2. 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"
  3. 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.
  4. Book1 is the filename of the Excel workbook you want to use. If it's not called Book1, then use the correct name.
  5. 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.
  6. 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?
  7. 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.
  8. 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?
  9. I answered this in the other place you posted it.
  10. This tag does not have an </li>: <li class="mobile"><a href="tutorials.php" title="A list of avaliable tutorials at avant information Services">Tutorials</a>
  11. File upload. If you upload a file, enctype must be multipart/form-data.
  12. You can also put the password in quotes and make sure you escape any quotes that are in the input.
  13. 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?
  14. 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; ?>">
  15. 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.
  16. justsomeguy

    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>
  17. You can probably just add a check for .txt: If UCase(Right(ObjFileItem.Name, 4)) <> ".ASP" and UCase(Right(ObjFileItem.Name, 4)) <> ".TXT" Then
  18. 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.
  19. You can open the file and count the number of line breaks if you want. Or if you only want to know how many lines there are of text you can exclude all of the sequential line breaks.
  20. justsomeguy

    Log in

    Try this one, the ID was wrong. This uses the same id that is in the cookie. <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 if (!$_COOKIE['id']){ echo "<a href=\"signup.html\">Register</a>"; echo " "; echo "<a href=\"login.html\">Log In</a>"; die(""); } echo "Welcome - "; ?> </td> <td width="212" height="19"> <?php // 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)) echo $r["username"]; ?> </td> <td width="212" height="19"> </td> <td width="214"> </td> </tr></table>
  21. justsomeguy

    Log in

    It looks like you took out there WHERE clause in the SQL statement. Use the same SQL statement you had the first time when you search for the ID. Also, it is a good idea to make sure you escape any text strings going into a query: $result = mysql_query("SELECT * FROM `users` WHERE `id` = '".mysql_escape_string($u)."' LIMIT 1"); It helps prevent something called SQL injection. You also don't need the LIMIT 1 here (you can probably assume there is only 1 user with the ID).
  22. That almost sounds like a homework question.It depends, if you are talking about an HTML line break, then it's "echo $var1 . "<br>" . $var2;", if you are talking about a newline character, you can write "echo "{$var1}\n{$var2};".
  23. What exactly is Firefox explorer? There's Internet Explorer, and there's Firefox. Is it one of those (Help -> About should tell you what you're using)?
  24. That's cool. It scrolls a little with Opera though.
  25. No, the only way to do that is via javascript. Once the window is open, it doesn't matter what your code says after the fact.
×
×
  • Create New...