-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
can NOT get query to pull data based on WHERE clause
.josh replied to simcoweb's topic in PHP Coding Help
okay you seem to have 3 different scripts going here: your form, your target, and some other script called members. And it seems that your form script's action targets your target script, but you are trying to access your form's posted variables in some other script called members.php . My best guess is that you have a login form that asks for the username/password, and then a script to authenticate it, and then upon authentication, you get whisked away to another script called members.php and you are wanting to do another query based on the same information. Is that even remotely right? Okay to access the info from form.php in your target.php, you use the $_POST array. To access info from target.php in your members.php you need to create a session variable. Let's simplify this a bit, kinda start over. This is the basic principle of passing a variable from a form to its target action script: form.php [code] <form action='target.php' method = 'post'> <input type='text' name='username'> <input type='submit' value='submit'> </form> [/code] target.php [code] <?php session_start(); $username = $_POST['username']; $sql = "select * from blah where username = '$username'"; $_SESSION['username'] = $username; header('location: members.php'); exit(); ?> [/code] members.php [code] <?php session_start(); $username = (isset($_SESSION['username'])) ? $_SESSION['username'] : NULL; ?> [/code] -
because it's a binary comparison. it breaks the strings down to their binary equivelants and compares them. Therefore it needs 3 returnable values: less than, equal or greater than. [code] strcmp(101,100); //returns 1 because 101 is greater than 100 strcmp(101,101); //returns 0 because they are equal strcmp(1010,1011); //returns -1 becuase 1010 is less than 1011 [/code]
-
no.
-
[quote author=redbullmarky link=topic=111424.msg451627#msg451627 date=1160768806] [quote author=fenway link=topic=111424.msg451624#msg451624 date=1160768384] Agreed... in general, one should never delete anything that has actually happened. EVER. [/quote] unless it involves your mistress, a camcorder and a wife who's a dab hand with a machete. [/quote] oh snap!
-
I understand perfectly well that you don't know what part is relevant. I just don't think you understand your options, as far as getting help without knowing anything about it. You will [i]not[/i] get help in this forum by posting your entire code, or PMing someone, or emailing it to someone. You [i]may[/i] get help by posting in the freelance forum. You [i]will probably[/i] have a better chance of someone helping if you offer to pay for their services. [i]More than likely[/i] you will get the same response no matter where you go. As far as I'm concerned, this discussion is over. It seems as though you are in agreement, so this thread is closed. Good luck. CV
-
can NOT get query to pull data based on WHERE clause
.josh replied to simcoweb's topic in PHP Coding Help
yes. your posted variables go to the targeted script in your form action. That's the only place they go to. therefore, your targeted script already checks to see if they are there, etc.. just add those 2 lines of code afterwards, just like i showed you. as far as your proper syntax thing... session_start() should only be used once, at the beginning of your script. If you are already checking for $_SESSION['loggedin'], then you presumably should aready have session_start() some place near the top already. also, using session_register is a deprecated way of doing sessions. instead, use $_SESSION['memberid'] = $results['memberid']; and then when your header redirects to members.php, you can do this: [code] <?php session_start(); $memberid = (isset($_SESSION['memberid'])) ? $_SESSION['memberid'] : NULL; ?> [/code] that way you will have your $memberid variable as an easier variable to play with. Just remember though, if you wanna do it that way, before you go to some other page, always go back and assign whatever you have in $memberid back to the session variable like so: $_SESSION['memberid'] = $memberid; presumably your memberid won't be changing, so this probably won't be necessary, but keep that in mind if you are going to have other session variables that will be changing. -
post what you feel is the relevant part of your code. cut/paste it. don't try to make an attachment. nobody is going to download and read 44k worth of code. or ask for help in the freelance forum (you did not mention freelance anywhere in your posts, btw). please read the freelance forum rules before posting. If you want the free version of help, then you're going to have to make an effort on your end. You are not making an effort. All you are doing is trying to post all of your code and have someone sort through all of it. Or trying to email it to people. Or get them to download it. The point is, you are asking for the free version of help, but you are expecting the paid version of help instead. This forum is not here for people who know absolutely nothing whatsoever who decided to fiddle with something and ended up breaking something, and then shoving the whole thing in our faces and saying here, fix it. We are here for people who are trying to learn something, and are having issues with a bug or logic or something. If you are looking to shove the whole shebang into someone's face, then more than likely you are going to have to pay for it. Your best option is to post in the freelance forum here (or elsewhere), and hell, even post it as unpaid, and maybe someone will take pity on you and do it for free. I doubt it, but hey, you never know. You are free to go to some other board if you like, but I garauntee you will find yourself being told the same thing. I'm not trying to be rude or unfriendly; that's simply the way things are. You can call up a mechanic and if you tell him what kind of funny noises your car is making, he might give you some advice or tell you what might be the problem for free, but if you take your car to him and hand him the keys and say here, fix it, you should expect a bill. That's just the way things are. Regards, CV
-
...or go post in the freelance forum if you would rather someone do it for you.
-
no. I'm not trying to be rude, but you need to carefully re-read my previous post.
-
if (mail("$to","$from","$subject","$body","$Q1-Q10")) you are trying to send your variables as a fourth argument to the mail function. If you read the manual, you will see that the 4th argument for the mail function is for additional headers. also, i don't know what this whole "$Q1-Q10" business is... I hope that's not some attempt to have it automatically echo all of those variables out. Unless that's some kind of shortcut I don't know about? Doesn't seem to work for me... try this: if (mail("$to","$from","$subject","$body $Q1,$Q2,$Q3,$Q4,$Q5,$Q6,$Q7,$Q8,$Q9,$Q10")) you might wanna look into using an array for your questions though... it might just make things a bit easier for you...just FYI...
-
well 44k is a lot of text. I picked a random php file on my computer. It's 6k and has 142 lines of code in it. I will certainly not look through 7 times that many lines. I'm sorry, but we cannot help you unless you show some code. If you know absolutely nothing about php to the point that you don't even know the problem area of your code, then perhaps you would be better off making a post in the freelance forum asking for help. If you wish to nonetheless ask here, you need to put forth a bit more effort than what you're giving. You said you added a little portal and things went wrong. Why not start there. Go to that part of your code.
-
i found this comment in the strcmp section of the manual, which seems to be a good explanation: [quote] One thing to note in comparison with == When we make a comparison with == php automaticly converts strings to integers when either side of the comparison is an integer, f.e.: <? $value = 0; if($value == "submit") { echo "Let's submit"; } ?> Above would be succesful, since "submit" is converted to an integer (eq 0) and the equation is would return true; (that's why (1 == "1submit") would also return true) That's why we should use strcmp or === (checks type also), for string comparisons. So my conclusion is that when comparing string, you'd better not make use of == (use strmp or === instead). For integer comparisons the == equation can be usefull, since our values will always be casted to an integer (1 == "1" returns true). [/quote]
-
[quote author=kevinritt link=topic=111225.msg451751#msg451751 date=1160799193] OK-I'm starting to get it. One final question (I hope) I want the teachers to submit homework for each day of the week (Monday, Tuesday, etc) How will the database know to call the most current entries? In other words, Monday's homework won't be called up a week later - a different 'Monday' homework will be called up. This way students can go to the 'Homework' page and see the most current homework without having to enter a date. Thanks ;D [/quote] you would have a timestamp field in your database. you would do a query based on the timestamp. a week ago monday's 24hour timestamp range is different from this upcoming monday's timestamp range.
-
can NOT get query to pull data based on WHERE clause
.josh replied to simcoweb's topic in PHP Coding Help
okay in your OP you said you had this: $username = $_POST['username']; but i do not see that in your code. [code] if(empty($eg_error)) { $username = $_POST['username']; // need to add this $password = $_POST['password']; // and this // Get Record Set $sql = ("SELECT * FROM plateau_pros WHERE username = '$username' AND password = '$password'"); [/code] -
a) once again you have not properly used the ternary operator. The ternary operator format looks like this: $variable = (condition) ? condition_is_true : condition_is_false; b) you are also using an = instead of an == sign in your condition. Those are 2 different operators. = is the assignment operator. == is the equality operator. c) you should NEVER insert a $_GET variable directly into a query, otherwise you are begging for sql injection hacks. you should always sanitize your variables before using them in queries. you should at the very very VERY least do something like what I have done below. d) as mentioned above, you're missing a ; on your echo $sig line. [code] <?php $con = mysql_connect("localhost","ZackBabtkis","") or die('Could not connect: ' . mysql_error()); mysql_select_db("test", $con); $id = mysql_real_escape_string($_GET['id']); $result = mysql_query("SELECT * FROM messages WHERE ID=" . $id); while($row = mysql_fetch_array($result)) { $sigtest = $row['sig']; $sig = ($sigtest == "no") "test" : NULL; // will set $sig to "test" if $sigtest equals "no" echo $sig; } ?> [/code]
-
can NOT get query to pull data based on WHERE clause
.josh replied to simcoweb's topic in PHP Coding Help
<form action[color=red]=[/color]"<?php echo $_SERVER['PHP_SELF']; ?>" id="Form1" style="WIDTH: 100%" name="Form1" method="post" > -
then the problem is with your post variable itself $sig = (isset($_POST["sig"])) ? "yes" : "no"; basically what this does is if $_POST['sig'] is set (it exists) then $sig = "yes"; if it does not exist, then $sig = "no"; the fact that it keeps setting $sig to the one on the right of the : means taht $_POST['sig'] is not set. check to make sure you actually named your checkbox 'sig' in your form, and that it is spelled right, your form method = 'post' etc..
-
select * from table order by length(columnname)
-
change the NULL to "no" $sig = (isset($_POST["sig"])) ? "yes" : "no"; or else in your database you can set the default to "no".
-
can NOT get query to pull data based on WHERE clause
.josh replied to simcoweb's topic in PHP Coding Help
if your script works just fine if you manually use a user's name in the query, then the problem is with your $username = $_POST['username']; make sure that in your form your input field is indeed name='username' and that your form method is method='post' -
$sig = (isset($_POST["sig"])) ? "yes" : NULL;
-
maybe it would have been funnier if i understood what they were saying.
-
As far as I know, phpfreak more or less gave control of the site over to ober and steelman to fix/manage/whatever. They are supposed to (eventually) fix a lot of bugs. I don't see why that couldn't include re-writing the whole damn thing.. or having it re-written via a contest like this. But I guess if I was in their shoes, I'd probably still run it by phpfreak.
-
i guess i forgot to mention that maya is a 3d model/animation program..
-
It was novel for about the first 10 seconds. Then it just got boring. And I personally think the stopping every couple of seconds was annoying.