Newb advice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Why not just use one template for all the pages though?
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

jackpf wrote:Why not just use one template for all the pages though?
When I turn my attention back to the front end (forgive the pun) I'll probably
template all the pages. For now at least half of them are just placeholders for
what will become real content.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Fair enough. So anyway, did you get them queries sorted out?
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

I've sorted most of it but still having all sorts of odd little problems.
If you've got two minutes join up (it's free and you just get an activation email)
then take a look at the "view profile" and "edit profile" links. You'll see all the
errors at the top of the page - also, although users can upload an avatar image
(this works and goes to the right folder) the profile page isn't displaying it properly.

Lots to do... Lots to learn :)

Best wishes
Monty
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Try what I suggested with the mysql_fetch_array() warning and undefined indexes.

And I uploaded an avatar, it should be here:
But it's obviously not.

I assume you're using rewrites for this?
What's your directory structure like, and what rewrites (if any) do you have?
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Aha... your image is there and named correctly but the chmod is set to 600 by
default. Need to write a line to chmod the image once it's up.
No help on this one for a while at least please - must learn to fix simple things on my own !
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Sorted...

scratched my head about this for a while but them realised that the images that users upload
from here will ALL be called "image01.jpg" so did this:

Code: Select all

 
$place_file = move_uploaded_file( $_FILES['fileField']['tmp_name'], "members/$id/".$newname);
      chmod ("members/$id/image01.jpg", 0644);
 
And I'm even learning to indent !
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

OK...
so this code

Code: Select all

 
if ($_POST['parse_var'] == "pic"){
 
        if (!$_FILES['fileField']['tmp_name']) {
 
which is used on all the forms on the edit profile page kept causing a "notice" message.
But the script was actually working fine. So I discovered a little trick which I'm sure is
very old hat to you lot - I put a @ symbol after the first bracket which suppresses the message.
This works fine and keeps the page free of messages but is it 'bad form' and a newb error to do it ?

Best wishes
Monty
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: Newb advice

Post by Mirge »

In a production environment, I turn off all error reporting.
In a development environment, I never suppress notices, warnings, errors... and I show all errors.

My .02 cents...
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Yes, it is bad and newby :P

Use isset() like I'm sure I pointed out before.... ;)

Also, why not just use $newname in your chmod? What if the user uploaded a second picture?
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

jackpf wrote:Yes, it is bad and newby :P

Use isset() like I'm sure I pointed out before.... ;)

Also, why not just use $newname in your chmod? What if the user uploaded a second picture?

OK - thought as much. I am a bad newb.
Your isset code does work nicely and I'll go through and change them all to that. Good practice
to get used to using that.

Users can upload more pictures (for other reasons) but the comments system (which is just a dream on a
distant horizon) and the "view profile" page will always look for image01.jpg to display the avatar so I saw
no reason not to do it long hand. Keeps it simple for future reference to the avatar image too.
And it saves space in my aching brain :)

Best wishes
Monty
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

L0l, I'd personally prefer it using the relevant variables...but your choice.

And I'm sure that eventually you'll allow users to choose their profile pictures? That's another reason to just do it now...
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Good point... Changed it.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

:)
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Hi all,

just an update to let you know that I (think) I've solved most of the issues with the
site and I could really do with a load of people to sign up and try to break it !
Well, to find bugs and glitches at least :)

You can now "Blab" from your profile page and see all the member's blabs
at "Bug Blabs" in the menu bar.

Best wishes
Monty
Post Reply