sKunKbad
Members-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by sKunKbad
-
Only if you want them to. For example, if the include is the only HTML on a page, and the rest is all php code than this would be fine. When the actual page is viewed, you don't want to have more than one set of html tags or you will have validation errors.
-
Automaticly Create a Link From a Submit Form?
sKunKbad replied to Chicken's topic in PHP Coding Help
You didn't ask for the links to be added to a database, but it sounds like you will need to write a php program that adds links to a database, then when the pagewithlinks.php page is viewed you will query the database and echo the result of the query. This is about as simple of a task as you can do with php/mysql. I recommend reading this book to learn how to do this: PHP & MySQL For Dummies 3rd edition -
Automaticly Create a Link From a Submit Form?
sKunKbad replied to Chicken's topic in PHP Coding Help
FORM.HTML <form action="pagewithlinks.php" method="post"> <input type="text" name="newlink"></input> <input type="submit" value="Subscribe"></input> </form> PAGEWITHLINKS.PHP <?php $link = $_POST['newlink']; echo "<a href='$link'>LINK TO WHATEVER YOU TYPED IN</a>"; ?> -
is there a free php sitemap generator script?
sKunKbad replied to ballhogjoni's topic in PHP Coding Help
I use one on my site called phpSitemapNG, and it works well. It writes both a google sitemap and a yahoo sitemap. The website where i got it is http://enarion.net/google/phpsitemapng/ -
If I remember right from my experience, you can't include the session_start();, or at least it didn't work for me.
-
where is your session_start(); ? This must be included at the top of every page.
-
[SOLVED] Form validation.. this should work..
sKunKbad replied to spfoonnewb's topic in PHP Coding Help
<?php if (eregi("^[a-z0-9]+$", "test")) { echo "Valid"; } else { echo "Invalid"; } ?> -
[SOLVED] Hyperlink Ajax Onclick Bookmark Question
sKunKbad replied to sKunKbad's topic in Javascript Help
Once again I solved my own question by looking at code from around the net somewhere. If you have hyperlinks that are using the onclick event, the proper format for the hyperlink is as follows: <a href='javascript:;' onclick='yourAjaxFunction();'>Click me</a> -
[SOLVED] Multiple divs changed within one response?
sKunKbad replied to sKunKbad's topic in Javascript Help
I was able to solve my problem with javascript's built in function "split". I simply divided my response with "|js-split-here|", and replaced what was inside the divs with the following code modification to my handleResponseGet function: function handleResponseGet() { if(http.readyState == 4 && http.status == 200){ // Text returned from PHP script var response = http.responseText; var myresponse_array=response.split("|js-split-here|"); //if(response) { // Update main-container div content document.getElementById("left-side").innerHTML = myresponse_array[0]; document.getElementById("tippic").innerHTML = myresponse_array[1]; //} } } Here is the MySQL queries divided by "|js-split-here|": <?php $tipPage = $_GET['tip']; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); $tipRow = mysql_fetch_array($thisTip); extract($tipRow); echo "<h2>$tipTitle</h2>\n"; echo "\t\t\t\t\t\t\t\t$tipCode\n"; ?> |js-split-here| <?php $tipPage = $_GET['tip']; $picQuery = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); $picRow = mysql_fetch_array($picQuery); extract($picRow); echo "$tipPic\n"; ?> Everything works perfectly. -
I have some standard AJAX code, straight out of the ajaxfreaks tutorial "Simple Introduction to AJAX and XMLHttpRequest", but the problem for me is, my script that runs MySQL queries returns content that shouldn't be in the same div. I need the results of two seperate MySQL queries to populate two seperate divs that are not connected. I found an example that parses XML for the seperation of what would populate the divs, but I tried to tweak it to work with what I am doing, and had no luck. The article that example is in is "Ajax and XML: Five common Ajax patterns". It would be great if there was a tutorial on how to do this, but there isn't that I can find anywhere online. So, I'm hoping for some help here. Here is my javascript that populates only one div: // Set path to PHP script var phpscript = 'tipselector.php5'; function createRequestObject() { var req; if(window.XMLHttpRequest){ // Firefox, Safari, Opera... req = new XMLHttpRequest(); } else if(window.ActiveXObject) { // Internet Explorer 5+ req = new ActiveXObject("Microsoft.XMLHTTP"); } else { // There is an error creating the object, // just as an old browser is being used. alert('There was a problem creating the XMLHttpRequest object'); } return req; } // Make the XMLHttpRequest object var http = createRequestObject(); function sendRequestGet(act) { // Open PHP script for requests http.open('get', phpscript+'?tip='+act); http.onreadystatechange = handleResponseGet; http.send(null); } function handleResponseGet() { if(http.readyState == 4 && http.status == 200){ // Text returned from PHP script var response = http.responseText; if(response) { // Update main-container div content document.getElementById("main-container").innerHTML = response; } } } and here are the MySQL queries in the tipselector.php5 script: <?php $tipPage = $_GET['tip']; $picQuery = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); $picRow = mysql_fetch_array($picQuery); extract($picRow); echo "$tipPic"; ?> <?php $tipPage = $_GET['tip']; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); $tipRow = mysql_fetch_array($thisTip); extract($tipRow); echo "<h2>$tipTitle</h2>"; echo "$tipCode"; ?> Once again, the results of these two queries need to populate two completely seperate divs. Any help is appreciated.
-
I'm using hyperlinks with onclick events to change the page contents. The hyperlinks have onclick events that call the php/mysql content that fills the content div of the page. I was under the impression that since there was an onlick event in my hyperlink that the onclick would take precidence over actual href. I need to be able to have the links in href so that people can bookmark the actual page views. How can this be done?
-
This is a tutorial on ajaxfreaks.com http://www.ajaxfreaks.com/tutorials/2/0.php and is exactly what you are trying to do.
-
I don't know what to say. I know that there are definately differences in hosts, and how mod rewrite is implemented. The rewrite rule that I showed you would definately work on the server I am on.
-
Try adding: Options FollowSymLinks above RewriteEngine On and see what happens
-
I'd like to know if it is possible to set up rules that only apply to a single file, for instance "foo.php".
-
you dont need to escape the . before php, and you dont need the $ after, and you should have a slash before parser, like this: RewriteRule ^(.*).php /parser.php?this_file=$1
-
Although this is a mod rewrite, I'm hoping somebody can help me with what I am doing because it involves regex. I've got this mod rewrite rule: ^books/(Title|Author|Keyword)/(.+)/([0-9]+).php5 /newbooks.php5?Action=Search&SearchIndex=Books&SearchString=$1&SearchBy=$2&Page=$3 and its supposed to turn a URLs functionality like this: http://www.mysite/books/Title/jeronimo/1.php5 into this: http://www.mysite/newbooks.php5?Action=Search&SearchIndex=Books&SearchString=star+wars&SearchBy=Title&Page=1 but its not working. Is this my regex, or something else? I have the regexbuddy, so I was pretty certain it wasn't my regex, but i don't know 100%. The URL parameters come from a form, and the action script takes the url parameters and puts them in the new mod rewrite URL like this: if ($_GET['Action'] == 'Passthru'){ header("Location: http://www.mysite.com/books/{$_GET['SearchBy']}/{$_GET['SearchString']}/{$_GET['Page']}.php5"); } The new URL does show up in the browser, so I don't have a clue what is going on. Do you?
-
You must use DISTINCT in your query. $query=mysql_query("SELECT DISTINCT`username` FROM `userlogin` ORDER BY `ID` DESC"
-
i need a help with .htaccess rewrite file..please !
sKunKbad replied to arcademint.com's topic in Apache HTTP Server
Options FollowSymLinks rewriteEngine on rewriteRule ^http://www.site1.com/images/(.*).jpg /http://www.site2.com/images/$1.jpg try putting that in your .htaccess file -
I did a mod rewrite for a new program I have on my site, and I just want to know more about what I am doing. I was successful, but have questions: 1) What is FollowSymLinks, and what is the difference between Options FollowSymLinks and Options +FollowSymLinks. I had to use Options FollowSymLinks to get my rewrite to work. It's a godaddy server so maybe that means something. 2) Options +FollowSymLinks -MultiViews works instead of Options FollowSymLinks, but if -Multiviews is removed, the plus sign in front of FollowSymLinks has to be removed for the rewrite to work. So what is with the plus sign, and what is -Multiviews? Is there any need to use [R=301,L] for a standard rewrite rule? Will I be penalized by search engines for not supplying the 301 redirect info? Will I have any other problems without including it? I have seen the official apache documentation, but it is too uberGeek for me to understand. Is there a dummies guide to this anywhere? Rewrites for boneheads? I'm no stranger to regex, so what I'm looking for is the Options info, etc. In case anyone else needs a rewrite on a godaddy server, here is what I used: Options FollowSymLinks rewriteEngine on rewriteRule ^tips/([0-9]+).php5 /test/tips.php5?tip=$1 [NC]
-
I'm working on creating a sidebar that has all of the links to content that appears on the page, and when clicking the links they sometimes work fine and other times I get this server error: Ive never seen anything like this, and my code seems to be simple, so I don't know what is going on. It all started when I worked on this code tonight: <?php if (!isset($_GET['tip'])){ $tipPage = 'current'; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipType = '$tipPage'"); }else{ $tipPage = $_GET['tip']; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); } $row = mysql_fetch_array($thisTip); extract($row); echo "$tipTitle\n"; echo "$tipCodeTop\n"; echo "$tipPicMid\n"; echo "$tipCodeMid\n"; echo "$tipPicBottom\n"; echo "$tipCodeBottom"; ?> It seems pretty straight forward to me. This is on godaddy servers. Its really weird that when I get the error, if I refresh the page it usually shows the appropriate page with content. Here is the complete code minus the database connection: <?php echo "<h2 style='margin-bottom:-17px;'>Past Tips & Tricks</h2><ul>"; $tipTypes = array(exhaust,suspension,engine); foreach ($tipTypes as $tipCat){ $query = "SELECT * FROM tipsntricks WHERE tipType = '$tipCat'"; $result = mysql_query($query); $num_rows = mysql_num_rows ($result); if ($num_rows != 0){ echo "<li class='prodcat'><h3>" . ucfirst($tipCat) . "</h3><ul>"; while($row = mysql_fetch_array($result)){ extract($row); echo "<li><a href='" . $_SERVER['SELF'] . "?tip=" . $tipNum . "'>" . $tipTitle . " </a></li>"; } echo "</ul></li>"; } } echo "</ul>"; ?> <?php if (!isset($_GET['tip'])){ $tipPage = 'current'; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipType = '$tipPage'"); }else{ $tipPage = $_GET['tip']; $thisTip = mysql_query("SELECT * FROM tipsntricks WHERE tipNum = '$tipPage'"); } $row = mysql_fetch_array($thisTip); extract($row); echo "$tipTitle\n"; echo "$tipCodeTop\n"; echo "$tipPicMid\n"; echo "$tipCodeMid\n"; echo "$tipPicBottom\n"; echo "$tipCodeBottom"; ?> Anyone know what's going on with this?
-
This is as good as it gets: $tipTypes = array(exhaust,suspension,engine); foreach ($tipTypes as $tipCat){ $query = "SELECT * FROM tipsntricks WHERE tipType = '$tipCat'"; $result = mysql_query($query); $num_rows = mysql_num_rows ($result); if ($num_rows != 0){ echo "<h3>" . ucfirst($tipCat) . "</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "Tip Number: " . $tipNum . "<br />"; echo "Tip Title: " . $tipTitle . "<br />"; echo "<img src='" . $tipPicTop . "' /><br />"; } } } Anyone got something better?
-
OK, I came up with this on my own... but If there aren't any rows I don't want the <h3> to print... $tipTypes = array(exhaust,suspension,engine); foreach ($tipTypes as $tipCat){ $query = "SELECT * FROM tipsntricks WHERE tipType = '$tipCat'"; $result = mysql_query($query); if($result) { echo "<h3>" . ucfirst($tipCat) . "</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "Tip Number: " . $tipNum . "<br />"; echo "Tip Title: " . $tipTitle . "<br />"; echo "<img src='" . $tipPicTop . "' /><br />"; } } }
-
I have 3 select queries which i was hoping to condense into a single query. The output is going to be a catagorized list. It works the way it is, and so its not entirely necessary to do this, but I just like learning more, and I'm stuck with this one. Is it possible to condense this into a single query and have loops within loops to do the same thing? $query = 'SELECT * FROM tipsntricks WHERE tipType = "exhaust"'; $result = mysql_query($query); if($result) { echo "<h3>Exhaust Modifications</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "Tip Number: " . $tipNum . "<br />"; echo "Tip Title: " . $tipTitle . "<br />"; echo "<img src='" . $tipPicTop . "' /><br />"; } } $query = 'SELECT * FROM tipsntricks WHERE tipType = "suspension"'; $result = mysql_query($query); if($result) { echo "<h3>Suspension Modifications</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "Tip Number: " . $tipNum . "<br />"; echo "Tip Title: " . $tipTitle . "<br />"; echo "<img src='" . $tipPicTop . "' />"; } } $query = 'SELECT * FROM tipsntricks WHERE tipType = "engine"'; $result = mysql_query($query); if($result) { echo "<h3>Engine Modifications</h3>"; while($row = mysql_fetch_array($result)){ extract($row); echo "Tip Number: " . $tipNum . "<br />"; echo "Tip Title: " . $tipTitle . "<br />"; echo "<img src='" . $tipPicTop . "' />"; } }