Jump to content

Monk3h

Members
  • Posts

    223
  • Joined

  • Last visited

    Never

Everything posted by Monk3h

  1. an example of a file contained within ip_files is: <?php //4127195136-4143972351 $ranges=Array( "4127195136" => array("4143972351","ZZ"), ); ?> This is file 246.php These files are used as referances to define which ips match which countrys.
  2. Nope, that was not it. I'm reletivly new to functions. Whats the most correct way to test the function?
  3. This script should detect what contry a visitor is from via there IP and display there contrys flag. However it does not work, please could you take a look and let me know if there are any obviouse errors as im stumped. <?php $IPaddress=$_SERVER['REMOTE_ADDR']; $two_letter_country_code=iptocountry($IPaddress); Print "$IPaddress" include("IP_FILES/countries.php"); $three_letter_country_code=$countries[ $two_letter_country_code][0]; $country_name=$countries[$two_letter_country_code][1]; print "Two letters code: $two_letter_country_code<br>"; print "Three letters code: $three_letter_country_code<br>"; print "Country name: $country_name<br>"; // To display flag $file_to_check="flags/$two_letter_country_code.gif"; if (file_exists($file_to_check)){ print "<img src=flags/$file_to_check width=30 height=15><br>"; }else{ print "<img src=flags/noflag.gif width=30 height=15><br>"; } function iptocountry($ip) { $numbers = preg_split( "/\./", $ip); include("ip_files/".$numbers[0].".php"); $code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]); foreach($ranges as $key => $value){ if($key<=$code){ if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;} } } if ($two_letter_country_code==""){$two_letter_country_code="unkown";} return $two_letter_country_code; } ?> Thanks in Advance, Monk3h.
  4. http://jaynetdesign.com/carbontrust/edit.php?id=2 the id changes ofc depending on what link is clicked.
  5. This is driving me MAD! The Variable gets passed through the URL but when I try and echo the result I gte NOTHING. First Page. <?php include'config.php'; $result = mysql_query("SELECT * FROM carbontrust"); while($entry = mysql_fetch_array($result)) Print "$entry[contact] - $entry[company] :: <a href='edit.php?id=$entry[id]'>Edit</a><br>"; exit; ?> Second Page. (Where I want the Variable passed to) <?php include'config.php'; $id = $_GET['id']; echo "ID: $id"; } ?> Its probably just a stupid error but iv looked through a load of tutorials and this should be correct. :/
  6. Spelling mistake FTL! Thanks mate! Been stuck on this for hours, didn't wanna get laughed out of a forum because I knew it would be a stupid mistake. Thanks again!
  7. Unknown column 'vatreg' in 'field list'
  8. I am a bit rust at SQL and have tried to make a simple insert query but failed. Please take a look and tell me where I went wrong. $sql = ("INSERT INTO carbontrust (contact, company, address, postcode, telephone, mobile, email, employees, turnover, assetvalue, sme, tradetime, nature, typeofo, companyregisteredname, regnumber, vatreg, regaddress, catapply, fuelused, otherfuel, heatingpercent, factoryspaceheating, officeheating, hotwater, heaterrating, existingheaters, setbackheating, billavailable, factorysize, roofheighte, roofheightr, builddate, spraybooths, dustextract, air, rollershutters, weekoc, occupancy, woodwaste, woodavailable, upload) VALUES ('$contact', '$company', '$address', '$postcode', '$telephone', '$mobile', '$email', '$employees', '$turnover', '$assetvalue', '$sme', '$tradetime', '$nature', '$typeofo', '$companyregisteredname', '$regnumber', '$vatreg', '$regaddress', '$catapply', '$fuelused', '$otherfuel', '$heatingpercent', '$factoryspaceheating', '$officeheating', '$hotwater', '$heaterrating', '$existingheaters', '$setbackheating', '$billavailable', '$factorysize', '$roofheighte', '$roofheightr', '$builddate', '$spraybooths', '$dustextract', '$air', '$rollershutters', '$weekoc', '$occupancy', '$woodwaste', '$woodavailable', '$upload')"); $sql = @mysql_query($sql); The variables have been defined from a POST form. When the variables are printed out they apear correct.. However they are not inserted into the database. Please help, been stuck for AGES. Thanks in advance, James.
  9. Thnaks to you both. Problem sorted!
  10. This script returns info from my database and limits it to a certain amount of items per page, then it adds links to view more pages etc.. also know as pagition. My problem is that i have an error. Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/monk3h/public_html/WMM/minishop/page.php on line 36 Line 36: while($line = mysql_fetch_array( $qresult )) Full code: <?php include ("config.php"); $pages=$_GET['page']; //Get the current page // This the full code which will generate a paging system $limit=2; // Limit of result per page $qresult = mysql_query("SELECT * FROM items"); // Let's get the query $nrResults=mysql_num_rows($qresult); // Count the results if (($nrResults%$limit)<>0) { $pmax=floor($nrResults/$limit)+1; // Divide to total result by the number of query you want // to display per page($limit) and create a Max page } else { $pmax=floor($nrResults/$limit); } $qresult = mysql_query("SELECT * FROM items DESC LIMIT ".(($_GET["page"]-1)*$limit).", $limit"); //Need to generate query considering your limit while($line = mysql_fetch_array( $qresult )) // LINE 36 ####################### { // Now once we got the query from MySQL, we need to think what we to do it. You can do anything. This is just an example echo " Name: ".$line['id']." <br /> Age: ".$line['name']." <br /> Phone Number: ".$line['image']." <br /> "; // Here comes the Real part of this Tutorial!! } echo "<div class='navpage'>"; // Make a simple css // We need to create a Previous page, so we need $pages to be bigger than 1, otherwise at the first page we would get a 0. //For the previous to show up we need at least to be at the second page. if($pages > 1) { $prevp="<a href='http://www.riseofkingdoms.net/WMM/minishop/page.php?page=".($pages-1)."' title='Previous Page'>Previous Page</a>"; } else {echo "";} echo $prevp; // Here We want create a page from the results we got by dividing the total by the the limit. So let say you got //45 results and you want 5 results per page; these simple lines will create you 8 pages. $pid=1; while ($pid<=$pmax) { $paging= "<a href='http://www.riseofkingdoms.net/WMM/minishop/page.php?page=$pid' title='Page $pid of $pmax'> $pid</a>"; //So here, let say we are at the 3rd page and we want the 3 to be blank so the user can know where is he now. //This will act as Current Page! We need to replace the url by a text $newpaging=str_replace("<a href='http://www.riseofkingdoms.net/WMM/minishop/page.php?page=$pages' title='Page $pages of $pmax'> $pages</a>", "<span>$pages</span>", $paging); echo $newpaging; $pid++; // create pages until reach the result } //We want to create a next page and a last page, $pages have to be less than $pmax. if($pages < $pmax) { $nextp="<a href='http://www.riseofkingdoms.net/WMM/minishop/page.php?page=".($pages+1)."' title='Next Page'>Next Page</a>"; } else {echo "";} echo $nextp; echo "<a href='http://www.riseofkingdoms.net/WMM/minishop/page.php?page=$pmax' title='Last Page'>Last Page</a>"; echo "</div>"; ?> Thanks in advance.
  11. The roll-overs are in CSS and there is no Javascript in my site. o.O
  12. It is the Div Tag. How do i change it so that it has nothing around it?
  13. Backup, and my Server is supposed to have 99% uptime.. Heh..
  14. My server was down, backup now. And tehre is a line still in FF3
  15. http://riseofkingdoms.net/portfolio/4/work.php Roll over the lowest Home button. (the roll over, not the text link) When it changes you can see a line.
  16. Its almost like the DIV tags have a hidden borded that i cant see. SO ANNOYING!
  17. <?php $homepage = "index.php"; if($homepage==$currentpage) { Print "<img src='images/rollovers/homemouse_01.png' width='100' height='30'>"; }else{ Print"<div class='rollover' > <a href='#'><img src='images/rollovers/home_01.png' width='100' height='30' border='0'></a> </div>"; } $workpage = "work.php"; if($workpage==$currentpage) { Print "<img src='images/rollovers/workmouse_01.png' width='100' height='30'>"; }else{ Print"<div class='rollover'> <a href='#'><img src='images/rollovers/work_01.png' width='100' height='30' border='0'></a> </div>"; } ?>
  18. My site is constructed with 2 tables, one for the top and one for the bottom. My problem is after adding a small PHP script to the bottom of the Top table a line break has appeared between the top and bottom table. any ideas? I haven't used any line breaks anywhere in my PHP script.
  19. Monk3h

    Position help

    I have created a roll over efect using CSS within PHP. However when i print out what i want it appears one above the other instead of side by side. I have not used any <BR> or <P> Very confused. Code is below, all help greatly appreciated! <?php $homepage = "index.php"; if($homepage==$currentpage) { Print "<img src='images/rollovers/homemouse_01.png' width='100' height='30'>"; }else{ Print"<div class='rollover'> <a href='#'><img src='images/rollovers/home_01.png' width='100' height='30' border='0'></a> </div>"; } $workpage = "work.php"; if($workpage==$currentpage) { Print "<img src='images/rollovers/workmouse_01.png' width='100' height='30'>"; }else{ Print"<div class='rollover'> <a href='#'><img src='images/rollovers/work_01.png' width='100' height='30' border='0'></a> </div>"; } ?> Example is here, http://riseofkingdoms.net/portfolio/4/work.php
  20. PROBLEM SOLVED! Thanks for all the help!
  21. It reads back index.php Thats my problem! When i use index.php it dosnt work.
  22. Also, when using the full path it does not work with index.php at the end or just / however if i use the script to identify any other page apart from index.php eg projects.php it works! any ideas?
  23. The following script is suposed to change the text to a link if it is not displayed on my home page. My problem is that it does not work, i think this is because my home page is in a directory higher than www. the full path to my home page is portfolio/4/index.php How would i change my script to check there without using the full path? <?php $homepage = "/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage==$currentpage) { Print "<span style=color:#f0f492>Home</span>"; }else{ Print "<span style=color:#999999><a href='index.php'>Home</a></span>"; } ?>
  24. <?php if (!$HTTP_SERVER_VARS["HTTP_REFERER"]) $HTTP_SERVER_VARS["HTTP_REFERER"] = "./index.php"; if (!$HTTP_GET_VARS["v"]) exit ("You have not selected a layout version!"); if (!file_exists("./header".$HTTP_GET_VARS["v"].".php")) exit ("The header for that layout version does not exists, please contact the webmaster with the subject 'header".$HTTP_GET_VARS["v"].".php not exist!"); if (!file_exists("./footer".$HTTP_GET_VARS["v"].".php")) exit ("The footer for that layout version does not exists, please contact the webmaster with the subject 'footer".$HTTP_GET_VARS["v"].".php not exist!""); setCookie ('layout", $HTTP_GET_VARS['v'], time()+(365*86400)); echo ""; ?> Sorted my Syntax, same error still.
×
×
  • 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.