Jump to content

DVigneault

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by DVigneault

  1. I see...so, two companies putting out their own versions of a similar product. I get it. Thanks a bunch!
  2. Hey all-- As I went to install MAMP 2.1.1 on my new machine, I thought I'd check to see if it was available in the app store. There, I found BitNami MAMP Stack 5.4.9, which I've never used before. What's the difference? Are they made by the same developers? Have I been using an out-of-date version, by using MAMP 2? Best, and happy new year! --Davis
  3. Thanks to both of you for your responses! @Christian -- I see that using "function" as the name in my example was a bad idea. The actual function is called buildInputField and is defined in an include. My question was really whether there was a way to check if the user has submitted the POST variable within the function, to prevent needing to wrap the function with isset each time I call it, without getting a notice. Per your code, it seems like performing that check before calling the function is the way to go. Best, and thanks again, –Davis
  4. Hey all– I've got a function that uses data from a variable from a user. Originally it was set up as follows: <?php function($_POST['variable']) { if (isset($_POST['variable']) && preg_match($_POST['variable'], $pattern)) { //Do something } else { //Do something else } ?> However, when I do this before giving any input, I get a notice saying that the variable isn't set. Now I realize that the notice is telling me something that I am accounting for in my function, and that the user won't see the notices when I turn off error reporting. However, the notice still makes me uncomfortable--should I be worrying about it? And, if so, how do I change it? I know that I can check to see if the variable is set before feeding it to the function, but this seems to partially defeat the purpose of having the function (if I need to re-write the same code over and over again each time I call it). Any thoughts or advice? Best, –Davis
  5. No...the stylesheet doesn't load. I get an access-denied-type message. I can't figure out what my stylesheet could be doing that's against its filtering rules.
  6. Thanks for the reply! Here's the site: www.clinicalc.com Here's the stylesheet: www.clinicalc.com/common/style.php Also, I looked up BlueSocket, which is the company that provides the wireless service to the library: http://www.bluesocket.com/solutions/vwlan I hope this helps, but, if not, thanks anyway for trying! Best, –Davis
  7. Hey all– I'm having trouble loading a stylesheet when I'm loading the website through a certain network. The stylesheet is referenced as follows: <base href="http://www.mywebsite.com/"> <link rel="stylesheet" type="text/css" href="common/style.php" /> The stylesheet itself is at mywebsite.com/common/style.php. When I visit the site from home, or from a cafe, or my school, or whatever, it loads find. However, when I visit the site from the public library, via a "filtered" public connection (it's the Boston Public Library, and it's connecting via "BlueSocket," which I'm not familiar with), the stylesheet doesn't load. I don't have this problem when I visit any other websites via the same connection. Any ideas about what might be going on, and how I might fix it? Best, and thanks, –Davis
  8. var_dump() helped alot--I've got it working! The problem, it seems, was that I included the <urlset> parent element in my foreach path. When I got rid of that, everything worked like a charm. :-)
  9. Thanks for the help, ChristianF--I didn't realize that you could append to a variable like that. The output looks like: <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://example.com</loc> <lastmod>2012-07-30</lastmod> <changefreq>monthly</changefreq> <priority>0.5</priority> </url> //More <url></url> elements </urlset> In the code-block I gave in my last post, the error is on the foreach statement: foreach ($sitemapXML->path->to->element as $var) { and it says that I'm supplying an invalid argument. Searching on google says that this could mean that I'm not supplying it with an array (and, infact, I just found the is_array() function, and is_array($sitemapXML) returns false). Thanks again for your help, everyone.
  10. So I've got it outputting XML using ob_start(), ob_get_contents, and ob_end_clean(), as follows: $xml1 = <<<XML <urlset> //and some hard-coded XML XML; ob_start() $con = new mysqli($host, $username, $password, $database); $result = $con->query("SELECT stuff"); mysqli_close($con); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo '<parent>'; echo '<child1>' . $row['something'] . '</child1>' . PHP_EOL; echo '<child2>' . $row['somethingelse'] . '</child2>' . PHP_EOL; echo '</parent>' . PHP_EOL; $xml2 = ob_get_contents() ob_end_clean() $xml3 = '</urlset>'; $sitemap = $xml1 . $xml2 . $xml3; Printing $sitemap with the xml header works, but... $sitemapXML = new SimpleXMLElement($sitemap); foreach ($sitemapXML->path->to->element as $var) { echo $var->whatiwant; } ...gives me an error, saying that I'm supplying an invalid argument. Thanks for bearing with me...
  11. Thanks! So I think understand how to store the hard-coded part of my XML as a string... <?php $xmlstr = <<<XML //Some hard-coded XML XML; ?> ...but what about XML I'm generating from a database? So far I've just been getting it from a database and echoing it like this: $con = new mysqli($host, $username, $password, $database); $result = $con->query("SELECT stuff"); mysqli_close($con); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo '<parent>'; echo '<child1>' . $row['something'] . '</child1>' . PHP_EOL; echo '<child2>' . $row['somethingelse'] . '</child2>' . PHP_EOL; echo '</parent>' . PHP_EOL;
  12. Hey all-- So I've got a php script that generates an xml page, which is working, as follows: <?php header ("Content-Type:text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; ?> //Functions to generate xml I'm then trying to grab some of that data in another php script. In the past, when the xml was hard-coded (file extension .xml), I've used the following: $xml = new SimpleXMLElement(file_get_contents(/path/to/file)); When I try to use this to grab my dynamically-generated xml page above (file extension .php), I get a bunch of SimpleXMLElement::__construct() warnings. Sorry in advance if this is a naive question--I'm sure what I'm doing wrong will be glaringly obvious to the people reading this forum. Best, --Davis
  13. Hey all-- I hope "PHP Applications" is the right place for this question. I've recently installed Sphider (v1.3.5) on my local machine (PHP v5.3.6, Apache v2.2.2.1, via MAMP v2.0.5), and am trying to get it to index my (local) site. However, when I add http://localhost/home/, check "index depth = full", and start indexing, it indexes that single page, but doesn't follow the links on that page. The output looks like this: There was a forum post on the Sphider website about it (here: http://www.sphider.eu/forum/read.php?2,4973,4973) but no one ever came up with an answer. Any ideas? --Davis
  14. Thanks! Perfect.
  15. Hey all-- Just downloaded Sphider 1.3.5 (I'm running php 5.3.6, MySQL 5.5.9) and have a question about the installation. When I ran the installation script, I got the following error: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(14), elapsed float(2), results int, key query_key(query))' at line 3 Someone on another forum suggested removing the "(14)" from one of the query statements, as follows: #Before mysql_query("create table `".$mysql_table_prefix."query_log` ( query varchar(255), time timestamp(14), elapsed float(2), results int, key query_key(query))"); #After mysql_query("create table `".$mysql_table_prefix."query_log` ( query varchar(255), time timestamp, elapsed float(2), results int, key query_key(query))"); When I make the change, the installation runs perfectly. That said, I'm very new to SQL, and am uncomfortable doing it without understanding why. Is anyone able to explain to me the error, why removing the "(14)" works, and if there are any reasons why I should be going about it another way? Best, ?Davis
  16. Thanks so much! That worked perfectly. And jsfiddle is pretty cool--I should use that next time I post.
  17. Hey all--more trouble styling my forms. Here's the HTML: <div id="wrapper"> <form> <fieldset>Some stuff</fieldset> <div id="buttons"> <button>Submit</button> <button>Reset</button> </div> </form> </div> And the CSS: div#wrapper { width: 800px; margin-left: auto; margin-right: auto; } #buttons { display: inline; margin-left: auto; margin-right: auto; } I'd like for the "buttons" div to be centered within the 800px "parent" div, but instead it stays against the left side. I can get it to look roughly how I want by setting margin-left to 300px or so, but I'd really just like it centered (and to know why setting the margins to auto isn't having the effect I thought it'd have). Any ideas about what I'm doing wrong? Best, -d
  18. Thanks so much for the reply--that looks like it would have worked. I actually gave up a few hours after I posted and just used jQuery, though. :-/
  19. Hey all--I've been using a workaround to style a dropdown list to match the rest of my form. Here's the HTML: <div class="styled-select"> <select> <option>kg</option> <option>lb</option> </select> </div> And the CSS: .styled-select select { background: transparent; font-size: 16px; width: 70px; height: 25px; border: 0px; } .styled-select { border:1px solid #aaa; position: relative; top: 10px; display: inline-block; height:25px; width:50px; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee; border-radius:2px; overflow: hidden; background: url(image.jpeg) no-repeat right #eee; } .styled-select select:focus { background: url(image.jpeg) no-repeat right #fff; } Everything is working perfectly except that when I tab to the dropdown list, the background image shifts off to the right by maybe 20px. Any idea how I make it stay put? Thanks! -d
  20. @Mahngiel--you're right, I could use the same logic for includes. Seems that there is no reason not to use includes. Just that I didn't know that there was a reason not to use eval() when I wrote it, so I thought it would be good to ask before rewriting. :-) @Pikachu2000 and @PFMaBiSmAd--they are medical scoring systems/algorithms. Each one is separate/distinct. Two simple examples. APGAR //Function function calculate($a,$b,$c,$d,$e) { $result = ($a+$b+$c+$d+$e); echo "APGAR: " . $result . "<br>"; if ($result < 5) $range = "The child requires immediate assistance."; elseif ($result < $range = "The child requires assistance."; else $range = "The child is normal."; echo "Interpretation: " . $range; } //Form <form name="form" method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Appearance:</legend> <label for="a1"> <input type="radio" name="a" id="a1" value="0" tabindex="1" <?php echo $a1; ?> /> Pale or Blue</label><br> <label for="a2"> <input type="radio" name="a" id="a2" value="1" tabindex="1" <?php echo $a2; ?> /> Blue in Extremities</label><br> <label for="a3"> <input type="radio" name="a" id="a3" value="2" tabindex="1" <?php echo $a3; ?> /> Pink</label> </fieldset> <fieldset> <legend>Pulse:</legend> <label for="b1"> <input type="radio" name="b" id="b1" value="0" tabindex="2" <?php echo $b1; ?> /> Absent</label><br> <label for="b2"> <input type="radio" name="b" id="b2" value="1" tabindex="2" <?php echo $b2; ?> /> Less than 100bpm</label><br> <label for="b3"> <input type="radio" name="b" id="b3" value="2" tabindex="2" <?php echo $b3; ?> /> Greater than 100bpm</label> </fieldset> <fieldset> <legend>Grimace:</legend> <label for="c1"> <input type="radio" name="c" id="c1" value="0" tabindex="3" <?php echo $c1; ?> /> No response</label><br> <label for="c2"> <input type="radio" name="c" id="c2" value="1" tabindex="3" <?php echo $c2; ?> /> Grimace</label><br> <label for="c3"> <input type="radio" name="c" id="c3" value="2" tabindex="3" <?php echo $c3; ?> /> Cough or Sneeze</label> </fieldset> <fieldset> <legend>Activity:</legend> <label for="d1"> <input type="radio" name="d" id="d1" value="0" tabindex="4" <?php echo $d1; ?> /> Flaccid</label><br> <label for="d2"> <input type="radio" name="d" id="d2" value="1" tabindex="4" <?php echo $d2; ?> /> Some Flexion</label><br> <label for="d3"> <input type="radio" name="d" id="d3" value="2" tabindex="4" <?php echo $d3; ?> /> Well Flexed</label> </fieldset> <fieldset> <legend>Respiration:</legend> <label for="e1"> <input type="radio" name="e" id="e1" value="0" tabindex="5" <?php echo $e1; ?> /> Absent</label><br> <label for="e2"> <input type="radio" name="e" id="e2" value="1" tabindex="5" <?php echo $e2; ?> /> Weak Cry</label><br> <label for="e3"> <input type="radio" name="e" id="e3" value="2" tabindex="5" <?php echo $e3; ?> /> Strong Cry</label> </fieldset> <input type="hidden" name="abbreviation" value="APGAR"> <input type="submit" name="submit" value="Calculate" tabindex="6"> </form> //Result calculate($_GET["a"],$_GET["b"],$_GET["c"],$_GET["d"],$_GET["e"]); Anion Gap: //Function function calculate($sodium,$potassium,$chloride,$bicarbonate) { $result = ($sodium+$potassium)-($chloride+$bicarbonate); echo round($result, 2) . "<br>"; } //Form <form name="form" method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Cations:</legend> <label for="sodium">Sodium (Na<sup>+</sup>): </label> <input type="text" name="sodium" value=" <?php if (isset($_GET['submit'])) { echo $_GET['sodium']; } ?> " tabindex="1"><br> <label for="potassium">Potassium (K<sup>+</sup>): </label> <input type="text" name="potassium" value=" <?php if (isset($_GET['submit'])) { echo $_GET['potassium']; } ?> " tabindex="2"><br> </fieldset> <fieldset> <legend>Anions:</legend> <label for="chloride">Chloride (Cl<sup>-</sup>): </label> <input type="text" name="chloride" value=" <?php if (isset($_GET['submit'])) { echo $_GET['chloride']; } ?> " tabindex="3"><br> <label for="bicarbonate">Bicarbonate (HCO<sub>3</sub><sup>-</sup>): </label> <input type="text" name="bicarbonate" value=" <?php if (isset($_GET['submit'])) { echo $_GET['bicarbonate']; } ?> " tabindex="4"><br> </fieldset> <input type="hidden" name="abbreviation" value="AnionGap"> <input type="submit" name="submit" value="Calculate" tabindex="5"> </form> //Result <?php calculate($_GET["sodium"],$_GET["potassium"],$_GET["chloride"],$_GET["bicarbonate"]);
  21. Only that I thought it would be neater to store them in the database than having them in files. There are three scripts per calculator (which would mean three includes per page), and eventually hundreds of calculators (each calculator having its own page), and I thought there might be difficulties down the road in managing it this way. Is this common practice, to avoid using eval()?
  22. Hey all--new to web design (as will become clear very soon). I've been writing a website with numerous medical scoring systems, written in php. I thought that I would store the php scripts in a MySQL database and call them with eval(), until I saw the giant warning on php.net saying to never, ever, not ever, use eval(). Ever. Searching around, I find lots of references to storing php in MySQL databases as a "design flaw," but I haven't found guidelines about how else to do it. Should I be using include instead? Or something else? Best, ?Davis P.S. Sorry if there is already a post about this--whenever I try to search the site, I get an error saying that I don't have permission.
  23. Oh and I'm using MySQL version 5.0 and PHP version 5.2 (on a godaddy account).
  24. Hey all-- Here's the setup: I'm joining two tables and then using while($row = mysql_fetch_array($result)) to echo the resulting records into an HTML table. But only 15 of the 16 records are showing up. If I delete one record, I get 14 out of 15. The one to not show up is always the latest record. <?php if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("atsband", $con); $query = "SELECT some fields of table 1 and table 2 FROM table 1 LEFT JOIN table 2 ON table 1.field = table 2.field WHERE date < NOW() ORDER BY date DESC"; if ($result = mysql_query($query, $con)) { if (mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { echo "<table id='shows_past'><th>Date/Time</th><th>Venue</th><th>Location</th>"; while($row = mysql_fetch_array($result)) { echo "an HTML table"; } echo "</table>"; } } else { echo "Something went wrong."; } } else { echo "The query failed."; } mysql_close($con); ?> There's a similar question posted here, but I couldn't figure out if we were doing the same thing wrong (very new to MySQL and PHP by the way): http://www.phpfreaks.com/forums/index.php?topic=325757.msg1534001#msg1534001. Thanks a bunch, -Davis
×
×
  • 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.