Jump to content

aleX_hill

Members
  • Posts

    143
  • Joined

  • Last visited

    Never

Everything posted by aleX_hill

  1. Sorry, remove the following line directly before the while loop $row = mysqli_fetch_assoc($result);
  2. I dont use a version control system, I just upload the files from dreamweaver. Much of the time there are edits to the other files on the website, ie the actual page structure, css files etc, the only similar file is the one holding the functions. Can you suggest a decent (preferably freeware) version control system for Windows?
  3. date("t",mktime(0,0,0,$nextmonth,1,date("Y"))); will give you the full name of the day for the first of the next month (ie "Sunday") I assume that you want to know which day (number) of the month the beginning and end of the week are, ie the sunday is on the 10th and the saturday is on the 16th: <?php $dayOfWeek = date("w"); //The number of the day of the week. Sun = 0, Sat = 1 $todayDayOfMonth = date("d"); //The day of the month $thisMonth = date("m"); //The number of this month. Jan = 1, Dec = 12 $firstDayOfWeek = $todayDayOfMonth - $dayOfWeek; //The day of the month for the beginning of the week (Sun) if($firstDayOfWeek < 1) //The beginning of the week was in the previous month { $monthBeginWeek = $thisMonth - 1; $firstDayOfWeek = $firstDayOfWeek + date("t",mktime(0,0,0,$monthBeginWeek,1,date("Y"))); } else { $monthBeginWeek = $thisMonth; } $lastDayOfWeek = $todayDayOfMonth + (6 - $dayOfWeek); //Get the day of the month of the end of the week (sat) if($lastDayOfWeek > date("t")) //if the day of the month is larger then the number of days in the month { $monthEndWeek = $thisMonth + 1; $lastDayOfWeek = $lastDayOfWeek - date("t"); //Then take the number of days in the week to get the day number of the next week } else { $monthEndWeek = $thisMonth; } echo "The week begins on ".date("l d F",mktime(0,0,0,$monthBeginWeek,$firstDayOfWeek,date("Y"))); echo "<br>"; echo "The week ends on ".date("l d F",mktime(0,0,0,$monthEndWeek,$lastDayOfWeek,date("Y"))); ?> There will be a problem if the beginning and end of the week span over the Dec 31/ Jan 1 range as I use date("Y") when I make the date in the last two lines. You can challenge yourself by using an if to check whether when you add on to $monthEndWeek is is over 12 (ie into the next year) or if $monthBeginWeek is < 1 (going into the previous year) and then set a $year variable to use it the display lines
  4. Well doesnt that suck. I wont be able to mount drives being on a hosted server. Looks like I am stuck with editing 10 files each time I make a small change Unless I write a cron to periodically replace the PHP files with the content from the "master" PHP file... now there is an idea
  5. Your problem is that $row only contains one row of data from the db. What I would do is something like this: <?php $sql = "SELECT reg FROM sales WHERE email='$_SESSION[logname]'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); $data = array(); //This way we can hold multiple results $i = 0; //The index of the array to add the result to while($row = mysqli_fetch_assoc($result)) { if ($row['reg'] != $_GET['reg'] ) { echo "I am sorry but '$_GET[reg]' does not seem to be registered by you!"; exit(); } else { //Why use two if statements? $data[$i] = $row['reg']; $i++; //increase the array index for the next while loop } } ?>
  6. Take a look at this: <?php $thisMonth = date("m"); //gets the 2 digit expression of the current month if($thisMonth == 12) //If we are in Dec { $nextMonth = "01"; //Make the next month Jan } else { $nextMonth = $thismonth + 1; //Otherwise add one the the current month } $daysInNextMonth = date("t",mktime(0,0,0,$nextmonth,1,date("Y"))); //set the time to the 1st of the next month of the current year (as the only time that the number of days change is in Feb, using current year is OK echo $daysInNextMonth; ?> All you need to know can be found at http://php.net/manual/en/function.date.php As for part two, I dont really understand what you are looking for.
  7. Ok, here is the situation. I have a few sites which all use the same functions (while connected to different dbs) to display content. Instead of updating each site when there is a change, I want to include all the display functions in one file, hosted on a different domain, and include that file on each site. So, being on shared hosting, allow_url_fopen isnt an option. I havent used CURL before, but I tried the code below, but that doesnt work either: $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://myurl.com/functions/siteFunctions1.0.php'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,10); curl_exec($curl_handle); curl_close($curl_handle); Is CURL an option for this, or is there another way that I can go about it? Cheers, Alex
  8. That looks like a good idea to me. Will give it a go tomorrow. The problem with removing tags is that I wont get the benefits of having them in there (ie links wont display). Thanks for the advice.
  9. Thanks for that. It is a little beyond my coding capabilities at the moment, but I will try and learn it when I get time. Hopefully in the mean time as a stop-gap measure someone can suggest something a little simpler.
  10. I have a string ($row['news']) extracted from my mysql database. Now if the string is too long, I want to trim it to 200 characters and put a "more" link at the end. The following does that fine: if(strlen($row['news']) > 200) { $row['news'] = substr($row['news'],0,200); $row['news'] .= " <a href=\"/news/id=$row[id]\">... read more</a>"; } The problem occurs when there is a HTML tag in the string (which is more then acceptable and required in this instance, mainly paragraph open and close tags). If the tag happens to be at the 200 character mark, I cut off half of the tag, which obviously causes display problems. So, is there a way that I can search the shortened string to see if I have trimmed a tag, and then remove that part of the tag. I would like to check for bold, italics, links and lists which are incomplete. Cheers
  11. Is it possible to add a checkbox to the bottom of the reply box to mark the topic as solved upon reply. If I find a solution to my problem I post it at the end to help the odd user who may actually use the search feature of the forum and find the post. It gets a little tedious to then open the thread again to click the "Marked Solved" button. If we could do it in one action it would be great.
  12. OK, I found a solution which works: $query = "SELECT * FROM mailinglist WHERE id = 'false'"; //the id=false just allows me to use the OR at the beginning of all statements below if($_POST['list1']) $query .= " OR list1='true'"; if($_POST['list2']) $query .= " OR list2='true'"; if($_POST['list3']) $query .= " OR list3='true'";
  13. I tried something similar to that with the list1='true' being similar to list1='$_POST[list1]' but I was getting users which had not subscribed to either of the selected lists. I will play around with the syntax and see what I can get. I think the error occurred when $_POST['list1'] was not selected and it matched users with list1='false' . Cheers, Alex
  14. OK, here is the situation. I have a mailing list with the following basic structure: id - int name - varchar email - varchar list1 - bool list2 - bool list3 - bool Now when the user sends an email to the group they get a checkbox for list1, list2 and list3. I want to send an email to anyone who has true in the corresponding list. The best way that I can see this is by doing something like this: $myarray = array(); if($_POST['list1']) { $result = mysql_query("SELECT * FROM mailinglist WHERE list1='true'); while($row = mysql_fetch_assoc($result)) { $myarray[] = $row['email']; } } //REPEAT FOR list2 and list3 Then I should have an array with all the email addresses in it, but if people subscribe to two of the selected lists, they will be duplicates in the list. How can I ensure that no duplicates occur?
  15. I cant help you out too much, but try calling print_r($_POST) from your UploadVerify.php This will dump out ALL the $_POST variables to make it easier to see what is set, and what each value holds.
  16. Dont worry, figured it out. I was writing the cookie from site.com/login/ (although this was redirected using .htaccess) which meant the path was set to /login/
  17. I am trying to set a cookie like so: $cookieresult = setcookie("schoolname",$_POST['school'],time()+1000000); $cookieresult holds the value "1" after this, but when i print_r($_COOKIE) it doesnt show up and there seems to be no cookie set. The same happens if I replace the $_POST['school'] with a string like "hi". Any ideas?
  18. Thanks. my google searching just kept bringing me to the page with all the string functions.
  19. Kicking myself that I didnt see that now. That is why I was asking you to check the source code of the output page, it would have shown the problem. Glad you sorted it out.
  20. try: include("../../include/menu.php"); the ".." means "go up one directory" so ../../ means go up two, or ../../../ means go up three etc. The other option is: include("/include/menu.php"); By putting the "/" at the beginning you are using an absolute filepath (include("/file.php") will include http://mysite.com/file.php) Remember that your menu may not work if the files it links to are relative to files in the Angellyceum folder. I would make sure that the menu.pgp uses absolute values (with the / at the front).
  21. Nope. I want to select the users from the table which have list1='1' if the list1 checkbox was checked, or list2='1' if the second was checked. So if the user selects list1 and list3, and user who has list1='1' OR list3='1' will be selected (ie this email is relevant to people who are interested in the stuff list 1 or list 3 were set up for. If they ONLY subscribe to list 2, ignore them) I have done the insert bit somewhere else
  22. It could be. What happens (from memory, someone correct me if I am wrong) when you include a file using the include() fuinction is it basically grabs the code of that file and dumps it into the file that called it before being parsed. So: MainFile.php (http://mysite.com) include("includes/some/file/path.php"); With includes/come/file/path.php (http://mysite.com/includes/some/file/path.php) <img src="myPicture.jpg" /> Will look for http://mysite.com/myPicture.jpg NOT http://mysite.com/includes/some/file/myPicture.jpg Have you tried removing the "../" form the filepath and not just the ".." ? What does the img tag say when you check check the source of the page?
  23. Firstly: Are the files sitting in your server? Secondly, we cannot assume the .jpg or .jpeg extension, it is based on the uploaded file (if it is .jpg, it should be .jpg, if it is .jpeg it will be .jpeg, if it is a .gif it will be .gif etc) Thirdly, the files should in in /avatars/file.extension based on the script which uploads it. So if your script is: http://myplace.com/scripts/myscript.php Then you need to look in http://myplace.com/scripts/avatars/file.extension When you are trying to show the image you are using img src='../avatars/'" . $_SESSION['username'] . "'.jpeg' width='526' height='45' /> which would point to http://myplace.com/avatars/file.extension I believe. Check the source code of your outputted file and see where it is trying to read the file from. It might be as simple as removing the "../" from the src attribute.
  24. I have always used " for strings: $string = "hello"; but I have seen a few scripts which use ' : $string = 'hello'; Is there a difference? From memory when I was learning C the "hello" referred to a string, whereas 'hello' was referring to a character (and should therefore only be used if you were doing 'c' etc).
  25. The problem that I have is structuring the query. Would it be (based on my original code, will make your suggested change when I get time) $query = "SELECT * FROM mailingList WHERE list1='$_POST[list1]' OR list2='$_POST[list2]' OR list3='$_POST[list3]' This didnt seem to work for me.
×
×
  • 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.