
doni49
Members-
Posts
515 -
Joined
-
Last visited
Everything posted by doni49
-
What will happen when there is more than one user logged on?
-
PHP - Displaying Images From Folder, With Most Recent First
doni49 replied to Steve1's topic in PHP Coding Help
Sorry. I missed an equal sign: $sortedimages[]$filetime => $image; I really don't see how the if & while statements can actually work as you've got them shown. Maybe someone else can explain that? -
PHP - Displaying Images From Folder, With Most Recent First
doni49 replied to Steve1's topic in PHP Coding Help
Try this on for size. This goes AFTER the while loop that creates the $images array (list of image filenames). <?php foreach ($images as $image) { $filetime = filemtime("images1/$image"); $sortedimages[]$filetime => $image; } krsort($sortedimages); echo "<pre>"; print_r($sortedimages); echo "</pre>" ?> Edit: the biggest change I made was to use krsort which is described at the following URL: http://us.php.net/manual/en/function.krsort.php -
PHP - Displaying Images From Folder, With Most Recent First
doni49 replied to Steve1's topic in PHP Coding Help
I'm still looking thru your code to see if I can find answers to your specific questions. But in the meantime, I did notice a few things to comment on. 1) Is this code copy/pasted directly from your php file? If so, I don't see how it could actually be working. I don't see any curly braces following the if statement or the while statement. //List files in images directory while (($file = readdir($dir)) !== false) if (!in_array($file, $ignore)) 2) Rather than testing the current "file" to see if it's the current or parent folder, you could use the is_file function. Besides even if it's not the current or parent folder, that doesn't mean it's not a child folder. http://us.php.net/manual/en/function.is-file.php -
What do you mean "insert"? Into a database or for outputting in the browser?
-
I created a folder outside of the publicly accessible area for php files that include sensitive info such as DB passwords. Then when I need to, I just include the file. By doing this a web user will not be able to read the file with the sensitive info.
-
I don't know what you mean by "name" here, but if you're asking how you should name the fields, I'd probably use either the row number or the ID number. If you're asking how to get the value of one of these fields from within the next page then the code you posted ($orno= $_POST['orno'.$y] won't do it because $y won't have any value. Are you going to run through the loop again in the second page?
-
I can't go through your code right now. But I do something similar to what you're asking for with my contact page. It loads the contact page and posts the form to the same php script. If the user submitted the form, the variable $_POST['submit'] will be set. If the form HAS been set, then the script checks each field. If there's an error in one of these fields, it appends a message about the error to the variable named $errorMsg. Then if the form has been submitted OR the $errorMsg variable is not blank, then it shows the form again. And if the $errorMsg is not blank, it displays it. If the form HAS been submitted and the $errorMsg variable is blank, it sends the message to me and thanks the user for the message. <?php if (is_set($_POST['submit'])){ // Check for a first name. if (eregi ("^[[:alpha:].' -]{2,50}$", stripslashes(trim($_POST['first_name'])))) { $fn = escape_data($_POST['first_name']); } else { $fn = FALSE; $validForm = false; $errorMsg .= '<p><font color="red" size="+1">Please enter your name.</font></p>'; } $email = true; // Check for an email address. if(!empty($_POST['email'])){ if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))){ $e = escape_data($_POST['email']); } else { $validForm = false; $errorMsg .= '<p><font color="red" size="+1">Please enter a valid email address.</font></p>'; } }else{ $email = false; } // Check for a subject. if (!empty($_POST['subject'])) { $u = escape_data($_POST['subject']); } else { $u = FALSE; $validForm = false; $errorMsg .= '<p><font color="red" size="+1">Please enter a valid subject.</font></p>'; } } ?> <?php if(!is_set($_POST['submit']) || $errorMsg <> ""){?> <html> <title>Contact Page</title> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table> <?php if($errorMsg<>""){echo "<tr><td colspan=2>" . $errorMsg . "</td></tr>";?> <tr> <td align="right"><b>Name*:</b></td><td><input type="text" name="first_name" size="50" maxlength="15" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name'];?>" ></td> </tr> <tr> <td align="right"><b>Email Address*:</b> </td><td><input type="text" name="email" size="50" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" > </td> </tr> <tr> <td align="right"><b>Subject*:<b></td><td><input type="text" name="subject" MAXLENGTH="50" SIZE="50" value="<?php if (isset($_POST['subject'])){ echo $_POST['subject']; }elseif(isset($_GET['subject'])){ echo $_GET['subject']; } ?>"></td> </tr> <tr> <td align="right" valign="top"><b>Comments:</b></td><td><TEXTAREA name="msgBody" ROWS=10 COLS=40><?php if (isset($_POST['msgBody'])) echo stripslashes($_POST['msgBody']); ?></TEXTAREA></td> </tr> <tr> <td colspan="2"><div align="center"><input type="submit" name="submit" value="Submit"> <input type="reset" name="reset" value="Start Over" /></div></td> </tr> </table> </form><!-- End of Form --> </body> </html> <?php }else{ //I have php code that sends the email message to me. That goes here but I've left it out because it doesn't pertain to this request. After sending the message, it displays the thank you page based on the following. ?> <html> <title>Thank you</title> <body> Thank you for taking the time to contact me. I'll be in touch with you soon. </body> </html>
-
Getting image link to be the only way to access a page
doni49 replied to byrne86's topic in PHP Coding Help
The link you're creating needs to have a code that changes with each click and needs matched against code in the destination page. Try something like the following. generateCode(){ $possible = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $code = ''; $i = 0; while ($i < 40) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; } If (is_set($_SESSION['access']) && is_set($_GET['accesscode'])){ if($_SESSION['access'] == $_GET['accesscode']){ //code to display the first page }else{ //code to display the requested page } } //no matter what page you're on, you'll need the following code $accesscode=generateCode(); $_SESSION['access'] = $accesscode; echo ('<a href="page.php?accesscode=' . $accesscode . '">Next page</a>'; -
Is this code copy/pasted directly from your php file? If so, it should be throwing errors. The echo statements don't have dollar signs in front of the vars. echo(udatedValue); Should be: echo($udatedValue);
-
<?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> www.php.net/header
-
No prob. Glad to help.
-
I assume you meant that you only want to "ignore" the negative by just echoing 75. Assuming that's the case, then convert the negative number to a positive and echo that value: $val = 150 - 225; $val = abs($val); echo $val; The abs function converts a positive to a negative. See the following: www.php.net/abs
-
I'm not totally sure I understand what you're asking. But I *THINK* I do. You're having trouble wrapping your head around the idea of tying the children to the parents? You could have ONE table called forums. Each forum would have a column called parent_id. If it's a top level forum (it's not a child) then it's parent_id would be 0. Each forum would have another column simply named ID. Then when defining the children, each one would continue to have unique id numbers in the ID column. The parent_id column would just list the "id" of it's parent. Try this: IDNameDescriptionparent_id 1TopLevel1The first of many top level forums0 2TopLevel2The second of many top level forums0 3TopLevel3The Third of many top level forums0 4ChildLevel1-1The first child of the first top level forum1 5ChildLevel1-2The second child of the first top level forum1 6ChildLevel2-1The first child of the Second top level forum2 HTH and good luck!
-
Edit: Sorry I didn't notice the reply you already received. I don't know what to tell you. I just tried the following code (I changed the time/timezone to match what it is here now) and it shows as expired. And the dates and times being reported are accurate. date_default_timezone_set("America/Chicago"); $drawH = 23; $drawMi = 10; $drawM = 11; $drawD = 15; $drawY = 2010; $cutoffT = 4; $tm = time(); $drawT = mktime($drawH, $drawMi, 0, $drawM, $drawD, $drawY); if($drawT-time() < $cutoffT*60) { echo "Time Expired.<BR><BR><BR>"; } $tk = $drawT;//-time(); echo $tk . "=" . date("h:i a m/d/y",$tk) . "<br><br>"; echo $tm . "=" . date("h:i a m/d/y",$tm);
-
Also--I just loaded your page in my browser and didn't get any errors. Does the error happen after submission? EDIT: I just went ahead and tried submitting the form. I get the same error message.
-
Is the code you posted above the entire contents of the one mentioned in the error message?
-
The ONLY file we need to see is the file mentioned in this error message.
-
I just compared your MySQL code to what I've used on my own site (my code is working for me). Try putting single quotes around the $nid variable: mysql_query("SELECT * FROM news where nid='$nid'")
-
This may or may not be the issue. But it would certainly make it easier to follow what you're doing. Try passing your list of variables as an array: $vars['MESSAGE'] = "This is my message"; $vars['LOCATION']= $URL; $vars['DURATION']=$duration; $vars['PHP_SELF']=$php_self; Then you don't have to worry about trying to explode the string out into an array.
-
My best advice would be to NOT try and create actual files on the fly. Store the variable info into a DB and then later each page that needs to use this CSS info would just include it directly on the page. It's what PHP sends to the browser that is important.
-
PHP Email - Getting Undelivered Mail Returned to Sender
doni49 replied to DBookatay's topic in PHP Coding Help
Nothing stands out for me. Start troubleshooting by setting $to to a specific address right above the line that runs the mail command. Once you confirm whether or not that works, someone might be better able to help. -
Ok that answers that part but take a look at the other two issues that I pointed out. Those are the only things that I picked up on. There MAY be other issues.
-
[SOLVED] finding the biggest needle in haystack
doni49 replied to Heylance's topic in PHP Coding Help
With the following $city_name will contain the longest string. <?php $l = 0; foreach($city_list as $city){ if(strlen($city) > $l){ //if $city is longer than $l change $l to the length of $city //and set $city_name to $city $l = strlen($city); $city_name = $city; } } ?> EDIT: What do you want to do if there is more than one city with the same length--and it happens to be the longest length in the list? -
The line via which you set the recipient looks like this: $email_to = "[email protected]"; But the line in which you attempt to send the message looks like this: mail($emailTo, $emailSubject, $emailBody, $emailHeader); You're also doing something strange with that switch statement--I really don't think it'll do what you expect. $emailTo = switch($_POST['Recipient'] Lastly, I don't see where you attempt to have multiple recipients as your post indicated you want to do. $emailTo = "[email protected]"; $emailTo .= "\[email protected]"; mail($emailTo, $emailSubject, $emailBody, $emailHeader);