Jump to content

tvdhoff

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tvdhoff's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi all, I need to strip all HTML tags from user input, save and . I'm trying regular expressions, but am having big trouble getting those to work. I thought of something like this (if found a tag with something else then 'i' remove tag): preg_replace(?(?=<[^i]+>)""); But that doesn't work. How would I go about that? Thanks a lot! Tim
  2. If I run your code it runs as expected...
  3. tvdhoff

    Hi again

    Hi, You don't need extra tables: you could add an extra column called 'status' and give each of those possibilities a value, ie. 'Work Done' = '1', 'In Progress'=2 etc. You could create an extra table to store those status IDs and add a column for the names that go with it. If you really want to store it in a new table you would need to make a combined create table and select statement, like: [code] CREATE TABLE worktomorrow SELECT values,work,now FROM worknow; [/code]
  4. Because one way or another, you're not logged in. You either: - made a typo in your variables and are requesting an empty variable - set that session variable without putting data into it Now, I don't see any typos in your code, so try echoing that variable as I suggested and see if it returns as expected.
  5. If you call session_start() multiple times, you'll only get a warning or even a notice. The function checks if a session exists and if so continues that session or else makes a new one. So no worries there..
  6. Hi, Try echoing those session variables you try to set: [code] echo "Username: " . $_SESSION["username"]; [/code] If it doesn't return the username you've set, then that's your problem. BTW: you can make your code more compact by combining that username and password query: [code] $encryptpass = md5($Password); $sql_user_check ="SELECT * FROM users WHERE username=\"$Username\" AND password=\"$encryptpass\""; and then: if ($usersfound == "1") { .... [code] If there's exactly one match then you've found the user that has both that username and password... Good luck! [/code][/code]
  7. Hi all, This calendar page uses two database tables: 'calendar'  which holds the appointment info and which is linked using column 'location_id' with table 'locations' which holds the location details. On the overview page I retrieve appointments using this query which works fine: [code] $listAppointmentsQuery="SELECT id,name,DATE_FORMAT(date,'%d-%m-%Y') AS date,time,location_name                                   FROM calendar INNER JOIN locations USING (location_id)                                   ORDER BY date DESC"; [/code] However, when a user deletes a location, the appointments that have that location are not displayed using this query. Is there a way to modify the query so that those entries are displayed (with an empty location) as well? I'd rather not have to run through all appointments resetting their location_id when a location is deleted.... thanks! Tim
  8. Try: [code] $content=$row["contentFromDB"]; $shortContent=substr($content,0,40); [/code] Where '0' is the start character of the string ($content) you are using and '40' is the number of characters that will be outputted.
  9. If you mean to say what Andy writes, then yes, all old rows will have that new column as well. Why would you want to do such a thing, anyway?
  10. [quote author=ryanlwh link=topic=102725.msg408238#msg408238 date=1154539799] hmm.. why don't you run something like this? [code](SELECT id,title FROM content WHERE id >= $id and category=$category ORDER BY id ASC LIMIT 3) UNION (SELECT id,title FROM content WHERE id <= $id and category=$category ORDER BY id DESC LIMIT 3) ORDER BY id DESC[/code] tested with some of my own data... it will get 5 records and surround it by 2 older and 2 newer. you use limit 3 on both queries, but UNION is distinct, so the duplicated one, which is the middle record, will be replaced by itself. [/quote] Thanks, that actually does the trick. It's practically the same as my initial solution, but as you correctly put it, the duplicate row gets replaced and becomes the third row if there are at least five rows in the recordset to limit down to five. This is good enough, though I would like to know if you could think of a way to make sure there are always five rows outputted. I can only imagine that you would first have to run the query and find the number of rows and then modify the query as needed to get five rows back (without $id being the middle row in that case). It's not really needed for functionality, but it's nicer aesthetically speaking - as long as it doesn't take to much resources.... Any thoughts? Thanks. Tim
  11. Hi, thanks for the attention. What I want is this: [quote] I have a page that displays a publication from a database and want to have a short list of other titles next to it, as to use it for navigating those publications. The list should contain five entries, the publication that is displayed should be in the middle and should be surrounded by two newer and two older entries. [/quote] A normal table with an autoincrementing primary key column called 'id' can be queried for this purpose like this: [code]SELECT id,title FROM content WHERE id >= $id-2 ORDER BY id ASC LIMIT 5[/code] But in my case, I have a table called 'content' which contains different types of data. A column called 'category_id' is used to keep track of those different kinds of data. Because of this mixed data, I can't rely on the primary key 'id' as in the example above to make that list of five consecutive titles (that are of the same category type). My solution was to create a temp table to first get a set of rows that are of the same category and give them an extra temp_id and then run that first query to get that list of five titles. However, the present code (as displayed in first post) gives an error 'can't reopen table' and needs fixing. Furthermore, I can't imagine there not being a less expensive way to get the desired result. I hope I made myself clearer than before. Looking forward to your reply. Thanks, Tim
  12. You can define in your php.ini file what mailserver to use. On windows it allows you to set an smtp server in the mail function. You can just specify the hostname or ip address of that other server. Should work..
×
×
  • 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.