Jump to content

elmas156

Members
  • Posts

    276
  • Joined

  • Last visited

Everything posted by elmas156

  1. $resdate is actually a string that I created by using "explode" to adjust the format of the date() function. The end result always look like "02/17/2012." I've never used a "join," any way you could break it down and help me understand exactly what's going on in your code? Thanks very much!
  2. Hello everyone, I've been working on this for about 2 days now, and I just can't seem to figure it out so I need some help from someone here. I have a database with three items (will be more, but for now there's three). The database keeps a record of the days that each item is reserved. I want to be able to select and generate a list of items that are available on a specific day. Here is what I have so far: <?php $result = mysql_query("SELECT `prodid` FROM reservations WHERE `resdate` = '$resdate'") or die (mysql_error()); while ($row = mysql_fetch_row($result)) { $resprodid = $row[0]; $result2 = mysql_query("SELECT `prodid`,`prodname` FROM products"); $row2 = mysql_fetch_row($result2); $prodid = $row2[0]; $prodname= $row2[1]; if ($prodid != $resprodid) { echo $prodid; } } ?> The result that I'm getting are not correct. I either get only one unit listed, or none. Any help would be appreciated. Thanks!
  3. Finally found the problem! $reserved = mysql_query("SELECT * FROM reservations WHERE `resdate` = '$resdate' AND `deltime` == '$posstime'"); SHOULD BE... $reserved = mysql_query("SELECT * FROM reservations WHERE `resdate` = '$resdate' AND `deltime` = '$posstime'"); TOO MANY "=" BETWEEN "`deltime`" and "'$posstime'" Thanks to anyone who tried to help!
  4. Hey everyone, I'm getting an error on this code and I'm having a difficult time sorting it out. Most of this page is in html, but here is what little PHP I'm using as of now: <select class="ddbox2" name="occasion"> <option value="select" selected>- Select -</option> <?php $resdate = "02/20/2012"; $result = mysql_query("SELECT `time` FROM delivery_times WHERE `index` > '0'"); while ($row = mysql_fetch_row($result)) { $posstime = $row[0]; $reserved = mysql_query("SELECT * FROM reservations WHERE `resdate` = '$resdate' AND `deltime` == '$posstime'"); $rowcheck = mysql_num_rows($reserved); // <-- THIS IS LINE 198 if ($rowcheck == 0) { echo "<option value='$posstime'>$posstime</option>"; } } ?> </select> What I'm doing is creating a dropdown menu for an html form depending on what is in my database, but here is the error that I'm getting: "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\new_site\custform.php on line 198" When I change line 198 to read: $rowcheck = mysql_num_rows($result); I don't get the error, but I don't get the information that I need to complete my task. I was thinking that maybe this query isn't allowed in a while loop for some reason, but I don't think that would be the case. Any ideas on what I could be doing wrong?
  5. Thanks very much! I think I can make it work from there.
  6. well, kind of, but the problem is I don't know what the stringid is beforehand. This is going to be run from a cron job. Here's what I have so far: $result = mysql_query("SELECT `entryid`,`stringid` FROM allmsgs WHERE reported = 'n' ORDER BY `messid` ASC") or die (mysql_error()); This returns the entryid and stringid for ALL entries that have not been reported yet (reported = 'n'), which means that I get the following results: entryid stringid 5 5 13 5 19 5 23 5 24 5 6 6 14 6 22 6 What I need to do is select all of the entries from each stringid, whith the higest entryid. So in this example, I would like for my results to return: entryid = 24, 22 (the most recent entries of "stringid=5" and "stringid=6") I hope this makes more sense. I was thinking that I would use something like: select entryid from `allmsgs` where `entryid`=(select max(`entryid`) from allmsgs); //maybe put this in a while loop and specify somehow to only select the "max('entryid')" for each "stringid"? Thoughts?
  7. Hello everyone, I have a database with strings of information that I am trying to create a report about. My question is pretty simple, but I'm not sure where to find the information that I need. Basically, am using two DB fields to select the information that I need. One field is named "entryid" and the other is "stringid." The "entryid" is always different... basically incrimental (1,2,3,4....), the "stringid" may be the same for several entries. What I am trying to do is to select the entries that has the same "stringid." So basically, if I have 5 entries that have "entryid" 5, 14, 25, 29, and 41 (just random numbers I selected), and they all have a "stringid" of 5, and then another 3 entries that have "entryid" 6, 13, and 20, with "stringid" of 6, how would I select the entries that have a "stringid" of 5 or 6 so that my results are 5 and 6? I know that I will have to use a while loop, but not sure of the sql code. Any help is appreciated.
  8. Thanks for your replies. Grissom, I do have a field in the database called "stringid" that does exactly what you suggest. Every message in a string of messages has the same "stringid." Basically, I just need to know how to select the most recent entry for each "stringid" in the database.
  9. Hello everyone, I have a messaging site where I have an email generated every night to report new activity on my site. The way it is currently set up, I have each message reply attached to the previous message, such as quoting the original text in an email message. Each string of messages in my database has one common field ("string"), but each new reply has a different message ID field in the database ("messid"). When each new message and reply is created the "reported" field in my database has a default value of n, meaning that it has not been reported yet. At the end of the day, when the email is generated, the reported field is then updated to y, meaning that it HAS been reported. The problem that I'm having now, is that I'm getting several of the same messages in every report. I am using the following code to select each unreported message from the database to generate my report: <?php $result = mysql_query("SELECT `to`,`studentname`,`staffname`,`subject`,`message`,`date` FROM caresa6_$acct.allmsgs WHERE reported = 'n' ORDER BY `messid` ASC") or die (mysql_error()); ?> Basically, I need to know how to select only the most recent unreported message within each string of messages. For example, now if there is a new message: "Hello there." Then a reply from the recipient: "Hi! How are you?" Then another reply from the original sender: "I am fine." My report will look like this: ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ Reply: "I am fine." ------------------ ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ ___________ New Message: "Hello there." ------------------ So I am getting carbon copies of every new message every time someone replies. I want to only select the most recent message so that my report only reads: ___________ New Message: "Hello there." ------------------ Reply: "Hi! How are you?" ------------------ Reply: "I am fine." ------------------ Thanks in advance.
  10. Thanks again for your help. I had tried it several different ways but it always seemed that I was getting the same result. I found out that the problem was that my browser wasn't refreshing properly each time I would modify the code. It's working now. One other question though: If the string that is being submitted in the textarea field is giving me the desired result, basically, it's not being cut off at the quotes, should I still use htmlentities() for it?
  11. I AM using htmlentities with ENT_QUOTES as the second parameter... <?php if (isset($_POST['submit'])) { $staffmessage = $_POST['staffmessage']; $studentmessage = $_POST['studentmessage']; echo htmlentities($staffmessage, ENT_QUOTES); echo "<br /> <br />"; echo htmlentities($studentmessage, ENT_QUOTES); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $message1="This is a test message. It does not get cut off here when the \"quotation marks\" are added."; $message2="This is a test message. It DOES get cut off here when the \"quotation marks\" are added."; ?> <form name="form" method="post" action="test.php"> <textarea class="textarea" name="staffmessage" rows="12"> <?php echo $message1; ?> </textarea></p> <input name="studentmessage" type="hidden" value="<?php echo $message2; ?>" /> <input class="submit2" type="submit" name="submit" value="Send Message" /> </form> </body> </html> The result I'm getting is the same. Am I using htmlentities properly, or should I be doing something differently?
  12. Now I'm adding this code: <?php $staffmessage1 = $_POST['staffmessage']; $studentmessage1 = $_POST['studentmessage']; $staffmessage = htmlentities($staffmessage1); $studentmessage = htmlentities($studentmessage1); echo "$staffmessage<br />&nbsp<br />$studentmessage"; ?> and I'm getting the same result... I don't understand what's wrong here...
  13. Thanks very much for your quick responses! Can either of you explain why I was having this problem with the string submitted in the "hidden" field and not the string submitted in the "textarea" field? I was VERY confused about this...
  14. Hello everyone, I'm having a difficult time figuring out what my problem is here. I'm trying to submit a couple of strings (to the user they are messages to be sent to other users) and I am having trouble with the string being cut off at quotation marks. Here is the code that I'm using: <?php if (isset($_POST['submit'])) { $staffmessage = $_POST['staffmessage']; $studentmessage = $_POST['studentmessage']; echo "$staffmessage<br />&nbsp<br />$studentmessage"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?php $message1="This is a test message. It does not get cut off here when the \"quotation marks\" are added."; $message2="This is a test message. It DOES get cut off here when the \"quotation marks\" are added."; ?> <form name="form" method="post" action="test.php"> <textarea class="textarea" name="staffmessage" rows="12"> <?php echo $message1; ?> </textarea></p> <input name="studentmessage" type="hidden" value="<?php echo $message2; ?>" /> <input class="submit2" type="submit" name="submit" value="Send Message" /> </form> </body> </html> The result that I'm getting is that when $staffmessage is echoed, I get the full message. When $studentmessage is echoed, the message gets cut off at the first quotation mark. The only thing that is different when creating these two variables is that $staffmessage is submitted using a "textarea" field in the form, and $studentmessage is submitted using a "hidden" field in the form. Other than that, they are handled the exact same way. Can anyone please help me figure out how to remedy this so that $studentmessage is not cut off at the quotation mark? Thanks in advance for your help!
  15. Well, I still have no idea what the problem was, but I re-wrote the code for the entire page, and now everything is working fine. I think it had something to do with my server. Oh well, it works now. Thanks.
  16. what do you mean "echo the queries?" Sorry, I'm still learning.
  17. OK, different query, different problems... When I use this: mysql_query("UPDATE `staff` SET `email` = '$email',`pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Only the pword field is updated... This: mysql_query("UPDATE `staff` SET `email` = '$email' WHERE staffid = '$staffid'") or die (mysql_error()); mysql_query("UPDATE `staff` SET `pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Only updates the email field... And this: mysql_query("UPDATE `staff` SET `pword` = '$pword' WHERE staffid = '$staffid'") or die (mysql_error()); Does absolutely nothing... I'm getting no errors at all. Any ideas?
  18. I just realized that. This is what too much work will do to you... make you overlook silly mistakes. Thanks.
  19. Sorry, just realized I posted this in PHP Coding Help and not MySQL help...
  20. Hey everyone, I'm getting this error message: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE email = 'ataylor'' at line 1" On this code: " mysql_query("INSERT INTO `staff` (email,pword) VALUES ('$email','$pword') WHERE email = 'ataylor'") or die (mysql_error()); I'm having a hard time figuring out what is wrong. Any help is appreciated.
  21. That works! 2 hours of trying everything I could think of, and I come to PHPFreaks.com and my problem is solved in less than 5 minutes! Wow! THANK YOU SIR... AGAIN! Is this just one of those IE things, or is there a good reason that this works the way it does?
  22. Hello everyone, I have a page with a short form with just a password field and a submit button. I also have php code setting variables depending on whether or not the password is correct. When the password is entered and the submit button is CLICKED, everything works as it should. However, when the password is entered and the ENTER button is pushed to submit the form, the form is reset and nothing else happens. Also, this only happens in I.E., it works fine with Firefox. I have plenty of other forms that I use in the same manner but they all work whether the submit button is clicked or the enter button is pushed to submit, regardless of what browser is used. The idea is to have this window close (it's opened as a pop-up) and the main window load the next page. Again, it works perfectly as long as the submit button is clicked but not if the enter button is pushed. Not sure if it has something to do with my php code or what. Any ideas on how to fix this? Here's my code: <?php if (isset($_POST['submit'])) { $pword = md5($_POST['pword']); $q = mysql_query("SELECT * FROM `accounts` WHERE acct_number = '$acct' AND pword = '$pword'") or die (mysql_error()); $r = mysql_num_rows($q); // Checks to see if anything is in the db. if ($r == 1) { $student = "true"; } else { $student = "false"; } } else { $student = "unknown"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Student Verification...</title> </head> <!-- <body> tag is in PHP --> <?php if ($student == "true") { echo "<body onunload=\"opener.location=('signup.php?acct1=$acct')\">"; } else { echo "<body>"; } if ($student == "true") { echo "<div align='center'>"; echo "<p><font size='+2'>Passcode Correct!</font></p>"; echo "</div>"; echo "<div align='justify'>"; echo "<p>You will now be directed to the signup page.</p>"; echo "</div>"; echo "<div align='center'>"; echo "<p>Thank you.</p>"; echo "<input type='button' value='Continue to Signup...' onClick='window.close()'>"; echo "</div>"; echo "<meta http-equiv=\"REFRESH\" content=\"20;url=close.php\">"; } elseif ($student == "unknown") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p>Please enter the school passcode.</p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' id='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } elseif ($student == "false") { echo "<div align='center'>"; echo "<table width='325' height='175' border='0' cellspacing='0' cellpadding='0'>"; echo "<tr>"; echo "<td width='325' align='center' valign='middle'>"; echo "<p><font size='+1'><strong>Welcome!</strong></font></p>"; echo "<p><font color='#FF0000'>Incorrect Passcode! Please try again.</font></p>"; echo "<form name='form' method='POST' action='schoolpw.php'>"; echo "<p><input type='password' name='pword' size='30' maxlength='20' /></p>"; echo "<input type='submit' name='submit' value='Submit' /> "; echo "<input type='button' name='cancel' value='Cancel' onClick='window.close()' />"; echo "</form>"; echo "</p>"; echo "</td>"; echo "</tr>"; echo "</table>"; echo "</div>"; } ?> </body> </html>
  23. Hello everyone, I don't know much about javascript but I managed to put the following code together: <head> <script type="text/javascript"> function checkValue() { var linkemail=document.forms["theForm"]["linkemail"].value if (linkemail == 'y') { document.getElementById('xtraInfo').style.display=''; } else { document.getElementById('xtraInfo').style.display='none'; } } </script> </head> <body> <form id="theForm" name="theForm" method="post" action=""> <input type="checkbox" name="linkemail" value="y" onClick="return checkValue(this)" /> Check here to link your email. <div id="xtraInfo" style="display:none;"> Email <input name="name" type="text" id="name" /> </div> </form> </body> I'm trying to get the textbox to show when the checkbox is selected (which DOES work) and the textbox to disappear when the checkbox is deselected (which is where I'm having the trouble. Can anyone help me figure this out please?... Thanks for any help!
×
×
  • 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.