Jump to content

afish674

Members
  • Posts

    148
  • Joined

  • Last visited

Everything posted by afish674

  1. I've applied a class to the jQuery UI button call like so: $(".UIbutton").button(); When the .UIbutton class is called on what is traditionally a button element, for example on a <input type="submit"> button then it works fine. However if you apply it onto an anchor like: <a href=\"birthdays.php\" class=\"UIbutton\">Add Another?</a> Then the button takes the full width of the page rather than just matching the size of the text. Does anyone know why it does this and how to get it to adjust to the text width? Thanks!
  2. I'm trying to create some custom exceptions but I'm not having any luck, the code is just proceeding as if nothing is wrong when I leave empty fields. Also, I'd like to have the errors display within the form itself by creating some divs, rather than just showing a message at the end. How would I do this? Here is my code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Birthday Reminders</title><link href="css/main-styles.css" rel="stylesheet" type="text/css" /><link href="css/redmond/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" /></head><body><?phpif (!isset($_POST['submit'])){?><form name="addBirthday" method="post" action="submitted.php"><h2>Enter a birthday to add to your reminders:</h2><label for="fName">First Name:</label><input name="fName" id="FName" type="text" size="20" /> <label for="sName">Second Name:</label><input name="sName" id="SName" type="text" size="20" /> <label for="date">Birthday:</label> <input name="date" id="date"/> <label for="note">Note:</label> <textarea name="note" id="note"></textarea> <input name="submit" id="submit" class="UIbutton" type="submit" value="Add Birthday" /></form><?php} else {class EmptyField extends Exception{ }$fName = $_POST['fName'];$sName = $_POST['sName'];$date = $_POST['date'];$note = $_POST['note'];try{ if (empty($fName)){ throw new EmptyField("First name!"); } if(empty($sName)){ throw new EmptyField("Second name!"); } if (empty($date)){ throw new EmptyField("Birthday!"); }}catch (EmptyField $e){ echo"<div class=\"ui-state-error\"><p>Please enter a ". $e->getMessage()."</p></div>"; exit();}echo "<h2>This birthday has been added to your birthdays!</h2><p>$fName $sName's birthday on $date has been added to your reminders.</p><a href=\"birthdays.php\" class=\"UIbutton\">Add Another?</a><a href=\"upcoming.php\" class=\"UIbutton\">Upcoming Birthdays</a><a href=\"bymonth.php\" class=\"UIbutton\">Overview by Month</a>";}?><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script><script type="text/javascript" src="js/UIscripts.js"></script></body></html>
  3. I have just noticed that the strawberry jam on the same page doesn't seem to have the problem, but the code appears to be the same?
  4. Thanks for your reply. The problem I have is I'm using the Joomla CMS for a client and it's editor keeps adding tags in the wrong places, if I turn the editor off and over-write the code manually when I turn it back in it changes it back again. Hence, blank and nested <p> tags. Obviously she won't have enough knowledge to overwrite these issues either. I did try changing the CSS on the surrounding div to overflow: hidden; Whilst this fixes the problem, it creates another one, in that the top of the red pin is cut off because this is absolutely positioned within the parent div. I resorted to placing a blank div below the paragraphs to stop the borders collapsing. Using a clearfix class on the parent in this casewould involve editing lots of PHP files which to be honest doesn't seem worth it!
  5. This should be fairly straight forward but I can't work out what is going on. I have an image of some jam, I want this image to line up with the top of the text next to it. Using firebug I can't find any padding or margins that is causing the image to be pushed down, any suggestions? http://lovespreading.co.uk/jams - Blackcurrant jam Thanks!
  6. What I was trying to do was set an x, y co-ordinate in pixels. So I just need to use the co-ordinates as in your last example and leave off the keywords. Thanks
  7. I'm trying to use this image as a background to save on file size on my site: https://dl.dropbox.c...pin-sprites.png Obviously to use the second pin along I need to move the background. I tried using this CSS but it doesn't seem to work, I'm not sure I have the correct syntax. #po-pin{display:block;width:36px;height:57px;top:-15px;left:105px;background:url(../img/pin-sprites.png) no-repeat 43px left 0px top;} If someone could write it out in both longhand (background-position:...) and shorthand as above then i'd appreciate it. Thanks! The tutorial here http://www.w3schools..._background.asp says that it should be: background-color background-image background-repeat background-attachment background-position Which I thought I followed. The code below works for the first pin in the line. #po-pin{display:block;width:36px;height:57px;top:-15px;left:105px;background:url(../img/pin-sprites.png) no-repeat 0px top;}
  8. Thanks, The added problem I have is that i'm trying to make a dynamic width page so my logo is resizing. If I put it as a background image then i'll need to give it a height, this will stop it scaling properly. https://dl.dropbox.com/u/13032629/Love%20Spreading%20BGimg/index.html as opposed to https://dl.dropbox.com/u/13032629/Love%20Spreading%20DW/index.html I suppose I could wrap the whole containing div with an anchor in the scaling version, but I don't know if this is a good idea?
  9. Quick question, and one which always confuses me: What tags should you use for your logo text and slogan for optimum SEO? It would seem to me that it shouldn't be <h1> because the logo and slogan are at the top of every page and it therefore defeats the purpose of the h1 tag. But other headings tags I'm also not convinced about, nor having it as <p>. It would seem that html could do with a logo text or company name tag. Any suggestions appreciated. Thanks!
  10. Thanks for taking the time to explain all that to me. Really appreciate it! I agree with your point about beginners books too. The author of this one tends to change minor things, but when you're trying to understand the code line by line, you suddenly find yourself going "Whoa! Where did that come from?!" Its quite frustrating.
  11. Also, I don't understand why in a bit of code which I haven't included in the first block occurs: <select name="songArtist"> <?php foreach ($artists as $k => $v){ echo "<option value=\"$k\">".$v."</option>"; } ?> </select> Why is the foreach loop "$artists as $k => $v"?When $artists as $a would seemingly work too.
  12. Most of the code is from a book I've been using a book to learn, they didn't use braces in this case. I did wonder why though as normally you do. I will do so in future. I did wonder what the above code snippet actually does though. The assignment operator normally makes the bit on the left match the bit on the right, but I'm not sure it is doing that in this case?
  13. Ah! Thanks for that. I need to get my eye in. I just get into the habit of ending every statement with a ";" without really thinking about it. Cheers for your help!
  14. I'm having some problem with my code. It says that I'm trying to get the property of a non-object on line 24. However I'm using the method for get object. So I don't really understand why it says its not an object. As you can see I have tried "fetch(PDO::FETCH_OBJ)" and "fetchObject()" to no avail. I assume these two do the same thing? I am very new to PHP. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Project 7-4: Building A Login Form</title> </head> <body> <h2>Project 7-4: Building A Login Form</h2><?php // if form not yet submitted // display form if (!isset($_POST['submit'])) { try{ $pdo = new PDO('mysql:dbname=music;host=localhost','root','Rockon!'); } catch (PDOException $e){ die("ERROR: Could not connect: " . $e->getMessage()); } //Get artists $artists = array(); $sql = "SELECT artist_id, artist_name FROM artists"; if ($result = $pdo->query($sql)) { while($row = $result->fetchObject()); $artists[$row->artist_id] = $row->artist_name; } $ratings = array(); //Get ratings $sql = "SELECT rating_id, rating name FROM ratings"; if ($result = $pdo->query($sql)){ while($row = $result->fetch(PDO::FETCH_OBJ)); $ratings[$row->rating_id] = $row->rating_name; } }?> <form method="post" action="add_songs.php"> <label for="songName">Song Name:</label> <input type="text" name="songName"/> <label for="songArtist">Song Artist:</label> <select name="songArtist"> <!--unset($pdo);--> </select> <input type="submit" name="submit" value="Add Record"> </form> </body></html> Thanks for your help.
  15. Okay, I changed "echo" to "print_r" but didn't use the true arguement because I wanted it printed to the screen so I could read it. It comes out in one long string: Array ( [dirname] => . [basename] => . [extension] => [filename] => ) Array ( [dirname] => . [basename] => .. [extension] => [filename] => . ) Array ( [dirname] => . [basename] => .project [extension] => project [filename] => ) Array ( [dirname] => . [basename] => .settings [extension] => settings [filename] => ) Array ( [dirname] => . [basename] => fruits-reversed [filename] => fruits-reversed ) Array ( [dirname] => . [basename] => fruits-reversed.xtx [extension] => xtx [filename] => fruits-reversed ) Array ( [dirname] => . [basename] => fruits.xtx [extension] => xtx [filename] => fruits ) Array ( [dirname] => . [basename] => readfileandreversecontents.php [extension] => php [filename] => readfileandreversecontents ) Array ( [dirname] => . [basename] => rename_files.php [extension] => php [filename] => rename_files ) Array ( [dirname] => . [basename] => reverse_fruit.php [extension] => php [filename] => reverse_fruit )Is there an easy way to format it? Also, it shows that there .txt file names that it can see, so I don't understand why my original code wasn't working?
  16. There are definatly some .txt files in the directory and there are no sub-directories. I changed the code to: <?php $dp = opendir(".") or die("Cannot open directory!");while($file = readdir($dp)){ $fileData = pathinfo($file); echo "$fileData <br/>"; /*if($fileData['extension'] == "txt"){ rename($file, $fileData['filename'] . ".xtx") or die("Error! Cannot rename file ".$file);*/ }//}closedir($dp);?> To see what it was passing on to the next bit and it echoed: (html)ArrayArrayArrayArrayArrayArrayArrayArrayArrayArray(end html) Is this what is causing the problem? Because it is not returning the file names?
  17. Hi, I'm learning PHP from a book and in one of the end of chapter tests it asks you to build a script that iterates through a directory and changes any files with the extension ".txt" to ".xtx" I struggled with this and then eventually went to the back of the book to check the authors code, which is as follows: <?php $dp = opendir(".") or die("Cannot open directory!");while($file = readdir($dp)){ $fileData = pathinfo($file); if($fileData['extension'] == "txt"){ rename($file, $fileData['filename'] . ".xtx") or die("Error! Cannot rename file ".$file); }}closedir($dp);?> However, this code generates an error that "extension" is not a valid index. He uses this in another script earlier in the book to check image extensions. Is this because the book is for an older version of PHP or is it a mistake? How would I fix it? Thanks for any help!
  18. afish674

    PHP and jQuery

    Thanks! One less thing to worry about then ha.
  19. https://dl.dropbox.com/u/13032629/Untitled-1.htmlThis link shows the problem, the white line can be seen going through the black border.
  20. afish674

    PHP and jQuery

    I've just started learning PHP and have a quick question regarding compatibility with jQuery. I noticed that PHP uses the "$" sign to set variables. This would seem to cause a compatibility clash with jQuery as it also uses the "$" sign for functions etc. My question is: If you want to use both on the same page together do you need to re-assign jQueries "$"? or if you use external script files would that get around the problem? Thanks.
  21. I don't see this problem either. Have you tried clearing your cache?
  22. Best way to do dropdowns is with CSS. There is a site that'll do most of it for you if you need to: http://purecssmenu.com/ If you wanted to open the links in a new window then you could use the "target=_new" attribute on the anchor, although this is apperently deprecated.
  23. I thought I had done, apperently it didn't save properly. That seems to have got it though!
  24. Just gave it a go. I had to remove the float (because this broke my layout, - https://dl.dropbox.c...%29/layout.html) and that seems to have stopped it from working. a#FB { display:block; width: 32px; margin-bottom:5px; height: 32px; background: url (img/facebook.png) no-repeat 0 top; } a#FB:hover { background: url (img/facebookHOV.png) no-repeat 0 bottom; }
  25. I have several images on my site that use the border radius property. This works fine. However, I have added a class which adds a white, 3px border around the image. This works fine in IE9 and Firefox but in Webkit browsers the border doesn't work on the corners (it borders the original square path before it has been rounded). Is there a way to fix this? (I tried changing the order the classes appear so that the border radius came before the border class but this made no difference.)
×
×
  • Create New...