Jump to content

bljepp69

Members
  • Posts

    111
  • Joined

  • Last visited

    Never

Everything posted by bljepp69

  1. You can't nest forms.  You have a form within your form so the closing tag for the nested form is really closing the first one.
  2. This is one way to do it: [code] <?php function latestnews() {         $i=0;         global $db, $max_items;         $query = "SELECT id, title, cat_id, postdate FROM news ORDER BY postdate DESC LIMIT 5";         $result = mysql_query ($query) or die("Problem with the query: $query on line:" . __LINE__ . "<br>" . mysql_error());                 echo '<div class="newscontainer">';                 while ($row = mysql_fetch_assoc ($result)) {                         $postdate = htmlentities ($row['postdate']);                         $title = htmlentities ($row['title']);                         //Display Data                         echo "<div class=\"news1\"><span> <div class=\"left\">$title</div> <div class=\"right\"><a href=\"../UNC/index.php" . "?action=show&id=".$row['id']."\">More</a></div></span></div>";                         $i++;                 }                 if ($i < 5) {                   for ($j=$i;$j<=5;$j++) {                     echo "<div class=\"news1\"><span>Empty</span></div>";                   }                 }                 echo '</div>'; } ?> [/code]
  3. bljepp69

    idk

    You have to use some kind of function to accomplish this.  Check out this post - [url=http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766]http://www.phpfreaks.com/forums/index.php/topic,119892.msg491766.html#msg491766[/url]
  4. Check out this user submission and the ones around it.  Might help. [url=http://www.php.net/manual/en/function.imagecolortransparent.php#48912]http://www.php.net/manual/en/function.imagecolortransparent.php#48912[/url]
  5. The current code returns an image that is 20% of the original size.  So, instead of using the width & height multiplied by this percent, simply state the height and width: [code] $modwidth = 50; $modheight = 50; [/code] However, if you go away from a relative size (like 20%) and only spec in hard numbers for height and width, you might end up with a strange looking thumnail.  So, you can use something like the code below to specify a max height and width for your thumbnail and the actual size is still relative to the original. [code] <?php                     $save = "albums/tn_".$name;                     $file = $path;                     echo "Creating file: $save";                     list($width, $height) = getimagesize($file) ;                     $max_width = 50;                     $max_height = 50;                     //generating smaller image                     $x_ratio = $max_width / $width;                     $y_ratio = $max_height / $height;                     if (($width <= $max_width) && ($height <= $max_height)) {                       $modwidth = $width;                       $modheight = $height;                     }                     else if (($x_ratio * $height) <= $max_height) {                       $modheight = ceil($x_ratio * $height);                       $modwidth = $max_width;                     }                     else {                       $modwidth = ceil($y_ratio * $width);                       $modheight = $max_height;                     }                     $tn = imagecreatetruecolor($modwidth, $modheight) ;                     $image = imagecreatefromjpeg($file) ;                     imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; ?>[/code]
  6. try this in your .htaccess file:  php_flag register_globals off the .htaccess file affects the current directory and any directories below it.  So, putting it in the root will impact the entire site.
  7. If you don't mind having the '?font=bigger' query string on the end of the URL, you can use the QSA (Query String Append) option in mod_rewrite.  So, your link would be:   <a href='/Stories/Read/8/?font=bigger'>Bigger Font</a>     or   <a href='?font=bigger'>Bigger Font</a> You rewrite rule would be:   ReWriteRule ^Stories/Read/([0-9]*)/ story/read.php?id=$1 [QSA] and the URL would look like:   http://www.yoursite.com/Stories/Read/8/?font=bigger Don't know if that's easier or not.
  8. From the manual [url=http://www.php.net/manual/en/faq.misc.php#faq.misc.registerglobals]http://www.php.net/manual/en/faq.misc.php#faq.misc.registerglobals[/url] This will emulate register_globals Off. Keep in mind, that this code should be called at the very beginning of your script, or after session_start() if you use it to start your session. [code] <?php // Emulate register_globals off function unregister_GLOBALS() {   if (!ini_get('register_globals')) {       return;   }   // Might want to change this perhaps to a nicer error   if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {       die('GLOBALS overwrite attempt detected');   }   // Variables that shouldn't be unset   $noUnset = array('GLOBALS',  '_GET',                     '_POST',    '_COOKIE',                     '_REQUEST', '_SERVER',                     '_ENV',    '_FILES');   $input = array_merge($_GET,    $_POST,                         $_COOKIE, $_SERVER,                         $_ENV,    $_FILES,                         isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());     foreach ($input as $k => $v) {       if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) {           unset($GLOBALS[$k]);       }   } } unregister_GLOBALS(); ?>  [/code]
  9. You're missing a '$' in front of 'db_user' and you need to select a database: [code] <?php   require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");   $connection = mysql_connect($db_host, $db_user, $db_password) or die("error connecting");   $db = mysql_select_db("$db_name", $connection) or die("Unable to select database!");   echo "connection made"; ?> [/code]
  10. Basically, you set a session variable after the user logs in.  Something like $_SESSION['logged_in']=1, or you could user their username in a session variable.  In any case, you set the session variable after a successful log in and then you check for the existance of it on the top of the restricted pages.  Like so: [code] <?php   session_start();//required at the top of every page using sessions   if (!$_SESSION['logged_in']) {     header("newlocation.html"); //redirects to a new page     exit; //good practice after a header redirect   } ?> [/code]
  11. Your submit button is named "Submit" but you check for $_POST['submit'] - capitalization matters.  Submit != submit ;)
  12. It's a browser issue.  I just created a test file and looked at it in IE, and it behaved how you described.  But FF simply displayed the name of the file as it didn't know what to do with it. You could do some error checking to make sure users are uploading only image files.  Using getimagesize() is the best/quickest way to validate that it's an image.
  13. You've just missed a little on your variables.  You have this: [code] $results = mysql_query("SELECT * FROM v2_forum_cat ORDER BY id"); while($row = mysql_fetch_array($result)) [/code] You define '$results' but then call '$result'  -- $result is empty so the query fails.
  14. You basically have to use an "onChange" command in your select element to submit the form for processing.  Then you go through the process of figuring out which state they selected and filling the next drop down.  If you don't want to reload the page, you will have to either fill all possible data into variables that are available to javascript and then display them as necessary or use an AJAX method.
  15. All you've done with this code is to set a variable with the contents of your query.  You haven't actually run the query.  Maybe change the last part of your code like this: [code] <?php ... if (!$count) {   $res_query = mysql_query("INSERT into tra_music_top10(artist_id,counter)VALUES('$arstist_id,'1')"); } else {   $res_query = mysql_query("UPDATE tra_music_top10 SET counter='$voted'"); } if (!$res_query) {   //there was an unsuccessful query, so you could display a custom message here or use mysql_error() } else {   //you actually don't need the else, but you could use this for a "success" message } ?> [/code]
  16. Use this method: [code] foreach ($arr AS $item) {   //do whatever to $item } [/code]
  17. Change your variable calls to: $_POST['message'] $_POST['name'] $_POST['subject'] $_POST['email'] and see if that works
  18. You've made the variables in the first script 'global'.  They are still only available in the first script.  To make a variable part of a session, you would need to define it like this: $_SESSion['first'] $_SESSION['news_prefs'] etc. Session variables are, by definition, super globals so you don't need to specify global when you define them this way.
  19. I think this will work: [code] SELECT * FROM table WHERE logged_date >= '$shellys_log_date' && logged_time >= '$shellys_log_time' [/code] mySQL has very good date/time handling capabilities
  20. I suspect that the way you've set up your db table is the issue.  From the error message it looks like you are trying to write the same information to a field that is set to be unique.  Make sure the the named fields are not set to be primary or unique.
  21. You can't reverse the md5() information.  So, I think a good solution in your case is to frist validate which user forgot their password and then send them to a 'change password' page.  Since you already have their email address, you can simply send them an email with a link to the change password page.  The link can contain some encoded information about the user so you can verify it's them returning.  Then, they change their password and move on.
  22. You should be able to just add a 'break' statement: [code] <?php        for ($i = 1; $i < $n; $i++) {                if ($streak[0] == $streak[$i]) {                        $streaklength++;                } else {  // i want to exit the for loop and stop but i don't know how                        break;                }        } ?> [/code] Then check the value of $streaklength
  23. you can add this debug code to the top of your page to see what you are actually carrying in the $_POST variables: [code] <?php   echo "POSTS:<pre>".print_r($_POST,TRUE)."</pre>"; ?> [/code] I'm also thinking that the extra spaces you have in the 'option' elements for the values might be causing some problems.  Maybe the different browsers handle those differently and then what you are comparing to the db doesn't work.
  24. In the form code submitted above... The 'select' and 'submit' form elements are both named 'state'.  I'll bet the two browsers are treating this a bit differently and submitting different values.  Change the name of your 'submit' element.
×
×
  • 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.