Jump to content
Larry Ullman's Book Forums

margaux

Members
  • Posts

    453
  • Joined

  • Last visited

  • Days Won

    52

Everything posted by margaux

  1. Brilliant! These kind of errors can be frustrating but as you say its a great way to learn. Keep posting and following other threads as this forum is a great learning resource.
  2. In your js file, you are setting the url incorrectly, hence $_GET['image'] does not exist. Add an equals sign to this line var url = "show_image.php?image" + image; i.e. var url = "show_image.php?image=" + image;
  3. Not many people are going to wade through all that code. The error has been spelled out, $_POST['category'] is not getting a value - you need to figure out why a category isn't being selected in your set-up. Could be your categories table is not set up properly. A couple of things: var_dump is a function that needs an argument not a constant which is why you're getting that error. Here's how to use it. Please use code tags when including code, it makes it a lot easier to read. Its the <> icon. Also only include the relevant code.
  4. It's obvious isn't it - $_POST is not getting the category that you select. There could be any number of reasons for this, but you'll have to show us your code so we can be more helpful. This kind of debugging is pretty basic and you may struggle with this book if you're not able to identify these errors. You may want to first read Larry's book, PHP and MySQL for Dynamic Web Sites.
  5. if (isset($_POST['category'] && (int) $_POST['category'] >= 1)) { In the above code you have one of the closing parenthesis in the wrong place. It should be if (isset($_POST['category']) && (int) $_POST['category'] >= 1) { You need to see what is being passed in $_POST['category']. Try inserting var_dump or print_r($_POST['category']); above your if statement.
  6. Sorry for posting the above a few times - Not sure what happened here, when I tried to edit the post, it just posted it again and added in a bunch of font tags. Anyway, have you ever come across this side effect from xmlwriter->flush? Do you have any suggestions as to how I would check the status of writing the file? Thanks.
  7. Well I'm not sure if there is a problem in that I found this http://drupal.org/node/1435264. The first comment indicates a problem that may be what I'm experiencing - The documentation for XMLWriter::flush will return the number of bytes written if opened using URI and apparently it is possible for the number of bytes written with a flush to be zero. I dont completely understand this but maybe that is what I'm getting. When I did a var_dump on the result of my flush, it was int(0) as opposed to bool(False) which is what I would expect. Going back to the code I posted originally I changed the end to [/size][/font] [font='Lucida Grande', 'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif][size=3]$xml->endElement(); $xml->endDocument(); header ('Content-type: text/xml'); $result = $xml->flush();[/size][/font] [font='Lucida Grande', 'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif][size=3]if ($result) { echo 'File "fcTeams.xml" created.'; } else { echo 'Problems creating file "fcTeams.xml".'; }
  8. Well I'm not sure if there is a problem in that I found this http://drupal.org/node/1435264. The first comment indicates a problem that may be what I'm experiencing - The documentation for XMLWriter::flush will return the number of bytes written if opened using URI and apparently it is possible for the number of bytes written with a flush to be zero. I dont completely understand this but maybe that is what I'm getting. When I did a var_dump on the result of my flush, it was int(0) as opposed to bool(False) which is what I would expect. Going back to the code I posted originally I changed the end to [/size][/font] [font='Lucida Grande', 'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif][size=3]$xml->endElement(); $xml->endDocument(); header ('Content-type: text/xml'); $result = $xml->flush();[/size][/font] [font='Lucida Grande', 'DejaVu Sans', 'Bitstream Vera Sans', Verdana, Arial, sans-serif][size=3]if ($result) { echo 'File "fcTeams.xml" created.'; } else { echo 'Problems creating file "fcTeams.xml".'; }
  9. Below is the file that was run recently. I think the format is correct but maybe I'm missing something? <?xml version="1.0"?> <rss version="2.0"> <channel> <title>mol rss feed</title> <link>http://www.mol.co.uk/articles.xml</link> <description>Articles from mol</description> <lastBuildDate>Thu, 03 Jan 2013 21:14:48 +0000</lastBuildDate> <item> <title>Responsive Design</title> <description>Adapting website design to all internet devices</description> <pubDate>Tue, 05 Jun 2012 09:58:19 +0100</pubDate> <link>http://www.mol.co.uk/blog.php?id=4</link> </item> <item> <title>New EU Cookie Law</title> <description>From 22nd May you better be compliant</description> <pubDate>Tue, 01 May 2012 09:56:09 +0100</pubDate> <link>http://www.mol.co.uk/blog.php?id=2</link> </item> <item> <title>Gamification</title> <description>The new trend in retail marketing</description> <pubDate>Tue, 03 Apr 2012 09:58:00 +0100</pubDate> <link>http://www.mol.co.uk/blog.php?id=3</link> </item> <item> <title>More on SEO</title> <description>Common misunderstandings about SEO</description> <pubDate>Tue, 06 Mar 2012 12:11:44 +0000</pubDate> <link>http://www.mol.co.uk/blog.php?id=6</link> </item> <item> <title>ARIA</title> <description>Why you should ensure your website is acessible</description> <pubDate>Tue, 07 Feb 2012 12:03:23 +0000</pubDate> <link>http://www.mol.co.uk/blog.php?id=5</link> </item> <item> <title>Cloud Computing</title> <description>The new buzzword in internet computing - What is i</description> <pubDate>Tue, 03 Jan 2012 09:56:00 +0000</pubDate> <link>http://www.mol.co.uk/blog.php?id=1</link> </item> </channel> </rss>
  10. Thanks for sticking with this. Several messages are output: From what I've been able to find out online I've included the required items and attributes for declaring the schema as RSS but obviously I am missing something. Any suggestions?
  11. I agree, I've learned so much by reading some of your responses!
  12. margaux

    Spam

    @Larry, I figured you were on top of this. Can you point out where to report spam? I started this topic as another forum I frequent became almost unusable. A big issue was the site owner/administrator didn't spend enough time administering to the site. An issue for him was that he didn't want to spend the time trawling through threads/accounts to determine if they were spam so it is helpful if potential spam posts were identified to him. It was amazing how quickly it spread once it started and was not dealt with. Thanks for a great learning resource.
  13. Checked is an attritbute of input type so it should not be within the value attribute. I think this is what you are trying to do <form method="post" action="#"> <label>Currently Available?</label><br /> <input type="radio" name="Available" value="Yes" <?php if (isset($_POST['Available']) && $_POST['Available'] == "Yes") echo 'checked="checked"';?>>Yes <input type="radio" name="Available" value="No" <?php if (isset($_POST['Available']) && $_POST['Available'] == "No") echo 'checked="checked"';?>>No <input type="submit" name="submit" value="Submit"> </form>
  14. margaux

    Spam

    To all forum participants who are human - Please don't respond to or encourage any kind of spam. I say this because on another forum, a similar situation has arisen and the forum is so riddled with spam that it has made the forum unenjoyable and most of the regulars have left. It started with one or two posts/comments and eventually a considerable percentage of the threads were infected. I think the site administrator has to disable the accounts.If a mechanism were set up for participants to report spam this will help the administrator quickly identify accounts that at least need monitoring.
  15. mysql returns an error on an update query if nothing has been updated. How this scenario is handled for the user is a developer decision. You can trap the error and handle it in a user friendly way or you can give the user an opt out button.
  16. This is new to me and I did not know to do that. I found a site that validates xml files and my file is 'invalid'. How do I define the file as of a particular schema and how does the xml file "find its scheme"? My project file is an rss file and is of the format <?xml version="1.0"?> <rss version="2.0"> <channel> <title>mol rss feed</title> <description>mol articles</description> <link>http://www.mol.co.uk/articles.xml</link> <lastBuildDate>Sat, 15 Dec 2012 17:24:05 +0000</lastBuildDate> <item> <title>Article 1</title> <description>Description of Article 1</description> <pubDate>Tue, 05 Jun 2012 09:58:19 +0100</pubDate> <link>http://www.mol.co.uk/blog.php?id=4</link> </item> </channel> </rss>
  17. Thanks Larry, yes I am. Not sure what to try or what further information to give that would help to debug. I think the cause is something to do with $xml->flush() The file is being created and looks good, proper format and populated with the data as I would expect. Search results yielded very little information, one thread mentioned that the error was an xml error, but as nothing is displayed and the error message states that the error begins on line 1 column 1 I'm at a loss. Any information you can contribute would be great.
  18. You can only use aliases in GROUP BY, ORDER BY and HAVING clauses. One workaround would be to create a view and then select from that view using the WHERE distance <= 1000 clause.
  19. No, this doesn't make sense but if I were to post all the code that got me to this point I don't think anybody would want to look through it. The larger project is to create an rss feed from a database. I posted the previous code as I have narrowed down that the error I'm getting is in the generateXMl class - which incidentally doesn't have all this xml, it uses several foreach loops after retrieving alot more data from a d/b. So - can you help me? If I run the code I already posted in the browser, this is what I get. The rest of the page is blank. The source code only displays my error message There is no php syntax error and most of the logic is working as the file is created. I wonder if its an xml error? an encoding error? a version error? I don't know enough about xml to know and I have done a number of searches but have not found anything to indicate what might be causing the error. and yes I love football, this is a project to try to create something using oop.
  20. As part of a larger project, I'm trying to generate an xml file using xmlWriter. The file is created and looks okay but I get an error - "This page contains the following errors: error on line 1 at column 1: Document is empty Below is a rendering of the page up to the first error." The rest of the page is blank. The source code only displays my error message "Problems creating file "fcTeams.xml". I've include a simplified version of my code which is where the error is coming from. Any ideas what's causing the error? $xml = new XMLWriter(); $xml->openUri('fcTeams.xml'); $xml->setIndent(true); $xml->setIndentString("\t"); $xml->startDocument(); $xml->startElement('teams'); $xml->startElement('fc'); $xml->writeAttribute('id', '03'); $xml->writeElement('name', 'Real Madrid'); $xml->writeElement('manager', 'Jose Mourinho'); $xml->writeElement('captain', 'Iker Casillas'); $xml->writeElement('stadium', 'Bernabeu'); $xml->startElement('player'); $xml->writeElement('name' , 'Christiano Ronaldo'); $xml->writeElement('position','forward'); $xml->writeElement('number','7'); $xml->writeElement('country','Portugal'); $xml->endElement(); $xml->startElement('player'); $xml->writeElement('name' , 'Kaka'); $xml->writeElement('position','midfielder'); $xml->writeElement('number','8'); $xml->writeElement('country','Brazil'); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); header ('Content-type: text/xml'); if ($xml->flush() ) { echo 'File "fcTeams.xml" created.'; } else { echo 'Problems creating file "fcTeams.xml".'; }
  21. getimagesize() requires the full path to the image relative to the script invoking the function, so if getimagesize is used in an included script you need to take that into account when coding your path. getimagesize('uploads/$img') will be interpreted literally, you need to concatenate the $img variable getimagesize('uploads/' . $img)
  22. Without seeing your d/b insert statement I can only guess why it's storing 'on'. Is your insert query something like $q = "INSERT INTO tablename (first_name, mid_initial, last_name, username, email, pass, agree) VALUES ('$fn' ,'$mi', '$ln', '$u', '$e', '$p', '$agree' )"; If it is, then you need to change the following line of code if (isset($_POST['agree']) && ($_POST['agree'] == TRUE)) { $agree = mysqli_real_escape_string($connect, $_POST['agree']); } else { If the checkbox is checked, $_POST['agree']'s value will be 'on' which is what you are then storing in $agree. You could change the above code to if (isset($_POST['agree']) && ($_POST['agree'] == TRUE)) { $agree = 'Agree'; } else { the comment about 'ascii codes' refers to this line <p><label for="username"><strong>Desired Username</strong></label><br /> <p class="noticeType">Only a combination of letters and numbers are <br />allowed with no special characters — from<br /> two to thirty in total.</p> <?php create_form_input('username', 'text', $reg_errors); ?> </p> Some browsers will render the dash differently. Replacing the dash with its ascii equivalent, in this case , will ensure it renders correctly in all browsers. Not a big thing but if you have a funny character on your site, it makes your site look unprofessional. Inline styling - HartleySan covered that. Best practice is to put all your css rules in an external file sheet and in your head section provide a link to it. <span class="error">' . $errors[$name] . '</span>' The above code displays your error messages and you may want to add additional css rules to control how your error messages are displayed. I completely agree with HartleySan's suggestion re liberally sprinkling print_r statements throughout your code during development. Not only will it help you with debugging, you will also learn alot about the internal workings of php by looking at what and how it stores your variables and global variables.
  23. The code I previously posted worked. I think your problem is that you have 2 inputs for the checkbox. <p class="noticeType"><input type="checkbox" name="agree" value="agree" />I agree to the user Terms and Conditions.</p> <?php create_form_input('agree', 'checkbox', $reg_errors); ?> replace the code above with <p class="noticeType"><?php create_form_input('agree', 'checkbox', $reg_errors); ?><label for="agree">I agree to the user Terms and Conditions.</label> </p>
×
×
  • Create New...