-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
A good programmer is someone who doesn't take on jobs that are above their head and then come to boards like these, making 'ZOMG TEH URGENTZ NED HEPL ASAP FIX TIS NOW PLOX!!1!111!!!1!1ONE!!1!!" posts.
-
[SOLVED] Exam Results script. Please help me ..........
.josh replied to ankur0101's topic in PHP Coding Help
I guess no one told you js form validation is a bad idea. I can turn off my js and sql inject your working example all day long. -
You don't need to make a new database. Just read the tutorial so you can get the idea of what you're supposed to do. No I won't rewrite your script for you. I'm here to teach people how to catch fish, not do their fishing for them.
-
[SOLVED] Exam Results script. Please help me ..........
.josh replied to ankur0101's topic in PHP Coding Help
Your search.php already does that. If no rows are returned, you have echo 'Error, ID does not exist'; Otherwise, it sends you to show_result.php. Since your show_result.php just takes the GET var and does a query based on that value, there's nothing to stop someont from directly going to show_result.php. So you have a couple of options. You can... a) Do the same thing in show_result.php as you did in search.php (run the query and if num_rows == 0, give error message). This isn't really that great of an option, as it's in essence duplicating code. That is, why bother with search.php at all, if you're just going to turn around and do the same thing again, in show_result.php? b) Put a condition in show_result.php to kick the user back to search.php if the referring page is not search.php <?php if ($_SERVER['HTTP_REFERER'] != 'search.php') { header("Location: search.php"); exit; } // rest of code here ?> Slightly better option, but personally, I'd go for option c. c) Combine search.php and show_result.php into a single script. -
[SOLVED] Exam Results script. Please help me ..........
.josh replied to ankur0101's topic in PHP Coding Help
you have that doctype line at the top of your script but later on in your script you call header() based on some condition. Well if condition evaluates true, you get the error, because any output causes headers to be sent. I suggest you move the doctype tag down to where the rest of your html is. And make sure you remove the line completely, not just the code. No output can be sent, not even whitespace, before header(); -
You run your query with the limit after you've already listed everything. Take a look at this basic pagination tutorial to get an idea on the idea.
-
echo "<p>". $classes[$i][0]." - ".$classes[$i][1]." <a href='#' onclick='deleteclass(\"".$classes[$i][0]."\")'>delete</a></p>";
-
I bought a 64 bit computer with vista 64 bit about 6 months ago. There isn't a whole lot of software out there right now that takes advantage of it, and actually, there's a lot of stuff out there that's not even compatible with it at this point in time. But by the time it gets around to being commonplace, The hardware will be a lot less expensive. It seemed like a good investment at the time, but now I kind of regret going 64 bit. On the other hand, I'm 'poor,' so it's not like I have the money to keep up with the Jones' every time something new comes out. My situation differed from yours though, in that my computer died on me, so it was more a matter of replacement rather than upgrade. If you do decide to stick with 32bit, you can downgrade the ram, because 32 bit cannot use 6gb of ram. Also, make sure that motherboard has a 16x pci express slot, for your graphics card. Also, you'd probably save yourself a lot of money by downgrading that blue ray to a regular DVD r/w flavor. You said this is a desktop, so unless you plan on popping the popcorn and pulling up the couch to watch movies on your desktop instead of your tv, it's kind of a waste of money.
-
Are you wanting the links to permanently be hidden for the user once he takes the survey, or just for that login session, as in, he can log out and log back in and it be available again? Or maybe it will be available again tomorrow or next week or something? Part of getting help is being specific with what you want.
-
[SOLVED] Allow Characters with ereg or preg_match for user input?
.josh replied to limitphp's topic in PHP Coding Help
Reminds me of something similar I made a while back. Not really that great, but oh well. -
Dude come on, I understand you may be a "newbie" to php, but you need to try harder, use some logic. Use some common sense. Look at the error message. It says your implode has a bad argument. So look at the arguments in your implode(). "','" and $dbquery If you look at implode in the manual, you will see that the first argument is a string that will act like glue, and the 2nd argument is an array to glue together. Since a string can be anything, chances are the bad argument is your $dbquery. So look at $dbquery. Where is it coming from? Look at your code. You don't assign anything to $dbquery before that implode. Therefore, you are passing a bad argument. Why did you take this line... $dbquery = explode(" ", $line); ... out from the code? That takes the current line in your foreach loop and explodes it into an array: the array you need for the implode. And even after all that is done, your code still will only generate a query string. It's not actually inserting it into your database. Read the documentation. I promise you, I don't mean to sound harsh. But if you're wanting to do this in an effort to learn php in general, I suggest you put this project on hold and back up a few steps and start with the basics. Syntax, etc... If you're just trying to do this in an effort to get a project done for your boss or something, and don't really have a desire to learn php in general, I suggest you consider just forking over a few bucks and having someone else do it for you, because (again, nothing personal) you're trying to work at level B when you haven't really learned level A. Even if you do manage to bluff your way through it, you're not going to understand what's going on and that can potentially be a very, very bad thing. I mean, you're struggling with just getting it to work. You probably haven't even considered how to make it secure, so someone doesn't come along and wtfpwn your database.
-
The documentation in the manual explains it a lot better than I ever could.
-
I suspect the problem is that he doesn't have code, but I don't want to make assumptions.
-
Find a boyfriend. Eat nuts all day long. Best of both worlds. Problem solved.
-
[SOLVED] Allow Characters with ereg or preg_match for user input?
.josh replied to limitphp's topic in PHP Coding Help
Facts: - pcre regex (preg, for php) is a lot faster, up to 6x faster. - pcre is perl compatible. Rumors/opinions: - People say that posix regex (ereg, for php) is easier to learn, but it doesn't offer as much as pcre regex. - pcre is safer (I hear it's a lot easier to inject xss into posix regexes, for instance) -
so...what's the question?
-
foreach ($dbinfo as $line) { echo $line; $dbquery = explode(" ", $line); $data = "'" . implode("','",$dbquery) . "'"; $dbquery = "INSERT INTO voip (C0, number1, number2, type, number3, linetype, c1, dial, c2, date1, date2, date3, c3, c4, anw, DOCUMENTATION, unix, C17) VALUES ($data)"; // ^ just creates the query string. You need to actually insert it into db with mysql_query or whatever function for the db you're using }
-
At best, I'd go from cat > wife to job > cat > wife But even then...kind of messed up. Kick the cat right out the front door. Leave a saucer of milk on the porch if you feel bad about it.
-
[SOLVED] ORDER BY ASC then DESC and back again.
.josh replied to TheStalker's topic in PHP Coding Help
Cheers for all the help guys ended up using this code if(isset($_GET["sort"])) $sort = ($_GET["sort"]=="DESC")?"ASC":"DESC"; else { $sort="ASC"; } Did you even bother to try that? If you set the default to ASC it will sort as ASC on first page load. If you make your link pass ASC it will switch sort as DESC if you click the link. Now click the link again and guess what, it sorts it as DESC again. And DESC again. And if you change your link to pass DESC, it will just keep sorting as ASC over and over and over. In order for 'your script' to 'remember' whether to turn the proverbial light switch on or off, it has to know what state it's currently in (on or off). But clicking on a link makes a new request to the server. As far as php and your script is concerned, it's a completely new request that has nothing to do with the previous request. There is no 'state' to speak of. In order for a single link 'switch' to work, you have to tell it what state the switch was in, before you clicked the link and restarted the whole script. In order to do that, you need to use some means of data persistence. You can do this with a cookie, but it's easier and less hassle to do this with a session variable, as shown to you by multiple people. -
So...getting off early or taking the day off to go there is not an option? cat > wife.
-
hi i have tried it and not able to understand why is it giving me a blank dropdown with no values vineet It didn't work because you used the wrong variable: $customer_city
-
chronister you put the closing select inside the foreach it needs to be outside the loop. Anyways, I win. <?php $cities = array('city1', 'city2', 'city3'); $previouslySelected = 'city3'; echo "<select name='cities'>"; foreach($cities as $city) { $selected = ($previouslySelected == $city)? " selected='selected'" : ""; echo "<option value='$city'$selected>$city</option>"; } echo "</select>"; ?>
-
nrg your code doesn't account for making ucasing the d in macdonald (MacDonald) http://us3.php.net/manual/en/function.ucfirst.php#40508 You can add another strncmp to the poster's condition to account for it.