Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. Why is that? I'm not too familiar with the topic of a db structure, so if you wouln't mind explaining it to me, or at least giving me some reading material, i would greatly appreciate it =)
  2. Incredible! When I was thinking about this earlier, I was hoping that a function like that did exist, and it does! thank you so much!
  3. try changing if (isset($_SESSION["used"][$rndTerm])) to this if (in_array($rndTerm, $_SESSION["used"])) you may have mixed up your values and keys. say rndterm is 2, and you have done this function three times, you are checking if there is a value for the key of _SESSION['used'][2] and since this function has executed three times, there would be (Assuming you are using a numeric array) Hope that helps
  4. hmm ok.. i still dont really get what you want, but It seems like you just want to set the From to that specific post variable. I thought you needed to set the Reply to header also, but I think I may see a problem. try changing $headers="From: {$_POST['email_box']}"; to $headers="From: ". $_POST['email_box']; I hope that helps. sorry if it doesnt
  5. that doesnt really loop? wouldnt you want something like $i = 0; while ($i < /* whatever your limit is */ ){ $_SESSION['List'][i]['Title'] = $_POST['title']; i++; } Or is that what you had before and what you want to change it from?
  6. $headers = "From: " . $_POST['email_box'] . "\r\nReply-To: " . $_POST['email_box']; Is this what you need?
  7. Hello. I'm pretty sure the answer to this is pretty easy, and as usual I am overthinking it, but I need a good method to pass arrays or array information into a sql database. I had come to the conclusion that you couldn't pass arrays directly into SQL ( I tried and failed once), but since my experience with this is so limited, I am not sure if that is entirely true. I have made a few functions that do pass array like information into SQL. My current method is to take a string, with a common delimiter (IE ":") and pass that string into SQL. The string would look something like $string = "Pie:Cake:Doughnuts:Strawberries:etc"; Now what I would do when I retrieved this string would be to use a string explode, something like $sql = mysql_query("blah blah blah"); //..other sql stuff to put the information I want into variable $string $string_array = explode($string); And Now I have an array of data. Oh and my syntax might be a little off up there, but my actual script works fine at this part. This works fine for getting the data, and outputting it or processing it. However, When I want to put the data back into the table, I use the implode function, IE $string = implode($string_array, ':'); However, sometimes my script messes up a little, and I get an extra semi-colon here and there. Sometimes it works great, and other times it just fails. I'm not really looking to fix my code or anything, I just want to know if there is an easier way to do something like this. I'm not versed to well with arrays, and how they interact with SQL, so I can't really think of another way. Thanks in advance for any responses
  8. oh my apologies, I wasnt familiar with what you were doing there, but now I understand. hmm that seems like it should work, but perhaps without a variable to assign the value of the key that each passes, it might not function correctly. Try making, like, a garbage variable or something that you use as the first parameter of the list function, IE instead of what you have, write while (list($garbage, $option... etc. But I could be totally wrong like last time. Hope that helps, sorry about first post
  9. Im not gonna give you the full script... but I can give you an idea of what you want to accomplish basically you want to store the URL in your database, as thorpe said, and when you want to display it, get the url via a mysql query, like: $query = mysql_query("SELECT * FROM tablename WHERE criteria='$credientials");//criteria and credentials are basically what you use to validate that its the specific user when they login. Using something like their session username is a good thing to use here $r = mysql_fetch_assoc($query); $url = $r['avatar']; echo "<img src='$url' />"; hope that helps
  10. im not entirely sure, but try changing list(,$option) to list($option)
  11. First off, this is a pretty bad way to go about things. As a few people have said, you don't want to set the session as the post variables, before you even check them. You want to just set them as simple variables, like so if (isset($_POST['username']) && $_POST['password'])){//or whatever your forms are called $uname = $_POST['username']; $pass = $_POST['password']; $result=mysql_query("select * from members where mbr_name='" .$uname . "' and mbr_pass='" . md5($pass) . "'"); $num=mysql_num_rows($result); if($num < 1){ echo "Bad Longin!" exit(); } //now here we set the sessions $_SESSSION['Username'] = $username; $_SESSION['isLoggedin'] = true; echo "Welcome $username!"; } else {//if the post variables arent set, put the form here ... etc. You also want to sanitize the post variables also. Check this tutorial: http://www.phpeasystep.com/workshopview.php?id=6 on secure logins for more information, but something like $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); would do the trick
  12. well since you already selected the database you were going to access with the following line: mysql_select_db("wowbasec_class", $connection); it is kind of redundant to use mysql_db_query. You might want to try just using mysql_query, IE $query = "select * from `char`, location WHERE name='$search'"; $result = mysql_=query($query, $connection);
  13. sorry about the long reply, i was gone for a little bit. Ok i didn't know that you were on that page twice, so yeah that if statement would work in that case. And the change you made, technically shouldn't really matter, since both point to the same location (which is step1.php I assume) try to use the != comparison, instead of the !==. the latter may be making your test run true for some reason (maybe they aren't the same type, or there is some other issue making them not "identical")
  14. Based on what I see there, since step1 is set, than your session "token" never gets its value set, and because of that, the next elseif check runs true every time (since that session isn't set, the post value of token cant equal nothing, assuming that that post value is also sent)
  15. you can create an error page, called error.php or something, and whenever a user tries to get to a bad page, they get redirected to that page. You might be able to even make a custom 404 page on your server. Some servers let you do that
  16. post the code?
  17. So i assume you just want to group the information about this array into a different array? ok well after you get some information about the arrays you can just make some functions to do what you want to do with the arrays. ok so the array you want till be something like this $data_simplified = array('serial'=> , 'color =>,...etc); for the quantity just do something like function quantity($array){ $i = 0; foreach ($array as $array){ $++ } would that work to get your quantity? for the color, you could just assign the first value of your data array to the color, and pretty much do the same for the rest of columns. You could also test if they were different if you wanted to really, and change the array based on that. but yeah, the function above would give you the quantity (I think) so getting the other values shouldnt be too hard to figure out
  18. two questions. Did you change your pages to what I gave in my post? Also, the undefined variables probably refers to a variabled named currentpo as opposed to the session named currentpo (which are diffferent by the way) post those specific lines and let me take a look at them
  19. since you fetched an associative array, you need a string as a key. thus, you have to encase your key around single quotes. So change the following if ($rate_row[student_id] != 0) { to if ($rate_row['student_id'] != 0) { that might fix your problem. Or i might be terribly wrong. Hope it helps regardless!
  20. Ok well right now you kind of have your page set up in a pretty bad way. Instead of making a function that shows the form just.. well.. have an html page where the form as. Set the action of that form to the page passion.php, and on that page you can have the code that has all the php from the page you first posted. Now you don't need a page called passion2.php because passion.php does all the stuff for you. So just to help you out here is what your pages should like like (kinda) here is the html page with the form this can be called form.html <form id="form1" name="form1" method="post" action="passion.php"> <table width="699" border="0" align="center" cellspacing="5" class="style1"> <tr> <td colspan="3"><div align="center"><span class="style4">Your Passion Test</span></div></td> </tr> <tr> <td width="24"> </td> <td width="429"> </td> <td width="220"><div align="right">Saturday, 03/28/09</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right">$_SESSION[MM_firstname]</div></td> </tr> <tr> <td> </td> <td> </td> <td><div align="right"></div></td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>1</td> <td><strong>I like talking to people. </strong><br /> </b></td> <td><div align="left"> <input name="po1" type="radio" value="0" /> 0 <input name="po1" type="radio" value="1" /> 1 <input name="po1" type="radio" value="2" /> 2 <input name="po1" type="radio" value="3" /> 3 <input name="po1" type="radio" value="4" /> 4 <input name="po1" type="radio" value="5" /> 5</div></td> </tr> <tr> <td>2</td> <td>It is important for me what other people think. </td> <td><p> <label></label> <label></label> <input name="mo2" type="radio" value="0" /> 0 <input name="mo2" type="radio" value="1" /> 1 <input name="mo2" type="radio" value="2" /> 2 <input name="mo2" type="radio" value="3" /> 3 <input name="mo2" type="radio" value="4" /> 4 <input name="mo2" type="radio" value="5" /> 5<br /> <br /> </p></td> </tr> <tr> <td>3</td> <td class="style1">My level of excitement is high right now. </td> <td><p> <label></label> <input name="mo3" type="radio" value="0" /> 0 <input name="mo3" type="radio" value="1" /> 1 <input name="mo3" type="radio" value="2" /> 2 <input name="mo3" type="radio" value="3" /> 3 <input name="mo3" type="radio" value="4" /> 4 <input name="mo3" type="radio" value="5" /> 5<br /> </p></td> </tr> <tr> <td>4</td> <td>I like solving mathematical tasks. </td> <td><input name="po4" type="radio" value="0" /> 0 <input name="po4" type="radio" value="1" /> 1 <input name="po4" type="radio" value="2" /> 2 <input name="po4" type="radio" value="3" /> 3 <input name="po4" type="radio" value="4" /> 4 <input name="po4" type="radio" value="5" /> 5</td> </tr> </table> <p align="center"> <input name="Submit" type="submit" class="style1" value="go on" /> </p> </form> and here is the php page passion.php (Note that in the above form, i set the action to this page. Whenever you make a form, the page with the code that processes the form should be set to the action of the form) <?php require_once('Connections/Login.php'); ?> <?php session_start(); ?> <?php //You will need to update all the below variables $mysqlhost = "localhost"; $mysqluser = "guntmar"; $mysqlpass = "je20sa05"; $mysqldb = "guntmar"; $mysqltable = "users"; $username = "username"; // End Variables mysql_connect($mysqlhost, $mysqluser, $mysqlpass); mysql_select_db($mysqldb); $query = "SELECT * FROM " . $mysqltable . " WHERE username='" . $username . "'"; $result = mysql_query($query) or die("There was a mysql error"); while($row = mysql_fetch_array($result)){ $currentpo = $row['resultspo']; $currentmo = $row['resultsmo']; } $pagepo = ($_POST['po1'] + $_POST['po4']); $pagemo = ($_POST['mo2'] + $_POST['mo3']); $newpo = ($currentpo + $pagepo); $newmo = ($currentmo + $pagemo); } $query = "UPDATE ".$mysqltable." SET resultspo = '".$newpo."', resultsmo = '".$newmo."' WHERE username = '".$username."' AND id = '".$_SESSION['id']."'"; mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); //JavaScript page redirect... // Close if/else ?> Ok that should help you out a little bit. Hope that helps!
  21. I think i see the problem. When you load the page, you show the form, thus ou dont set the variables. However you still run the query. Try chaning } else { $pagepo = ($_POST['po1'] + $_POST['po4']); $pagemo = ($_POST['mo2'] + $_POST['mo3']); $newpo = ($currentpo + $pagepo); $newmo = ($currentmo + $pagemo); } $query = "UPDATE ".$mysqltable." SET resultspo = '".$newpo."', resultsmo = '".$newmo."' WHERE username = '".$username."' AND id = '".$_SESSION['id']."'"; mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); to this } else { $pagepo = ($_POST['po1'] + $_POST['po4']); $pagemo = ($_POST['mo2'] + $_POST['mo3']); $newpo = ($currentpo + $pagepo); $newmo = ($currentmo + $pagemo); $query = "UPDATE ".$mysqltable." SET resultspo = '".$newpo."', resultsmo = '".$newmo."' WHERE username = '".$username."' AND id = '".$_SESSION['id']."'"; mysql_query($query) or die("There was a mysql error<br />Query: {$query}<br />Error Returned: " . mysql_error()); }
  22. two things. Make sure the directory you are ttrying to move the files to exists. something like: ff (!file_exists('images/')) { mkdir('images'); } this will check if the dir exists, and if not it will make it. now make sure that your script has access to moving, and creating folders/files in your server. It has to have its permissions set to 777 i believe.
  23. your query looks fine. Instead of using mysql_query($sql,$connection) connect to your Database before you do the query, then simply do mysql_query($sql) that might work. hope that helped
  24. instead of using the copy function, try using the move_uploaded_file function so change the following $copied = copy($_FILES[$image]['tmp_name'], $newname); to $copied = move_uploaded_file($_FILES[$image]['tmp_name'], $newname); hope that helped
  25. seems right to me =/ make sure You have all your column names and stuff right. Maybe try setting Active to a variable name and checking if status='$active' or something
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.