Jump to content

elmas156

Members
  • Posts

    276
  • Joined

  • Last visited

Everything posted by elmas156

  1. elmas156

    Collation

    Sorry, I had some things come up and I have been out of the loop for a few days. I'll be storing English and maybe some Spanish. Thanks.
  2. elmas156

    Collation

    Ok, I'm probably going to sound ignorant here, which I am on this subject, but I need to figure this out. What is the collation and how would I know which is the best to use for my application? What I'm creating is a messaging system, very similar to email, but it will only be capable of sending and receiving messages to and from other users of the system. Much like the myspace and facebook messaging systems. Can someone please explain and help me to understand? Thanks for any help.
  3. I've got a simple internal messaging system that I'm trying to get the text to display the way it was entered when a message was sent. The messages are inserted into the database using variables generated through this function: <?php function safe($value){ return mysql_real_escape_string($value); } $staffid=form($_POST['staffid']); $from=safe($_POST["from"]); $category=form($_POST['category']); $subject=safe($_POST["subject"]); $message=safe($_POST["message"]); $grade=form($_POST['grade']); ?> when the text is inserted, there are back slashes automatically inserted behind certain punctuation marks. For example, is someone sends a message that says, "Someone's using phpfreaks forums." It would be inserted as, "Someone\'s using phpfreaks forums." How can I stop this from happening? Or how can I remove the "\" when displaying the string on the web page? Any help is greatly appreciated.
  4. I have a form for a sign in page that I want the label for the form field to actually be displayed in the text box and clear when the box is selected to enter text. I've accomplished this using the code below and it works fine. The problem that I'm having is in IE the password field does not change to display dots or asterisk in place of each character. It works fine in Fire Fox but not in IE. Is there way to accomplish this using php or so that it is compatible with most browsers? Here's the code that I'm using: <?php echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password';}\"> "; ?>
  5. I solved it... the action on the forms was set to head.inc.php, which was causing the page to get stuck on that page when the login info was incorrect rather than going back to the index page and displaying the head.inc.php as an included file. I just changed the action to index.php. Now it works fine because the form variables are still being processed through head.inc.php since it is included on the index page. If anyone has a better or more logical solution, I would be glad to hear it. Thanks to all who looked at my code and attempted to help.
  6. Hello everyone. I'm having a problem with what should be a fairly simple login system that is included on the index page of my site. Basically, it is set up to display a short form so that the user can enter his/her email address and password to log in. If there is a mistake with the email/password, it displays the same form with a notification that there was an incorrect email or password. The problem that I'm having is that when the wrong email/password is entered, the page goes to the next step of notifying the user of the incorrect information but it does not display the rest of the page that it is included on. What is happening is when the user arrives at the site it displays the index.php page, which is currently a blank page with some simple text, and the included page mentioned above. When an incorrect email/password is entered, instead of staying on the index page and displaying the included page with the login form, the user is redirected away from the index page to the included page only. Here's my code for "head.inc.php": <?php include("conf.inc.php"); // Includes the db and form info. session_start(); // Starts the session. if ($_SESSION['logged'] == 1) { // User is already logged in. $_SESSION['email'] = $email; header("Location: main.php"); // Goes to main page. exit(); // Stops the rest of the script. } else { if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted. echo "<form name=\"form\" action=\"head1.inc.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a> <br>"; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password'}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\"> "; echo "</form>"; } else { // If the form HAS been submitted $email = form($_POST['email']); $pword = md5($_POST['pword']); // Lightly encrypts the password. $q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query $r = mysql_num_rows($q); // Checks to see if anything is in the db. if (!$r) { // There is something in the db. The username/password match up. echo "<form name=\"form\" action=\"head1.inc.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a> <br>"; echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font> "; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"text\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000'; this.type='password'}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\"> "; echo "</form>"; } else { // If the username/password is invalid $_SESSION['logged'] = 1; // Sets the session. $_SESSION['email'] = $email; header("Location: main.php"); // Goes to main page. exit(); // Stops the rest of the script. } } } ?> Here's the code for "index.php": <?php include("head.inc.php"); echo "This is the index page"; ?> Any ideas on how to stop the redirection from the index page when the incorrect info is entered?
  7. My fault for trying to type too fast. The code that I have works fine... no errors or anything. The code that I posted is just generic code to try to show what I'm trying to do. I'm not using the same computer to post here as I am to write my code so copying and pasting the code would be out of the question... I'm just trying to find out how to make the text in the textbox bold. Thanks for your reply.
  8. I have a text box for users to enter new text in. The box also contains text that is determined by a variable that is created from a mysql query and some other added text. I want to make a portion of the added text within the textbox bold. How would I achieve this with php? <?php result = mysql_query("SELECT `something` FROM `table` WHERE `this` = '$that'"); row = mysql_fetch_row($result); $variable = $row[0]; $text = "<strong>Here is the text that I want bold</strong> $variable"; echo "<textarea name=\"textbox\">"; echo "$text"; echo "</textarea> ?> Doing this gives me this result in the textbox: "<strong>Here is the text that I want bold</strong> This is what the variable text says." Any ideas?
  9. thanks... I'll check out triggers... if I have any trouble with that, I'll try some other ideas that I thought of since posting this thread. Thanks again for your help!
  10. I've got multiple tables I'm using for an internal messaging system that I'm creating. I'm trying to keep the same message id ('messid') for messages regardless of what table they are saved in (inbox, saved, deleted...). To do this, I've created a table named "allmessages" where every message sent is inserted and the 'messid' is generated using auto increment. This allows me to keep all the information on all sent messages in one place rather than having to pull certain information from different tables. From there, the message will keep the 'messid' when inserted into "allmessages". Here's the problem I'm having: at the same time that I insert the information into the "allmessages" table, I need to insert some of the information into another table as well, including the 'messid' generated from the AI in "allmessages". BUT as of now, I have no way to pull just that specific message because 'messid' is the only unique field that I have to use when querying the database. Basically, if I use any other field (Like: "SELECT `messid`,`staffid`,`message`FROM `allmessages` WHERE `anything other than messid` = '$whatever'") I would get multiple results because 'messid' is the only unique field AND it's part of the information I need to pull from the database. I hope I'm making sense here... basically, I need to figure out a way to either use the 'messid' generated when inserted into "allmessages" and insert the same 'messid' into another table at the same time... OR use the 'staffid' field and pull all information from the last entry into "allmessages" and get the 'messid' to insert into a different table. I would greatly appreciate any help. I'm stumped on this one.
  11. Hey Keith (kickstart) You said that until recent versions of MySQL, a varchar field was limited to 255... what field type do you suggest if someone needs a field with a large amount of characters, such as a message or in this case, a bio? Thanks.
  12. Just a quick question about the behavior of MySQL when a field is set for auto increment... Lets say there are 100 entries with id numbers 1-100. If random entries are deleted from the table, then one is later re-entered with the same id number manually inserted rather than allowing the AI to assign a new number, will the next AI id number always be 101 or would it ever go to the next available number after the manually re-entered id number? I hope I explained that correctly... On a smaller scale, here's an illustration: id 1 2 3 4 5 id 2, 3, and 4 are deleted leaving this: id 1 5 if id 2 is re-inserted manually rather than allowing the auto increment to assign id 6, will the next auto increment id number continue at 6 or will it ever use the next available number, in this case, 3? id 1 2 - inserted manually 5 (3 or 6?) - new auto increment number Thanks for your help.
  13. OK Ethan, here is the solution to our problem. It works exactly how we want it, with the "..." at the end of the string. Plus it's a lot simpler than the other code. <?php $text = "This is whatever text you want to go into the table."; if (strlen($text) > 40) { $short_text = substr($text,0,40); echo "$short_text..."; } else { echo "$text"; } ?> Thanks for your help in figuring this one out.
  14. Thanks Ethan, I'll give it a try and let you know how mine turns out.
  15. I found it... but I edited my last message to this: I'm not sure how I would use substr() to truncate if I don't know how long the string is before hand. Is there a way to truncate by determining how many characters you want displayed rather than how many characters you DON'T want displayed? By the way thanks for your help!
  16. Pikachu, can you tell me more about your solution? It sounds like it would be worth a try but I'm not sure how I would use substr() to truncate if I don't know how long the string is before hand. Is there a way to truncate by determining how many characters you want displayed rather than how many characters you DON'T want displayed?
  17. This sounds like it should be pretty simple but I've looked for a while and I'm having trouble finding an answer. What I have is a simple table with 3 columns with predetermined widths. When the text that is queried from the database is inserted into the table, and the text string is longer than the column width, it pushes the text to a second line, which throws the whole table out of whack. Instead, I want the text to be cut off before going to the next line. For example: This is what is happening: This is a sample string of text. This is what I'm trying to do: This is a sample string... Can anyone tell me where to find the solution to this problem? Not that it's needed, but here is some simple code that I'm working with: <?php $message = "This is a sample string of text."; echo "<table width=\"150\" height=\"20\"border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">Column 1</td>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">Column 2</td>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">$message</td>"; echo "</tr>"; echo "</table>"; ?>
  18. Wow, that was easy... I guess it helps to know where to look and the terminology to search for. Thanks for your help!
  19. Hello everyone. I'm creating a website that has a sort of messaging system built in and I'm trying to get the information pulled out of the database to display exactly as it was typed. For example, if someone types this message: "This is the first line. This is the second line. And this is two lines below the second line." (By the way, when I view this message using phpMyAdmin, the message is displayed in the above format.) I would like to have the message displayed the same way when it is queried from the database. As of now, this is what I'm seeing instead: "This is the first line. This is the second line. And this is two lines below the second line." How can I achieve this? I would post the code that I'm using, but it's just a basic mysql query to get a variable "$message" then I'm just using echo "$message"; to put it on the page. Any help to point me in the right direction would be greatly appreciated. Thanks!
  20. OK, first let me say that I'm testing locally, using MYSQL version 5.1.36 I'm creating a site that is designed to me sort of an internal messaging system much like email but messages will only be able to be sent to other users within the system. I've created a page to insert the message information into the database to be retrieved later and everything works perfectly until I use special characters that might normally be used in a message, such as apostrophes ( ' ). The type of field is set as varchar 20000. This is the only way that I know how to do it as I am learning as I progress. What can I do to get mysql to accept the message, including the special characters that are used? Also, is there a better field type I should be using? Thanks in advance for any help. This is the error that I get when a special character is used: Notice: Undefined index: grade in C:\wamp\www\insertmsg.php on line 40 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 'm going to see if this works.')' at line 1
  21. I'm getting the following error and I've looked everywhere but I can't figure out what's wrong... any suggestions? 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 'read = 'yes' WHERE messid = '1'' at line 1 Here's the code: mysql_query("UPDATE messages SET read = '$yes' WHERE messid = '$messid'") or die (mysql_error());
  22. Thanks everyone! The back ticks worked.
×
×
  • 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.