Jump to content

1 question, 1 problem.


AshleyByrom

Recommended Posts

Okay well I am making a simple private messaging system where when a user creates a message that adds a row to a database then when you go on your inbox you get all the messages where read='0' (false) and touser=(their username)

 

One question I have is in the inbox, I want a simple preview of messages I do not want to display the full message. So is there any way I can restrict the amount of characters that are displayed? Say, the first 50 or the first 100.

 

My problem I also face is here is my query:

 

$connectToInboxQuery = "SELECT * FROM messages WHERE touser='" . $_SESSION["theUSERNAME"] . "' AND read='0'";

 

and here is the MySQL error I get:

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=0' at line 1

 

Any help is appreicated!

 

Link to comment
Share on other sites

The issue is with you using mysql reserved terms in your table/db.

You can see them here:

http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

 

The sticking point is your field name "read". This is a reserved name. I suggest you either do what Coreye suggested and use backticks (`) around the word read. Or change the field name from read to something that isnt a reserved term. The latter is better for compatibility as backticks are not technically valid SQL and therefore if you were to import the database into another database server you may experience issues.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.