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.

                          This works on my server. You will need to change the table names and the path though.

                          <?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);
                          		$this->allowed  = array("image/jpeg", "image/jpg", "image/pjpeg", "image/png");
                          
                          	if(!is_dir($this->path)){
                          		$msg = "Specified path is not a directory. Specified Path = (".$this->path.")";
                          		@unlink($this->image_tmp);
                          		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;
                          				@unlink($this->image_tmp);
                          				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.";
                          					@unlink($this->image_tmp);
                          					return $msg;
                          				}
                          			}
                          		} else {
                          			$msg = "File type \"".$this->image_type."\" is not supported.";
                          			@unlink($this->image_tmp);
                          			return $msg;
                          		}
                          	} else {
                          		$msg = "File was not uploaded to be moved.";
                          		return $msg;
                          	} // end if file is uploaded
                          }
                          
                          //end Travis' function
                          
                          
                          //start main stuff
                          
                          if(isset($_POST['submit'])){
                          
                          $title = $_POST['title'];
                          $text1 = $_POST['text1'];
                          $text2 = $_POST['text2'];
                          $upload = $_POST['upload'];
                          $newsid = $_POST['newsid'];
                          
                          //lets verify the data first
                          if(empty($title)){
                          	echo "Title was empty.  Please try again.";
                          	exit;
                          }
                          
                          if($_POST['upload'] == "Y"){
                          	$image = $_FILES['image'];
                          	$path = "/home/user/public_html/imgs/";
                          	newImage($image, $path, 75000, "");
                          	$sql = "UPDATE test SET image='".$path.$image['name']."'";
                          	if(!mysql_query($sql)){
                          		echo "Error :: The image SQL was not updated!";
                          	}
                          }
                          
                          $title = mysql_real_escape_string($title);
                          $text1 = mysql_real_escape_string($text1);
                          $text2 = mysql_real_escape_string($text2);
                          
                          $sql = "UPDATE test SET title='".$title."', text1='".$text1."', text2='".$text2."' WHERE newsid='".$newsid."'";
                          
                          if(mysql_query($sql)){
                          	echo "Record updated.";
                          } else {
                          	echo "Error :: The record could not be updated.";
                          }
                          
                          } else {
                          	$newsid = $_GET['newsid'];
                          
                          if(!empty($newsid)){
                          	$sql = mysql_query("SELECT * FROM test WHERE newsid='".$newsid."' LIMIT 0,1");
                          	$fetch = mysql_fetch_array($sql);
                          	extract($fetch);
                          }
                          ?>
                          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
                          <input type="hidden" name="newsid" value="<?php echo $newsid; ?>">
                          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          	<tr>
                          		<td width="50%">Title:</td>
                          		<td width="50%"><input type="text" name="title" value="<?php echo $title; ?>" size="18"></td>
                          	</tr>
                          	<tr>
                          		<td width="50%">First Paragraph:</td>
                          		<td width="50%"><textarea name="text1" rows="5" cols="50"><?php echo $text1; ?></textarea></td>
                          	</tr>
                          	<tr>
                          		<td width="50%">Everything Else:</td>
                          		<td width="50%"><textarea name="text2" rows="5" cols="50"><?php echo $text2; ?></textarea></td>
                          	</tr>
                          	<tr>
                          		<td width="50%">Image:</td>
                          		<td width="50"><input type="file" name="image" value="<?php echo $image; ?>"></td>
                          	</tr>
                          	<tr>
                          		<td colspan="2"><input type="checkbox" name="upload" value="Y">Replace current image?</td>
                          	</tr>
                          	<tr>
                          		<td width="50%">&nbsp;</td>
                          		<td align="left"><input type="submit" name="submit" value="  Submit!  "></td>
                          	</tr>
                          </table>
                          </form>
                          <?
                          }
                          ?>

                            Nice portfolio by the way. I wish I had something that glamourous, but I was born with the backbone of a programmer, not an artist. :queasy:

                            Work backwards from line 140 until you find the missing end quote or line terminator.

                            I forgot to close a bracket on my image cla...function now...

                              David,

                              In UltraEdit, if you go to Advanced->Configuration -- Syntax Highlighting Tab -- Then you can change the syntax coloring individually in the Color Groups.

                              🆒

                                Thanks again for the continued support...

                                Okay, here's the error message I received:

                                Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pantica/public_html/davidliebman/adman/DL_EditNews.php on line 99

                                Warning: extract(): First argument should be an array in /home/pantica/public_html/davidliebman/adman/DL_EditNews.php on line 100

                                This time around, it didn't pull the data into the respective fields, so I'm assuming these errors are the cause.

                                I tried to diagnose this on my own, by working backwards from the problem, but thus far, no dice. I also did a search via google on the aforementioned warnings, but again no dice.

                                Thanks for the compliment on my work. If you want an interface for your site, thus the main design, just let me know. I'd be more than willing to create one for you, for free, considering all your help here.

                                  Did you make sure to change the table name from test to news like I said earlier?

                                    Oh man, sorry about that. I gotta stop skimmin' posts, as well as emails...details details details...

                                    Well, it worked this time. Wooo hooo! Well, kinda. It updates fine, but if I try to add a new image, it won't upload the image (and I checked "Replace current image." Actually, when I view the article, and then the source code, it shows the correct path, however, the image isn't in my hosting account. The directory path permissions are correct seeing how it was working before.

                                    What do you think?

                                    Thanks again man.

                                      Put an echo in front of the newImage command at tell me what it says.

                                      Do you have AIM or ICQ? We are loadin up this thread.

                                        Write a Reply...