Originally posted by Kudose
Took me from your post time, to now to: download, install, and play with UltraEdit. Then uninstall it.

I couldnt get it to change my colors on syntax.

Oh well.

😃

Did you go to Menu->View->View AS (highlighting file type)->PHP ? If you open a file with a recognised extention then UltraEdit knows what syntax to highlight, but if you just start coding then it could be anything, C, PHP, VB, Java, etc so how can it choose the correct syntax form? Have another go.

PS It even has the facility for you to add another language's highlighting syntax extention to the 9 that included in the package. Cool huh?

    Originally posted by Kudose

    if (($_FILES) && ($_FILES['imagefile']['size']<=75000)){ 

    I double sized it.

    :queasy: [/B]

    I added your code and this is what I got:

    Error :: Image was not moved.Unable to create record.

    This happens when I try to add a new image, as well as when I don't. I'm gonna check this out.

    To Roger:

    As far as text editors go, I have the infamous Dreamweaver program, but I don't think it auto-indents, which would be really nice. And yes, I want to get into programming more, so I might check out that other editor. For the last 8 years, I've been doing pretty much front-end work, with the odd editing of some php code and open-source installs. I've only done a tiny bit from skratch. That said, I really gotta learn this stuff pretty much from the ground up.

    Thanks for the recommendation.

      Is it possible to get rid of the denver bronco poo looking syntax coloring?

        Okay, I tested it some more and here's the scoop:

        If I change the text, but not the image, it works, however, I still get the aforementioned error.

        If I try to change the text and image, only the text will change, plus I get the error.

        If just try to change the image, it won't work, plus I get that error. Hmmm.

          Never occured to me. Can't say as I've seen such an option, but then there are so many that I'm still discovering things after 6 months with this version. I suppose you're not a Broncos fan eh?

            Try this:

            <?php
            include 'DL_Config.php';
            
            function newImage($image, $path, $maxsize, $img_prefix){
            		$this->path = $path;
            		$this->image = $image['name'];
            		$this->maxsize = $maxsize;
            		$this->image_tmp = $image['tmp_name'];
            		$this->image_type = $image['type'];
            		$this->img_prefix = $img_prefix;
            		$this->image = $this->img_prefix."_".$this->image;
            		$this->image = str_replace(" ", "_", $this->image);
            
            	if(!@is_dir($this->path)){
            		$msg = "Specified path is not a directory. Specified Path = (".$this->path.")";
            		return $msg;
            	}
            
            	if(@file_exists($this->path.$this->image)){
            		@unlink($this->path.$this->image);
            	}
            
            	if(@is_uploaded_file($this->image_tmp)){
            		if(@in_array($this->image_type, $this->allowed) !== FALSE){
            			if($this->image->size > $this->maxsize){
            				$msg = "File is too big.\n\nMaximum size is: ".$this->maxsize."\n\nYour file was: ".$this->image->size;
            				return $msg;
            			} else {
            
            				if(@move_uploaded_file($this->image_tmp, $this->path.$this->image)){
            					$msg = "Image uploaded";
            					return $msg;
            				} else {
            					$msg = "File was not moved from it's temporary location.";
            					return $msg;
            				}
            			}
            		} else {
            			$msg = "File type \"".$this->image_type."\" is not supported.";
            			return $msg;
            		}
            	} else {
            		$msg = "File was not uploaded to be moved.";
            		return $msg;
            	} // end if file is uploaded
            
            //end Travis' function
            
            if ($submit){
                // Grab form data...
                $title = mysql_real_escape_string($_POST['title']);
                $text1 = mysql_real_escape_string($_POST['text1']);
                $text2 = mysql_real_escape_string($_POST['text2']);
                $newsid = $_POST['newsid'];
            
            if (!$title){
                @unlink($_FILES['imagefile']['tmp_name']);
                echo 'Error: News title is a required field. Please fill it.';
                exit;
            }
            
            // ****************** CHECK IMAGE FILE SIZE AND TYPE SECTION ************
            
            // Check file size...
            		if($_FILES){
            				newImage($_FILES['imagefile']['tmp_name'], "/home/username/public_html/", 75000, "");	
            				@mysql_query("UPDATE news SET image='".$path."' WHERE newsid='".$newsid."'") or die("Could not upload image."); 
            		}
            
            
            // ****************** UPDATE SECTION ************
            
                 // UPDATE News table...
            $sql = "UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid'";
            
             @unlink($_FILES['imagefile']['tmp_name']);
            
             if (@mysql_query($sql) !== FALSE){
                // Success!
                echo '<meta http-equiv="Refresh" content="3;url=DL_Index.php">';
                echo "<br><b>UPDATED!<br>You'll be redirected to the Admin Area in a couple seconds...Hold tight!";
            } else {
                // Failure!
                echo '<br>Unable to create record.';
            }
            
            // ****************** END UPDATE ************
            
            // ****************** SELECT SECTION ************
            
            } elseif($newsid) {
                    $sql = "SELECT * FROM news WHERE newsid='$newsid'";
                    $res = mysql_query($sql) or die(mysql_error());
                    while($myrow = mysql_fetch_assoc($res))
                         {
                            $title = $myrow["title"];
                            $text1 = $myrow["text1"];
                            $text2 = $myrow["text2"];
                            $image = $myrow["image"];
            
            // ****************** END SELECT ************
            ?>
            
            <html>
            <Body>
            <p class="ParaTitle">Add News Article</p>
            
            <!-- Edit Record Form -->
            
            <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
            <input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>">
            <table width="600" border="0" cellspacing="0" cellpadding="0">
            <tr valign="top">
              <td>Title:</td>
              <td><input name="title" size="40" maxlength="255" value="<? echo $title; ?>"></td>
            </tr>
            <tr valign="top">
              <td>Image:</td>
              <td><input type="file" name="imagefile" value="<? echo $image; ?>"></td>
            </tr>
            <tr valign="top">
              <td>First Paragraph:</td>
              <td><textarea name="text1"  rows="7" cols="50"><? echo $text1; ?></textarea></td>
            </tr>
            <tr valign="top">
              <td>The rest of the article:</td>
              <td><textarea name="text2" rows="10" cols="50"><? echo $text2; ?></textarea><br>
            <input type="submit" name="submit" value="Update News Article"></td>
            </tr>
            </table>
            </form>
            
            <!--  End Edit Record Form -->
            
            </Body>
            </html>
            <?
                    }//end of while loop        
            }//end else ?>

            You should take out all of the error suppression @'s and tell me what the exact error is.

              We seem to have gotten out of sync here J. Well you are having fun. I know that it is frustrating, but we learn from our mistakes, and some people can't even manage that. My personal approach at this stage would be to go away and do something else for an hour or so. Then come back refreshed and start again.

              Have a look at the Debugging 101 thread for the best hints on how to tackle this. Pay attention to the part about using echo to track your execution paths, it will help fix this.

                Okay, I implemented that code and here's what I got after trying to access the edit page:

                Parse error: parse error, unexpected $ in /home/pantica/public_html/davidliebman/adman/DL_EditNews.php on line 140

                I looked on line 140, which is at the very very bottom, and there's no $ sign. I would have removed the @ signs like you suggested, but something tells me this error has nothing to do with that, no?

                Thank you.

                  Originally posted by Roger Ramjet
                  We seem to have gotten out of sync here J. Well you are having fun. I know that it is frustrating, but we learn from our mistakes, and some people can't even manage that. My personal approach at this stage would be to go away and do something else for an hour or so. Then come back refreshed and start again.

                  Have a look at the Debugging 101 thread for the best hints on how to tackle this. Pay attention to the part about using echo to track your execution paths, it will help fix this.

                  Thanks Roger, I just bookmarked that link.

                  And yeah, it's kinda frustrating, but honestly, I like the challenge (even if people have to hold my hand a bit). Furthermore, I really like doing this stuff, it's not only somewhat fun, it's a good braintuner as well as a confidence booster.

                  Can you recommend any php books that target the beginning programmer? I've done a couple php tutorials, and while they were somewhat descriptive with respect to what I was doing, it didn't explain everything, which is understandable. Basically, I wanna know exactly what each character does. I'm getting a better understanding now from trial and error, but man, that's a long way to learn something. So, any books/sources you can recommened would be awesome. Thanks.

                    Work backwards from line 140 until you find the missing end quote or line terminator. Again, at this point the best thing you can do is to go read the debugging thread. You will find the condensed wisdom of the mods and all the most experienced contributers ther. 20 mins now will save you endless grief later.

                      I can't type fast enough in the thread, it's taken on a life all of it's own.

                      Best stuff I've found is by Kevin Yank. Here are some links to articles by him. They are to his publishers website and include sample chapters and great code downloads. I would say his books are as good as it gets, though I've not had to buy one. If I did it would be one of his.

                      http://www.sitepoint.com/books/phpmysql1/
                      http://www.sitepoint.com/print/users-php-sessions-mysql
                      http://www.sitepoint.com/article/write-secure-scripts-php-4-2
                      http://www.sitepoint.com/article/great-client-login-system

                        Okay, I'm gonna take your advice and read it now, well, after I eat.

                        I know I've said this countless times, but man, thanks for both of your help. I'm really learning alot about this stuff, which is obviously ideal, with the help of you too. For this particular job, I could have just got some existing open-source to handle the client's objectives, however, this time I really wanted to learn this stuff. Actually, while I was doing the tutorial (how to create a simple news' app), I pretty much typed out every character, as opposed to simply copying and pasting the tut author's code, so that I could really learn. It helped big time.

                        Peace.

                        Oh, and thanks for the latest links. I'm gonna check 'em out.

                          Hell! If I'd known this was some hack authors example I'd have told you to dump it. Most of those books are only good for doorstops, as your experience with this script confirms. At least Kevin Yank's stuff is up to date and he points out the version specifics. I'd be demanding my money back if I'd bought that book.

                          Still, you got your feet wet, and legs, back and neck.

                          PS You mean you're getting paid for this? 😕 Where is our cut 😃

                            It was an online tutorial, so no money invested, only precious time.

                            What I did was follow a news app tutorial, which worked great, well, it worked...then I followed an image upload tutorial, which ended up working too. Then, with the help of someone on phpfreaks, we got the the two scripts to work together, however, I couldn't get it to work without updating the image, hence this post.

                            As far as a cut, I'm getting chump change for this. It's more of a learning experience, plus I can use this code for future projects. While I know you were kidding, I'm totally willing to help out with some graphic design, should you guys need some. I have photoshop on lock!

                            Peace.

                              Cool, just ask. And that definitely goes to Kudose too.

                              Okay, I'm reading the Debug 101 article, as well as trying out what I read in efforts of getting this script to work.

                              I'll report back later.

                              Peace.

                                Originally posted by Kudose
                                You should take out all of the error suppression @'s and tell me what the exact error is.

                                My mistake, I originally missunderstood this part, but I've since removed all the "@'s" but I still get the same error message. I'm still reading through this debuggin' post, so maybe I'll learn something here.

                                Thanks.

                                  My eyes burn really bad. I will run this on my own server in the morning and fix it up...

                                  Man, I can edit images and such, but creating and making pretty ones is a major weakness of mine.

                                  Got any work online?

                                    Originally posted by Kudose

                                    Man, I can edit images and such, but creating and making pretty ones is a major weakness of mine.

                                    Ahhh, that's my strength. Here's my portfolio:

                                    http://www.Pantica.com

                                    I would be more than glad to help you out with any graphics, just tell me what you need. Maybe we can hook each other up back and forth 'cause I'm sure I'll have questions about other php projects in the future. If you, or a client needs graphic help, maybe we can trade time. Something to think about.

                                    Peace.