
bljepp69
Members-
Posts
111 -
Joined
-
Last visited
Never
Everything posted by bljepp69
-
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.
-
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]
-
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]
-
stripslashes()
-
PHP (GD) created transparent PNG and Microsofts AlphaImageLoader
bljepp69 replied to martinvie's topic in PHP Coding Help
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] -
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]
-
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.
-
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.
-
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]
-
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]
-
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]
-
Your submit button is named "Submit" but you check for $_POST['submit'] - capitalization matters. Submit != submit ;)
-
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.
-
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.
-
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.
-
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]
-
Use this method: [code] foreach ($arr AS $item) { //do whatever to $item } [/code]
-
Change your variable calls to: $_POST['message'] $_POST['name'] $_POST['subject'] $_POST['email'] and see if that works
-
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.
-
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
-
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.
-
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.
-
help, finding consective elements in an array
bljepp69 replied to jdubwelch's topic in PHP Coding Help
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 -
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.