![](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
dannyb785
-
Posts
544 -
Joined
-
Last visited
Posts posted by dannyb785
-
-
what he means is.. you defined a function, in order to execute the function you need to call it. All a function is needed for is for code reuse, say you want a function that grabs the name of the user, its much easier to make a function for this and call the function instead of type all the code to grab the persons name, get it? So what you did is create a function, but you never called it.
ok,i kinda get you..
so how should i go about calling the function?
so what I said didn't make sense? Are you new to php?
-
yea, just put some sort of identifying measures to make sure users don't try to run the script(if they know it exists). something like if you know it's supposed to run every 30 minutes, do a check to make sure that when it's execited that it really is 2:30 or 2:00 and so on. otherwise, there's no reason why not to use a cronjob
-
you changed what to updateDetails()? you didnt delete the function and then try to call it, did you?
edit: post the exact code you changed it to
-
it would be so much easier to just use semantic markup... you can play around a little but the example below would achieve the desired layout except the header would not be centered - you'll just have to play a little more...
<div class="infoitem">
<h2>Section Title</h2>
<p>some copy about what they will find...</p>
</div>
the css
div.infoitem { border: 1px solid #ccc; margin-top: 1.5em; }
div.infoitem h2 { float: left; position: relative; top: -1em; margin: 0 0 -1em 20px; background: #fff; color: #ccc }
I agree completely. Because in my experience, the fieldset/legend/etc are interpreted differently by different browsers. Check how it looks in FF, then IE, and then safari. I almost guarantee it wont look the same.
-
For $25, I bought 'php and mysql for dummies' and I kid you not, was an amazing starter for me. You can probably get it cheaper, and dummies books are awesome at explaining concepts that more advanced books don't even cover. And they make it enjoyable to read. After that, I recommend any of the o'reilly books that are php related(they always have different animals on the cover) and then recently I bought the 'php 5 and mysql bible' which covers pretty much everything. Overall about $100 spent on books.
and STUMBLE!!! often. If you dont know what it is, download FF and do a google search. Select 'web technology' and 'programming' and you'll gain invalueable knowledge from blogs, tutorials, and the like
-
Yes, it's not too bad, but just like creating dynamic links(so that youd have to insert a closing </a> at the end) basically, whatever if statement you use to create the div, you need to use the same to insert the closing </div> wherever it would be inserted, if needed.
so maybe something like this:
if( $open_div == true ) { open div and do some stuff } blah blah whatever else if( $open_div == true ) { close div and whatever else you might need to do to finish it off }
-
You've defined a function, but havent executed it. Either remove the "function updateDetails()" part(and the opening and closing curly braces) or just do
updateDetails();
after the closing curly brace.
-
2 errors I caught...
retufn preg_replace($headers, '', $string);
needs to be 'return'
$query = "INSERT INTO submissions (name, email, topic, comments) VALUES ('$name', '$email', '$topic', '$comments',)";
remove the very last comma after the $comments' just before the closing parenthesis
-
I only started learning how to install and configure this stuff as the need arose. It starts small.
"Ah I need to change php.ini"
"Ah I need to change .htaccess"
"Ah it's better to put items in .htaccess in httpd.conf instead. What's all this other stuff do in this file?"
"Ah I need to recompile to enable or disable something."
Exactly how i learned. IMO it's better than making a thread on a php forum every time I have an issue... but to surf google(and stumble... everyone should stumble!) and figure it out.
Think about it like learning guitar. Are you gonna go out and buy a $3,000 guitar as a starter? Because what if you lose interest and stop caring.. even if you could sell it, you wouldn't get all your money. Or worse if you screw it up accidently(or drop it or something), then there you go. So you buy a guitar for a few hundred bucks, learn it, love it, then upgrade.
Similarly, if you've never done php or coding before, it'd be almost stupid to get VPS or a dedicated server to start off with.
-
You guys have said multiple times you don't see why people still use shared hosting. There are many reasons why:
1) newbies. Some of us start out buying webspace without even knowing php or other languages. So the thought of us paying any more than $15 or $20 a month for something we don't even know how to use isn't a comforting thought. (especially since shared hosting usually charges up front so a payment of over $200 for something we don't know much about isn't a good feeling).
2) affordable. Some of us flat out don't have $50/mon to spend on a hobby. Paying only $5-10 a month makes it so that even if nothing ever comes of our website ventures, we really didn't lose much.
3) ease of use. Yes, if you know what your'e doing, you can install the awesome new php 6 and newest mysql versions and all that good stuff. But in reality, most of us(even most php coders) have no idea how to do that. Yea, you may say 'well you should learn' but when we're spending time learning php, creating a website, and whatnot, learning how to setup a server isn't really on our minds.
-
^ did you realize the problem? It's a pretty simple fix. In fact, it's not even an error. You just didn't put an else statement
-
dude... sorry but... uh.... this is the kinda thing I'd expect from my clients... that they'd be paying me to answer. So much code... yikes... there's gotta be an easier way to do what you're doing....
-
lol the answer was easy(took me 20 minutes to figure out)...
basically... it goes blank because you say "if everything is great, then email... " you have no else statement in the case that email or name was blank.
p.s. you shoud also make sure the textarea wasn't left blank
-
I'd say it's just annoying to a user. They also might not know why the window exited. I'd challenge you to find me any top site out there that exits your window after logout... it's just not necessary.
btw, I did the test on my site where I'd logout, and then hit back(in FF) and it redirects me to the login page. I basically have a check_logged_in() function on the top of every single page that requires a user to be logged in, so if the session is destroyed, and you try to go back into it, it will run the function and then redirect you somewhere else.(I'm using the header() function to redirect)
-
Use JavaScript to close the browser window?
lol not a good idea
-
Can you give an example?
-
dude,you really should indent your curly braces... it's nearly unreadable as it is now.
-
No, you should. You shouldn't let PHP try to make it a string and all that garbage I meant.
ok cool. just making sure the way I code isn't bad.
-
when you use an array whos index isn't a number, you need to put single quotes. for example: $row['index'] instead of $row[index]
Okay, actually, since PHP is loosely typed and wants to be on your side, you don't, but it's faster, neater and more proper to use ' '. This is because when PHP encounters a string not enclosed in "" or ' ', it assumes it's a constant so it looks for one by that name. If it doesn't find one, it attempts to cast it to a string, which allows you to use it in that way. But you shouldn't. So don't.
shouldn't put it in single quotes?
-
I should clarify...
if you're using the variable within double quotes, then you can't use the single quote. But if it's anywhere else, you need the single quotes.
fake edit: I'm not gonna look over all that code.. sorry. I need some kinda error message or line #
-
how can you tell the session is still active?
-
when you use an array whos index isn't a number, you need to put single quotes. for example: $row['index'] instead of $row[index]
-
OK, if you're looking to move it down from the view in FF(personally the position I think looks much better), modify stylesheet.css to
#contentwide {position:relative; top:30px;line-height:1.5em;...
It moves the entire column down 30px in FF, but not in safari or IE. So that should have you set.
-
pushed too far in IE? did you mean too far in FF? It looks better to me in IE since the main box(Welcome to..) isn't over the header image
UPDATE query ..Urgent
in PHP Coding Help
Posted
ok so basically you have functions, which make it easier to process code(without having to retype the code if you use it on more than one page). Just defining a function in itself does nothing. You have to execute it. Like you may have FF, but you can't browse the web unless you open it up. So if you create a function and tell what it does, that's awesome. Thing is, you have to execute it for it to do anything.
In your original code, you have some code, then you have a function defined(everything between the curly braces). And then after that you have the end of the file. It won't execute that function unless... AFTER(i'm not sure if it matters if it's before or after the function, it matters in C, thats all I know) the function is define, you execute it. So once you make function(), you have to go to the place you want to execute it and go
otherwise, you can write as many functions you want in any page but they won't do a single thing until they're executed.
So go to your original code(what you first posted). and AFTER the closing curly brace of the function, type this on the following line, exactly:
and it should do what you need(provided the function doesn't have errors in it)
QUICK EDIT: you need to do addslashes() on all your $_POST variables. Just inserting them as is will cause an error to occur if you insert something with a single quote.