Jump to content

dannyb785

Members
  • Posts

    544
  • Joined

  • Last visited

Posts posted by dannyb785

  1. ^^ did you even read his question? He said that he uses stripslashesand it messes things up.

     

    I dont know how the text is when you're inserting it in the database, but it needs to be like this... don't do anything do it(except addslashes) when inserting. Don't give it entities or anything. When displaying the data, do stuff to it just before outputting it.

     

    Like for example:

    while($row = mysql_fetch_assoc($result))
    {
      extract($row);
      $text = htmlentities($page_data);
      echo $text;
    }
    

     

    And if you're putting the data into a textarea or input field, you don't need to do anything to it

    while($row = mysql_fetch_assoc($result))
    {
      extract($row);
      echo "<textarea rows=5 cols=5 name=whatever>$text</textarea>";
    }
    

     

    I never use stripslashes.. ever. If you need to use them, then you've been adding slashes when you don't need to.

     

    I think you may have magic_quotes on. When that's on, it adds slashes automatically. And then if you try to remove slashes, it will find "\n" and make it "n"

  2. I'm pretty sure you'd need to change your .htaccess file to convert something like domain.com/1234 to domain.com/view.php?code=1234 kinda like myspace. I don't think it's something you can do just entirely in html without anything else.

     

    Once the .htaccess file is modified, you can do what was said where you'd have a form with a GET method

  3. I don't use xml all that much, but I'd say when you have the color variable ready(with all the colors separated by ;), do a $temp = explode(";", $colors) and then step through each variable, printing a <color> tag for each. Remember to ignore the last one though, since it will be blank(since there's nothing on the right side of your last semicolon)

  4. Good design guidelines is make your entire page's width set at 800(maybe 850 if you have to). Because there are still lots of people who have older computers and can't view pages with 1000px wide setups without side scrolling(in web design, side scrolling == bad). Even those with 1024x768 can view it easily and if people have those crazy big resolutions(1600 or higher) they are likely already used to most sites looking small. But making 2 pages for each resolution(even if you can do it) isn't a good idea.

     

    But if you absolutely have to, I'd say have a splash page(a HUGE web design no no) that says "What resolution are you?" and they click accordingly. And then have a "I dont know" link and go to the 800x600 layout since if someone doesnt know their resolution, they probably have an older computer(just my guess).

  5. I have no idea where you got your code from. When I do zebra stripes, it's unrelated to the query's array. I do...

     

    $n = 0;
    while($row = mysql_fetch_assoc($result))
    {
      extract($row);
      if($n%2 == 0) $bgcolor="whatever color";
      else $bgcolor="other color";
      echo "<td bgcolor=$bgcolor>text</td>";
    
    }
    

     

    and modify as needed. This is provided you only need alternating colors. If you're looking for different colors based on the content, let us know.

  6. I dont think you can do 2 separate queries at the same time. Just split them up into 2.

     

    And I dont think <> is a valid checker. do '!=' (not equal to)

     

     

    also, add single quotes around the variables(like "where id='$id', not "where id=$id")

     

    and also, on your die statement after a query, make it "or die(mysql_error());" that'll help you with what the problem is.

     

    And I'm confused with "UPDATE ".$db_prefix."sportsdb_conferences" what is db_prefix? I dont see it declared as anything. I don't think you need multiple different tables for this kind of thing.

  7. The problem with telling him to just use htmlentities is that he probably doesn't know why it works.

     

     

    Takamine, html tags display as they are supposed to when "<anything>" is types. Anytime html sees a "<" it won't print anything out until after a closing ">" is printed, and then it makes whatever changes are needed til is sees a closing "</whatever>" tag. So for you to print a < without it thinking it's an html tag, you'll need to type out the assosicated 'entity' code for it.

     

    For example, ya know how if you type 5 space between words, it doesnt care and only adds one space? Well, the space entity code is ' ' so if you want 5 spaces, you need to type 5  's or else it won't print them. Now, the easy way to add entities is as suggested, with the htmlentities function. But if you dont' want to have to to that all the time, you can do the entity code for the < and > which is < and >, respectively. An easy way to remember is all entities starts with a & and end with a ;. And with these 2, you have a 'greater than' sign and a 'less than' sign. Hence, < and > There is an entity for (I think ) every character that needs to be displayed literally on the page.

     

    Hope that made sense.

     

    Hope that made sense.

  8. Ok I have bolded the errors or things you need to fix

     

    <?php
       include("configuration.php");
          if (!($db = mysql_pconnect($hostname, $username , $password))){
             die("Can't connect to database server.");
          }else{
             // select a database
             
             if (!(mysql_select_db("$database",$db))){
                die("Can't connect to database.");
             }
          }
          
          $result = mysql_query("SELECT * FROM Assignment");
    
          $num_rows = mysql_num_rows($result);
          
          $i = 0;
          
          echo"<table width="100%" border="0">";
          echo"<tr>
                   <td>[b]$nbsp;[/b]</td>
                   <td>Assignment ID</td>
                   <td>Title</td>
                   <td>School ID</td>
                   <td>Description</td>
                </tr>";
                
          while([b]$row = mysql_fetch_array($result)[/b])
          {
                $query = "Select * from Assignment where AssnID = [b]'$i'[/b]"; // you need single quotes around the variable
                                    $result = mysql_query($query);
               ;
             echo"
                <tr>
                   [b]<td>$row['column_name']</td>
                   <td>$row['column_name']</td>
                   <td>$row['column_name']</td>
                   <td>$row['column_name']</td>
                   <td>$row['column_name']</td>[/b]
                </tr>   
             ";
             [b]$i++[/b]
          }
          echo"</table>";
       ?>
    

     

    EDIT: well, apparently it won't bold if the text is in code tags. Oh well, look for the [ b] tags

  9. you need to do the error function as:

     

    $result = mysql_query("QUERY") or die(mysql_error());
    
    that should show the error

     

     

    also, when you get the blank page, view the source and see if anything is printing. Like the </table> tag that  you have set to output whether $r is true or not. If it does display, then there's an error grabbing the data. If it's blank, then you have error in the code.

×
×
  • 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.