Jump to content

Yesideez

Members
  • Posts

    2,337
  • Joined

  • Last visited

Everything posted by Yesideez

  1. Any chance you can post the structure of the tables you want to read and the contents of the function "cleanquerydata()" please?
  2. I'm not sure what issue you're actually having - the data held inside $d_dailtstatistics is an array so you can access any piece of data in any order. You might find it easier if you use mysql_fetch_assoc() instead as you can read the array by name rather than index. For example, if you had the date in your table as "dt" then you would use this to access it: echo $d_dailystatistics['dt'];
  3. I tried reading through that but got lost but can add one bit. You've got a large chunk of links being thrown out and you can tidy that up a bit. <a href="<? echo $siteurl; ?>/bio.php?username=<? echo $username; ?>" class="mwtabslink">Biography</a> Can be cut down to: makeURL($siteurl,$username,'Biography'); Then you have a function to make the link: function makeURL($url,$uname,$str) { echo '<a href="'.$url.'/bio.php?username='.$uname.'" class="mwtabslink">'.$str.'</a>'."\n"; } The "\n" on the end isn't needed, it just helps reading the source easier if you "View Source" in your browser.
  4. I have to admit to not making a template system which the code reads in and adds the relevant HTML but what I do is I make a file called template.html which contains all my HTML as I want it and I have the css file called screen.css and as this file gets built it's the actual file I use for the site. After I've got my HTML file looking nice I split that into smaller files ready to be included like between the <head> and </head> (head.php), title of the site (title.php), menu (menu.php) and footer (footer.php) and anything else I might need like maybe right news/updates panel (news.php) I then code around those files first writing all the class basics and going on from there. Probably not how you meant but that's how I do it.
  5. Just a quick note. If your web space (or future web space) has PHP set up to be strict this: $userQuery=$_POST['name']; will throw a warning. I'd use a ternary here like this: $userQuery=(isset($_POST['name']) ? $_POST['name'] : ''); That way if the $_POST['name'] is set it'll get the content and assign it to the variable otherwise it'll be assigned an empty string. You could replace '' with null for example: $userQuery=(isset($_POST['name']) ? $_POST['name'] : null); Or instead of null you could even specify a default value.
  6. I got into the habit of using backticks right from the start. Not a bad thing as I think it makes queries slightly more readable.
  7. You don't say if it works or not, if not where it fails, no error messages and the list goes on...
  8. First, check this out: http://php.net/manual/en/function.filesize.php I think you need to use that on $target_path at some point, maybe when letting the user know the file has been uploaded?
  9. I don't know if you can use any of this source - feel free - I wrote this ages ago to list all the files inside a specific folder on the server building up a multi dimensional array where the files and dirs are split into two groups. <?php /************************************************************** ** Get the contents of a directory ** ** Place the contents into an array then sort alphabetically ** **************************************************************/ $strDirName=$_SERVER['DOCUMENT_ROOT']; //PATH $arrContents=array('dir' => array(),'file' => array()); //MAKE ARRAY $strMessage=''; if ($ptrLock=@opendir($strDirName)) { //GET DIRECTORY LOCK clearstatcache(); while (false!==($strFilename=@readdir($ptrLock))) { if ($strFilename!='.'&&$strFilename!='..') { //IGNORE "." AND ".." if (is_dir($strDirName.'/'.$strFilename)) { //IS THE ENTRY A DIRECTORY? array_push($arrContents['dir'],$strFilename); //YES } else { array_push($arrContents['file'],$strFilename); //NO } } } sort($arrContents['dir']); //SORT THE DIRECTORIES sort($arrContents['file']); //SORT THE FILES closedir($ptrLock); //RELEASE THE DIRECTORY LOCK } else { $strMessage='ERROR: Unable to lock directory ('.$strDirName.')'; } if (isset($_GET['debug'])) { var_dump($arrContents); } ?> <html> <head> <title>Dir Test</title> <style type="text/css"> td {font: 10px verdana} </style> </head> <body> <?php if (empty($strMessage)) { echo '<table cellspacing="1" cellpadding="0" border="0">'; echo '<tr><td colspan="2">Directory: '.$strDirName.'/</td></tr>'; for ($i=0;$i<count($arrContents['dir']);$i++) { //SHOW THE DIRECTORIES echo '<tr><td width="17"><img src="gfx/folder.gif" alt="Folder" width="16" height="16" border="0" /></td><td>'.$arrContents['dir'][$i].'</td></tr>'; } for ($i=0;$i<count($arrContents['file']);$i++) { //SHOW THE FILES $tmp=explode('.',$arrContents['file'][$i]); $strFileExt=strtolower($tmp[count($tmp)-1]); switch ($strFileExt) { case 'php':$strFileType='php';break; case 'gif': case 'jpeg': case 'jpg':$strFileType='picture';break; case 'htm': case 'html':$strFileType='html';break; default:$strFileType='file'; } echo '<tr><td width="17"><img src="gfx/'.$strFileType.'.gif" alt="File" width="16" height="16" border="0" /></td><td>'.$arrContents['file'][$i].'</td></tr>'; } echo '</table>'; } else { echo $strMessage; } ?> </body> </html>
  10. In all honesty I'm not sure if I'd write a function for it as the code would only have to be used once.
  11. In the script that displays the topic have something like this: mysql_query("UPDATE topic SET click=click+1 WHERE topicid=".$topicid);
  12. Okies In that case you're going to need to be refreshing the page each time. This means you'll be scanning the pictures folder each time - as you build up the list of files build an array at the same time and default the first picture to view as 1 if the index number isn't set on the URL: [code=php:0]$intPicNum=(isset($_GET['pic']) ? intval($_GET['pic']) : 1); Now for the next/prev buttons: <a href="picviewer.php?pic=<?php echo ($intPicNum-1); ?>">Prev</a> <a href="picviewer.php?pic=<?php echo ($intPicNum+1); ?>">Next</a> Of course, you'll need to add checks in there at $intPicNum is already at the first or last picture - no need to make the "next" link if the user is at the last picture already!
  13. I'd have my routine read through the files on the server building up an array in Javascript containing all the filenames. Then you can have a viewer where you use "onclick" events for the next and previous buttons where you have something like: <img src="pictures/firstpic.jpg" id="picviewer"> Then something like this for the buttons: <input type="button" value="Prev" onclick="showPreviousPicture()"> Inside the javascript function showPreviousPicture() you would have something like: document.getElementById("picviewer").src=arrPicList[num-1];
  14. I posted a similar topic a few days ago where my cURL script wasn't "pressing submit" for me. It was loading my script with the referer set and everything but getting it to "press submit" automatically proved to be a complete pain. If your submit button has the name "sublogin" then you can try this: curl_setopt ($ch,CURLOPT_POSTFIELDS,'user=tom&pass=test&login_theme=cpanel&sublogin=Commit'); If that still fails to work check the form itself in the browser and see if there are any hidden fields set.
  15. Try this... if ( isset($_GET['subtractwin']) ) { $sql = 'UPDATE `teams` SET `wins` = `wins` - 1 WHERE `id` = \'' . mysql_real_escape_string($_GET['team']) . '\''; echo $sql.'<br>'; mysql_query($sql); } Then try the code. Once you get the query in your browser copy and paste it into phpMyAdmin and see if it generates an error - if it does, you've found the problem.
  16. A notice is nothing realy to worry about but ideally you'd want to strive to eliminate them. All it means is that you're accessing something [variable] that hasn't yet been set. In your case one or more of those variables are being referenced without being defined.
  17. Just thought - if your PHP routine above is outputing straight into a Javascript routine change the > and < for the > and < respectively and try again.
  18. You can post your Javascript and I'll have a quick look but you're better off posting that in the Javascript section - also because if I can't sort it someone else might. As for the above script, if hostip.info ever goes down or has difficulties your web page will have until file_get_contents() times out. I just knocked this up using cURL that will wait a maximum of 2 seconds - you can change this to however long you want your script to wait, replace the file_get_contents line with the following: $ch=curl_init('http://api.hostip.info/country.php?ip='.$ip); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_HEADER,false); curl_setopt($ch,CURLOPT_TIMEOUT,2); $country=curl_exec($ch); if (curl_errno($ch)) { echo 'ERROR'; } curl_close($ch);
  19. My bad - mysql_num_rows won't work with UPDATE - missed that first time round. http://php.net/manual/en/function.mysql-num-rows.php
  20. As an extra, if you're choosing multiple country codes a switch() conditional would be better. switch ($country) { case "US": echo "<American-English Ringtone Ad Tag>"; break; case "UK": case "IE": case "AU": echo "<British-English Ringtone Ad Tag>"; break; default: echo "<YPN Ad Tag>"; }
  21. Check the syntax of your MySQL query - check spellings of the table and all field names as something is incorrect.
  22. <?php $ip = $_SERVER['REMOTE_ADDR']; $country = file_get_contents('http://api.hostip.info/country.php?ip='.$ip); if ($country=="US") { echo "<American-English Ringtone Ad Tag>" ; } elseif ($country=="AU" || $country=="UK" || $country=="IE") { echo "<British-English Ringtone Ad Tag>"; } else { echo "<YPN Ad Tag>"; } ?> Couple of things... 1. PHP uses || instead of OR 2. If displaying < or > on a web page you need to use the codes otherwise the browser will try and interpret the contents as HTML and nothing will be displayed
  23. Thanks - it worked!!! http://www.pictureinthesky.net/curl/readpage.php
  24. Thanks Farkie - I'll give that a go now - I owe you one pulled my hear out last night over this!
×
×
  • 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.