sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
I have something like this on one of my sites. It displays a categorized list of links, but could easily be modified to list categorized articles: $articleTypes = array('news','profile','event'); foreach ($articleTypes as $articleCat){ $query = "SELECT articleType,articleContent FROM articles WHERE articleType = '$articleCat' ORDER BY articleNum DESC"; $result = mysql_query($query); $num_rows = mysql_num_rows ($result); if ($num_rows != 0){ echo " <h3>" . ucfirst($articleCat) . "</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "<p>" . $articleContent . "</p>; } } }
-
if the error is in my example.php script (the initial XML), make sure that when you copied and pasted the XML that you didn't gain any whitespace after any of the lines, especially the heredoc tags ( <<<XML ) and ( XML; ).
-
Yeah, I know nada about macs, but I put together a full script example that works. writeXML.php5 <?php include 'example.php'; $xml = new SimpleXMLElement($xmlstr); $character = $xml->book[0]->characters->addChild('character'); $character->addChild('name', 'Yellow Cat'); $character->addChild('desc', 'aloof'); $success = $xml->book[0]->addChild('success', '2'); $success->addAttribute('type', 'reprints'); $xml = $xml->asXML(); $config = array( 'input-xml'=> true, 'indent'=> true, 'output-xml'=> true ); $tidy = new tidy; $tidy->parseString($xml, $config, 'utf8'); $tidy->cleanRepair(); echo "<pre>"; echo htmlentities($tidy); echo "</pre>"; ?> example.php <?php $xmlstr = <<<XML <books> <book> <title>Great American Novel</title> <characters> <character> <name>Cliff</name> <desc>really great guy</desc> </character> <character> <name>Lovely Woman</name> <desc>matchless beauty</desc> </character> <character> <name>Loyal Dog</name> <desc>sleepy</desc> </character> </characters> <plot> Cliff meets Lovely Woman. Loyal Dog sleeps, but wakes up to bark at mailman. </plot> <success type="bestseller">4</success> <success type="bookclubs">9</success> </book> </books> XML; ?> output = <?xml version="1.0"?> <books> <book> <title>Great American Novel</title> <characters> <character> <name>Cliff</name> <desc>really great guy</desc> </character> <character> <name>Lovely Woman</name> <desc>matchless beauty</desc> </character> <character> <name>Loyal Dog</name> <desc>sleepy</desc> </character> <character> <name>Yellow Cat</name> <desc>aloof</desc> </character> </characters> <plot>Cliff meets Lovely Woman. Loyal Dog sleeps, but wakes up to bark at mailman.</plot> <success type="bestseller">4</success> <success type="bookclubs">9</success> <success type="reprints">2</success> </book> </books>
-
I'd like my WAMP to behave like Godaddy
sKunKbad replied to sKunKbad's topic in PHP Installation and Configuration
Exactly what I was looking for ... but whether or not I can make it work with WAMP is another question. Thanks PFMaBiSmAd -
Tidy is really nice, but it needs to be enabled on your php installation. The following code would work perfectly for you in php5: <?php $xml = "<sean><person><detail><fname>bob</fname><lname>hadababy</lname><address>itsaboy</address><skills>yahoo</skills></detail></person><person><detail><fname\n>another</fname\n><lname>test</lname><address>to</address><skills>see</skills></detail></person></sean>"; $config = array( 'input-xml' => true, 'indent' => true, 'output-xml' => true ); $tidy = new tidy; $tidy->parseString($xml, $config, 'utf8'); $tidy->cleanRepair(); echo $tidy; ?>
-
I'd like my WAMP to behave like Godaddy
sKunKbad replied to sKunKbad's topic in PHP Installation and Configuration
I know that most php4 code works in php5. For the sake of just knowing how it is done, what if it were php5 and php6, or two different versions of 5. How is it that Godaddy has both running at the same time, and separating the files that are interpreted? -
One thing I like about the sites I have on Godaddy is that I can have both .php and .php5 file extensions on my php files. The server interprets .php files with php version 4 and .php5 files with php version 5. I do have the php4 addon to my WAMP5 v1.7.1 installation, but would like to set it up to where I don't have to use the switch (as long as it is an easy thing to do).
-
[SOLVED] Cannot add header information - headers already sent
sKunKbad replied to srinivas6203's topic in PHP Coding Help
I think I spoke too soon. Look at line 60 of user_check.php. What is on that line? -
[SOLVED] Cannot add header information - headers already sent
sKunKbad replied to srinivas6203's topic in PHP Coding Help
try adding session_start(); to the top of your file. -
I tried the tutorial, and it still writes the tags all to one line.
-
This is a way to make rounded corners without images. Using images is more popular in my opinion, and makes the XHTML cleaner. All those divs just to make a round cornered box is a little extreme. I usually use 3 divs, one with a top of the box image, one with a background and the content, and one with the bottom of the box image. <div id="boxtop"> <img src="boxtop.gif" /> </div> <div id="boxcontent"> <p>This is the content of the box</p> </div> <div id="boxbottom"> <img src="boxbottom.gif" /> </div> I've tried numerous ways of making rounded corner boxes, and this one I like best.
-
This script is working, but I'm just wondering why the Firefox debugger is showing an error. The error is: Javascript Error: window.document.quizForm.submit is not a function The javascript is: <script type='text/javascript'>function preValidate(Q1,Q2,Q3,Q4,Q5,Q6) { var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q6.length; loop++) { if (window.document.quizForm.Q6[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q5.length; loop++) { if (window.document.quizForm.Q5[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q4.length; loop++) { if (window.document.quizForm.Q4[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q3.length; loop++) { if (window.document.quizForm.Q3[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q2.length; loop++) { if (window.document.quizForm.Q2[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } var allcool = 'no'; for (var loop = 0; loop < window.document.quizForm.Q1.length; loop++) { if (window.document.quizForm.Q1[loop].checked == true) { allcool = 'yes'; } } if (allcool == 'no') { alert('Go back and check that all questions were answered!'); return false; } window.document.quizForm.submit();} </script> and the form in the page is: <form action="register.php" method="post" name="quizForm" id="quizForm"> <div class='question'> <div class='listnumber'> 1 ) </div> <div class='listquestion'> My appearance is most important because: </div> <div class="choice"> <input type="radio" name="Q1" value="I need to look good professionally" /> I need to look good professionally </div> </div> <div class='question'> <div class='listnumber'> 2 ) </div> <div class='listquestion'> My current body weight is: </div> <div class="choice"> <input type="radio" name="Q2" value="I'm pretty close to my ideal weight now" /> I'm pretty close to my ideal weight now </div> <div class="choice"> <input type="radio" name="Q2" value="I'm within 25 pounds of my ideal" /> I'm within 25 pounds of my ideal </div> </div> <div class='question'> <div class='listnumber'> 3 ) </div> <div class='listquestion'> My ideal body goal is: </div> <div class="choice"> <input type="radio" name="Q3" value="I just need to tone up" /> I just need to tone up </div> <div class="choice"> <input type="radio" name="Q3" value="I want to lose a dress / pant size" /> I want to lose a dress / pant size </div> </div> <div class='question'> <div class='listnumber'> 4 ) </div> <div class='listquestion'> My experience with exercise programs has been: </div> <div class="choice"> <input type="radio" name="Q4" value="I'm too busy" /> I'm too busy </div> <div class="choice"> <input type="radio" name="Q4" value="I get discouraged when I don't get results" /> I get discouraged when I don't get results </div> </div> <div class='question'> <div class='listnumber'> 5 ) </div> <div class='listquestion'> Have you ever considered cosmetic surgery? </div> <div class="choice"> <input type="radio" name="Q5" value="It seems risky" /> It seems risky </div> <div class="choice"> <input type="radio" name="Q5" value="It seems expensive" /> It seems expensive </div> </div> <div class='question'> <div class='listnumber'> 6 ) </div> <div class='listquestion'> If I could change one thing about myself it would be my: </div> <div class="choice"> <input type="radio" name="Q6" value="Appearance" /> Appearance </div> <div class="choice"> <input type="radio" name="Q6" value="Self confidence" /> Self confidence </div> </div> <div id='thankyou'> <p> Thank you for taking the quiz. </p> </div> <div id='button'> <button id='submit' type='submit' onclick='preValidate(window.document.quizForm.Q1.value,window.document.quizForm.Q2.value,window.document.quizForm.Q3.value,window.document.quizForm.Q4.value,window.document.quizForm.Q5.value,window.document.quizForm.Q6.value);return false;'><img src='buttons/GetYourAnalysis.jpg' alt='Get your Analysis' /></button> </div> </form> How can I fix this and still have the code work?
-
which line is 71?
-
remove the brackets that are on the sides of "else"
-
I've been starting to create everything in php files. That doesn't mean everything has to be php, but in the event that you want to add php to a page later, it is easier to have the page already set up for it. That way you don't have to use 301 redirects and worry about changing links in your other pages.
-
if you remove the javascript, it will probably appear
-
Every decent php book I've ever read had at least a small section devoted to security. You might go to the bookstore and browse for a bit, find a book you like, and then go home and buy it on Amazon.
-
[SOLVED] Form Input Limited to Numbers Only
sKunKbad replied to xProteuSx's topic in PHP Coding Help
or use (int) -
I made this work, but if it doesn't work for you, then you have problems not related to this code: cURL.php <?php // create a new curl resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http://localhost:81/phun/receive.php"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Let's POST the data curl_setopt($ch, CURLOPT_POST, 1); // Set that POST curl_setopt($ch, CURLOPT_POSTFIELDS, array('post_test'=>"true", 'name'=>"Ryan")); // add POST fields // grab URL, and return output $output = curl_exec($ch); // Print output echo '<h1>cURL Results:</h1><p>' . $output . '</p>'; echo '<h1>curl_getinfo() Results:</h1>'; echo '<pre>'; print_r (curl_getinfo($ch)); echo '</pre>'; ?> receive.php <?php if(isset($_POST['post_test']) && isset($_POST['name'])){ echo "post_test == {$_POST['post_test']}"; echo "<br>"; echo "name == {$_POST['name']}"; }else{ echo "there was a problem with your cURL post"; } ?>
-
for the receive.php try <?php echo '<h1>Hello!</h1>'; if (isset($_POST['post_test']) && isset($_POST['name'])) { echo "Success!<br />post_test = {$_POST['post_test']}<br />name = {$_POST['name']}"; } else { echo 'You are here with $_POST vars unset!<br />'; echo '$_POST = <br />'; //echo var_dump($_POST); } ?>
-
I think the reason why it wasn't working is that your post vars might not have been submitted correctly. try <?php // Initialize the connection $ch = curl_init(); $url = "http://localhost:81/phun/receive.php"; curl_setopt($ch, CURLOPT_URL,$url); // set url to post to // FAIL on error! curl_setopt ($ch, CURLOPT_FAILONERROR, 1); // You don't need redirects for this, so I removed it // Assign returned data to var curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Set timeout (in seconds) curl_setopt($ch, CURLOPT_TIMEOUT, 30); // Let's POST the data curl_setopt($ch, CURLOPT_POST, 1); // Set that POST //OLD .. curl_setopt ($ch, CURLOPT_POSTFIELDS, "post_test=true&name=ryan"); curl_setopt($ch, CURLOPT_POSTFIELDS, array('post_test'=>"true", 'name'=>"Ryan")); // add POST fields // Execute!, snatch the output $output = curl_exec($ch); // Grab any curl info before we terminate connection $info = curl_getinfo($ch); // Close the connection curl_close($ch); // Let's have a look-sey echo '<h1>cURL Results:</h2><pre>' . htmlspecialchars($output) . '</pre>'; echo '<h1>curl_getinfo() Results:</h2><pre>' . print_r($info) . '</pre>'; ?>
-
check out this cURL tutorial http://www.phpit.net/article/using-curl-php/
-
I don't have the time to really look deeply into your CSS, but many problems with IE6 are caused by floating divs with margins. For style declarations that include both a float and a margin, try adding display:inline to fix IE6.
-
xProteuSx, I suffer from the same brainlessness late at night. One day you will be the helper, and I will be the helped!