Jump to content

dazzathedrummer

Members
  • Posts

    101
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

dazzathedrummer's Achievements

Member

Member (2/5)

0

Reputation

  1. Yes - I've just added it and it now works fine!! thanks for your help - I guess I should read up on this!
  2. session_start(); is in the second include that appears on each page once you're through the door - but not on the initial login include.....should it be?
  3. Hi, The 'admin' section of my website stopped working a couple of months ago and I'm just trying to fix it - I was getting an error about Session_Register being deprecated and I'm now trying to knife and fork my way around it with results from various google searches. I'm an advanced SQL user but only occasionally dabble with PHP so any help would be appreciated. So, basic set up, login page checks credentials against the DB, a session cookie is set and you're let into the admin area - my script is looping me back to the login page as my !isset is true.....because I can't figure out how to set it with the new functions! This is the login include..... <?php $host="database.lcn.com"; // Host name $username="blahblah"; // Mysql username $password="blahblah"; // Mysql password $db_name="blahblah_db"; // Database name $tbl_name="users"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['username']; $mypassword= md5($_POST['pass']); // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM users WHERE is_obv = '1' and username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['username'] = $myusername; $_SESSION['pass'] = $mypassword; header("location:../admin"); } else { header("location:http://www.web.co.uk/ooops"); } ?> and this is the 'login_success' include that I include on each protected page.... <? session_start(); if(!isset($_SESSION['username'])){ header("location:http://www.web.co.uk/login"); } ?> Darren
  4. Can anyone help with this? or point me in the direction of a script that I can use? thanks, Darren
  5. ...yeah - I tried to rebuild the script from scratch.... <? // Connects to your Database include '/connect_include.php'; $query = " SELECT gl_id as 'id', '' as 'last_update', 'name' as 'name', 'fname' as 'firstname', 'sname' as 'surname', 'confirmed' as 'status', concat(left(gl_date,4), mid(gl_date,6,2), mid(gl_date,9,2),'T210000Z') as 'starts', concat(left(gl_date,4), mid(gl_date,6,2), mid(gl_date,9,2),'T235959Z') as 'ends', case when gl_unavailable = '1' then gl_comments else gl_venue end as 'location_name' FROM tg_gig_list where gl_date >= curdate() and year(gl_date) = year(curdate()) and gl_delete <> 1 order by gl_date asc"; $result = mysql_query($query); define('DATE_ICAL', 'Ymd\THis\Z'); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "BEGIN:VEVENT SUMMARY:{$row['surname']}. UID:{$row['id']}". strtoupper("{$row['status']}"). date(DATE_ICAL, strtotime("{$row['starts']}")). date(DATE_ICAL, strtotime("{$row['ends']}")). date(DATE_ICAL, strtotime("{$row['last_update']}")). "{$row['location_name']}". "END:VEVENT\n" ; } mysql_close(); ?> This gives the following output..... BEGIN:VEVENT SUMMARY:sname. UID:2310CONFIRMED20121123T220000Z20121124T005959Z19700101T010000ZDazza unavailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2249CONFIRMED20121124T220000Z20121125T005959Z19700101T010000ZO'Neill'sEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2226CONFIRMED20121130T220000Z20121201T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2227CONFIRMED20121201T220000Z20121202T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2395CONFIRMED20121201T220000Z20121202T005959Z19700101T010000ZO'Neill'sEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2228CONFIRMED20121202T220000Z20121203T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2306CONFIRMED20121207T220000Z20121208T005959Z19700101T010000ZThe Burghley ClubEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2401CONFIRMED20121208T220000Z20121209T005959Z19700101T010000ZThe London InnEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2397CONFIRMED20121214T220000Z20121215T005959Z19700101T010000ZEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2139CONFIRMED20121215T220000Z20121216T005959Z19700101T010000ZO'Neill'sEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2230CONFIRMED20121215T220000Z20121216T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2398CONFIRMED20121215T220000Z20121216T005959Z19700101T010000ZEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2231CONFIRMED20121216T220000Z20121217T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2399CONFIRMED20121216T220000Z20121217T005959Z19700101T010000ZEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2250CONFIRMED20121221T220000Z20121222T005959Z19700101T010000ZQuinnsEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2312CONFIRMED20121222T220000Z20121223T005959Z19700101T010000ZDazza unavailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2232CONFIRMED20121228T220000Z20121229T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2233CONFIRMED20121229T220000Z20121230T005959Z19700101T010000ZDazza unanvailableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2256CONFIRMED20121229T220000Z20121230T005959Z19700101T010000ZGav not availableEND:VEVENT BEGIN:VEVENT SUMMARY:sname. UID:2234CONFIRMED20121230T220000Z20121231T005959Z19700101T010000ZDazza unanvailableEND:VEVENT ....so, my (dumb) question now is......how do I get line breaks into this?
  6. Hi, I've been looking for a way to create an iCal feed from my calendar database (a MySQL db that my users update from php forms). I found the following code on this blog...http://stevethomas.c...-and-mysql.html code: <?php // the iCal date format. Note the Z on the end indicates a UTC timestamp. define('DATE_ICAL', 'Ymd\THis\Z'); // max line length is 75 chars. New line is \\n $output = "BEGIN:VCALENDAR METHOD:PUBLISH VERSION:2.0 PRODID:-//Thomas Multimedia//Clinic Time//EN\n"; // loop over events foreach ($query_appointments->result() as $appointment): $output .= "BEGIN:VEVENT SUMMARY:$appointment->firstname $appointment->surname UID:$appointment->id STATUS:" . strtoupper($appointment->status) . " DTSTART:" . date(DATE_ICAL, strtotime($appointment->starts)) . " DTEND:" . date(DATE_ICAL, strtotime($appointment->ends)) . " LAST-MODIFIED:" . date(DATE_ICAL, strtotime($appointment->last_update)) . " LOCATION:$appointment->location_name $appointment->name END:VEVENT\n"; endforeach; // close calendar $output .= "END:VCALENDAR"; echo $output; ?> ....it looks like it would do the trick.......I'm not brilliant at PHP, but I get by OK.......I assume that all I need to do is create a query from my DB that will populate the fields in the FOREACH loop. I created a query and tested it by outputting it to a table - it works fine....I get a full list of my calendar entries. So, I put query into the code like this (you'll note that some of the fields are dummies for testing purposes).. <?php // Connects to your Database include '/connect_include.php'; $query = " SELECT gl_id as 'id', '' as 'last_update', 'name' as 'name', 'fname' as 'firstname', 'sname' as 'surname', 'confirmed' as 'status', concat(left(gl_date,4), mid(gl_date,6,2), mid(gl_date,9,2),'T210000Z') as 'starts', concat(left(gl_date,4), mid(gl_date,6,2), mid(gl_date,9,2),'T235959Z') as 'ends', case when gl_unavailable = '1' then gl_comments else gl_venue end as 'location_name' FROM tg_gig_list where gl_date >= curdate() and year(gl_date) = year(curdate()) and gl_delete <> 1 order by gl_date asc"; $query_appointments = mysql_query($query); // the iCal date format. Note the Z on the end indicates a UTC timestamp. define('DATE_ICAL', 'Ymd\THis\Z'); // max line length is 75 chars. New line is \\n $output = "BEGIN:VCALENDAR METHOD:PUBLISH VERSION:2.0 PRODID:-//Thomas Multimedia//Clinic Time//EN\n"; // loop over events foreach ($query_appointments->result() as $appointment): $output .= "BEGIN:VEVENT SUMMARY:$appointment->firstname $appointment->surname UID:$appointment->id STATUS:" . strtoupper($appointment->status) . " DTSTART:" . date(DATE_ICAL, strtotime($appointment->starts)) . " DTEND:" . date(DATE_ICAL, strtotime($appointment->ends)) . " LAST-MODIFIED:" . date(DATE_ICAL, strtotime($appointment->last_update)) . " LOCATION:$appointment->location_name $appointment->name END:VEVENT\n"; endforeach; // close calendar $output .= "END:VCALENDAR"; echo $output; ?> .....with this I'm getting an error on the foreach line.....presumably the loop is unable to load the data for some reason?? I must admit that the syntax for the loop isn't something that i've seen before - I usually use a "while($row = mysql_fetch_array($result, MYSQL_ASSOC))" and then call the fields using {$row['name']} etc. Would appreciate some pointers on this. Thanks, Darren
  7. Hi, I have a website with a simple calendar function, dates are put in using $post and i've created pages to edit and delete entries etc. At the moment I just publish a list of dates - I'm wondering how simple it would be to create some kind iCal thing whereby a user subscribes to a feed on my website for viewing the calendar in iCal? I've googled this and not come up with very much. thanks, Darren
  8. Hi, I have a very basic page that puts a list of dates from a mysql database into a list in order of date like this... echo' <h1>Gigs</h1> <table width=\"400\" height=\"200\" >'; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {echo "<form action=\"giglist_private_update.php\" method=\"post\">". " <tr> <td style=\"height:80px; width:80px;\"valign=\"top\"> <img height=\"79px\" width=\"79px\" valign=\"top\" alt=\"calendarpic\" style=\"position:absolute; vertical-align:top; z-index:1;\" src=\"calpics/{$row['background']}.png\"/> <img height=\"79px\" width=\"79px\" valign=\"top\" alt=\"calendarpic1\" style=\"position:absolute; vertical-align:top; z-index:2;\" src=\"calpics/{$row['day']}.png\"/> <img height=\"79px\" width=\"79px\" valign=\"top\" alt=\"calendarpic2\" style=\"position:absolute; vertical-align:top; z-index:3;\" src=\"calpics/{$row['month']}.png\"/></td>". "<td colspan=\"3\"><font size=\"4\"><strong>{$row['gl_venue']} {$row['gl_city']}, {$row['gl_postcode']} </td><td>{$row['pf']}{$row['publish']}{$row['unavailable']}</td>". "<td colspan=\"2\"><a href=\"http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=&q={$row['gl_postcode']}\">Map</a></td><td>". "<form action=\"giglist_private_entry.php\" method=\"post\">". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_date\" value=\"{$row['gl_date']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_venue\" value=\"{$row['gl_venue']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_postcode\" value=\"{$row['gl_postcode']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_city\" value=\"{$row['gl_city']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_phone\" value=\"{$row['gl_phone']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_contact\" value=\"{$row['gl_contact']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_net\" value=\"{$row['gl_net']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_comments\" value=\"{$row['gl_comments']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_text\" value=\"{$row['gl_text']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_pf\" value=\"{$row['gl_pf']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_id\" value=\"{$row['gl_id']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_unavailable\" value=\"{$row['gl_unavailable']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_next_gig\" value=\"{$row['gl_next_gig']}\"></td>". "<td display=\"none\"><td><input type=\"hidden\" name=\"gl_publish\" value=\"{$row['gl_publish']}\"></td>". "<td><input type=\"submit\" value=\"Details\">" ; } echo '<tr style=\"height:40px\"></tr></tr></table><br><br>'; The hidden fields post the details from the query to memory so they can be displayed on an 'edit' page. How do I go about grouping this list by month?? My instincts are telling me to create a field in the mysql query that returns the month (month(gl_date) with a case statement for '1='January' etc). Then what do I do.......is it an array of arrays? how do I code that?
  9. Solved! $array = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $array['gigs'][$row['monthYear']][] =$row; } $output = json_encode($array); } gives me what I want.
  10. This is as close as I've got. If I do this.... $array = array(); $array['gigs'] = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $array[$row['monthYear']] =$row; } $output = json_encode($array); I get the right sort of result, but there's an empty set of square brackets at the start..... { "gigs": [ ], "May, 2011": [ { "monthYear": "May, 2011", "dateVenue": "14-05-2011, Queen Victoria hall", "date": "14-05-2011", "venue": "Queen Victoria hall", "city": "Oundle", "postcode": "PE8 4EJ", "description": "", "imageName": "14May.png" }, { "monthYear": "May, 2011", "dateVenue": "19-05-2011, O'Neill's", "date": "19-05-2011", "venue": "O'Neill's", "city": "Peterborough", "postcode": "PE1 1SQ", "description": "This one is another outing for Jason and Darren's acoustic duo, the pair will be playing a selection of their favourite songs as well as some tunes from the guards set.<br \/>\r\n<br \/>\r\n19:00 to 21:00", "imageName": "19May.png" }, { "monthYear": "May, 2011", "dateVenue": "21-05-2011, The Old Bridge Hotel", "date": "21-05-2011", "venue": "The Old Bridge Hotel", "city": "Huntingdon", "postcode": "PE29 3TQ", "description": "", "imageName": "21May.png" }, { "monthYear": "May, 2011", "dateVenue": "29-05-2011, The Bell", "date": "29-05-2011", "venue": "The Bell", "city": "Sawtry", "postcode": "PE28 5UY ", "description": "We'll be joining in the fun at the Bell as part of their charity day in aid of Help the heroes and CARESCO.<br \/>\r\nThis is an all day fun day event that starts at 1pm.<br \/>\r\n<br \/>\r\nWe'll be on stage at 9pm.", "imageName": "29May.png" } ], "June, 2011": [ { "monthYear": "June, 2011", "dateVenue": "04-06-2011, ", "date": "04-06-2011", "venue": "", "city": "Cambridge", "postcode": "", "description": "", "imageName": "4June.png" },............ { How do I get rid of those brackets??
  11. Hi, I've got the follow array: Query: SELECT concat(monthname(gl_date),", ",year(gl_date)) as "monthYear", concat(DATE_FORMAT(gl_date,"%d-%m-%Y"),", ",gl_venue) as "dateVenue", DATE_FORMAT(gl_date,"%d-%m-%Y")as "date", gl_venue as "venue", gl_city as "city", gl_postcode as "postcode", gl_text as "description", concat(DAYOFMONTH(gl_date), MONTHNAME(gl_date),".png") AS "imageName" FROM tg_gig_list where gl_date >= curdate() and gl_publish = 1 order by gl_date Array: $array = array(); $array['gigs'] = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $array['gigs'][] =$row; } $output = json_encode($array); This returns JSON like this: - { "gigs": [ { "monthYear": "May, 2011", "dateVenue": "14-05-2011, Queen Victoria hall", "date": "14-05-2011", "venue": "Queen Victoria hall", "city": "Oundle", "postcode": "PE8 4EJ", "description": "", "imageName": "14May.png" }, { "monthYear": "May, 2011", "dateVenue": "19-05-2011, O'Neill's", "date": "19-05-2011", "venue": "O'Neill's", "city": "Peterborough", "postcode": "PE1 1SQ", "description": "This one is another outing for Jason and Darren's acoustic duo, the pair will be playing a selection of their favourite songs as well as some tunes from the guards set.<br \/>\r\n<br \/>\r\n19:00 to 21:00", "imageName": "19May.png" }, {.......next record I'd like the data to be arranged by the 'monthYear' field....something like this... { "gigs": [ "monthYear": "May, 2011" { "monthYear": "May, 2011", "dateVenue": "14-05-2011, Queen Victoria hall", "date": "14-05-2011", "venue": "Queen Victoria hall", "city": "Oundle", "postcode": "PE8 4EJ", "description": "", "imageName": "14May.png" }, {......all gigs for 'May, 2011' } "monthYear": "June, 2011" {....records for 'June, 2011' so 'gigs'=>'monthYear'=>'other records' I've tried all sorts of combinations of putting the '$row['monthYear']' field in different places in the array, but I seem to loose data by doing so for some reason. any input greatly appreciated. Darren
  12. just having a look at my data, I'm using mysql_real_escape_string to put the text into the database, the only characters that are coming out of (stored in) the database are "\r\n" for line breaks, these get processed fine in HTML but come through as they are when I take them into an Xcode textarea. Thinking about this I could probably leave them where they are and find/replace them in a method in Xcode - sound like a question for the iOS dev forum! Thanks anyway everyone - for helping me to get to that conclusion!
  13. Thanks for your input, I'm ok on how to remove the escape characters, I'm just wondering what the most efficient way of getting the array would be?
  14. Hi, I have an array that I've set up as a JSON feed API. The array pulls data from a MySQL query, one of the fields in the query ('description') contains text with escape characters. I'm just wondering how I change either the query to remove the escape characters (ie can you strip escape chars in MYSQL?) - or change the array to strip the escape chars?? //Run query $result = mysql_query(' SELECT DATE_FORMAT(gl_date,"%d-%m-%Y")as "date", gl_venue as "venue", gl_city as "city", gl_postcode as "postcode", gl_text as "description", concat(DAYOFMONTH(gl_date), MONTHNAME(gl_date),".png") AS "imageName" FROM tg_gig_list where gl_date >= curdate() and gl_publish = 1 order by gl_date '); $array = array(); $array['gigs'] = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $array['gigs'][] = $row; } $output = json_encode($array); }
  15. excellent, that works brilliantly!! now I just need to figure out how to get that into an NSDictionary - but that's a question for a different forum haha! thanks again! ....just out of interest, why is $array declared twice? Darren
×
×
  • 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.