Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. HTML: <div id="awards"> <ul> <li><img src="images/awards/first.jpg" width="12" height="27" /></li> <li><img src="images/awards/second.jpg" width="12" height="27" /></li> <li><img src="images/awards/third.jpg" width="12" height="27" /></li> </ul> </div> CSS: #awards { display: block } #awards ul li { display: inline }
  2. <select name='ATTEND" . $info['id'] . "'> Is not what I told you to use: <select name='attend[" . $info['id'] . "]'> This will create: <select name='attend[1]'> <select name='attend[10]'> <select name='attend[3]'> and can be accessed in php as: $_POST['attend'][1]; $_POST['attend'][10]; $_POST['attend'][3];
  3. Google. Or if you want us to take a look then post your code.
  4. if ($row && mysql_num_rows($row)) { $num = mysql_fetch_array($row); }
  5. $domain = gethostbyaddr($_SERVER['REMOTE_ADDR']); if (!preg_match('/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/', $domain)) { if (!preg_match('/(google|bing|mydomain)/', $domain)) { // tracking.. } } if (!preg_match('/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/', $domain)) Makes sure the returned address is not an ip-address but a domain name (making it safe to use in a visitor environment) if (!preg_match('/(google|bing|mydomain)/', $domain)) Makes sure the domain name is not google, bing or our own domain name // tracking.. This is where your logic will reside: add it to a database, .. P.S. I'm not sure how long gethostbyaddr() takes to resolve an ip to domain name otherwise you may want to store the ip address along with the domain name of popular search engines for example: 74.125.127.100=google.com (http://74.125.127.100).
  6. Hm... The primary key is psNumber which already contains a unique value. Plus if I change it i'm going to have to rewrite code to suit. $sql="INSERT INTO db (deliveryDate, psNumber, numItems, volume, estimatedDelivery, customerName, address1, address2, address3) VALUES ('$parts[0]','$parts[3]','$parts[4]','$parts[8]','$parts[1]','$parts[2]','$parts[5]','$parts[6]','$parts[7]') ON DUPLICATE KEY psNumber = psNumber + 1";
  7. $query = 'INSERT INTO gameprizes (name, prize, odds, gameID) VALUES (\'%s\', \'%s\', %s, NULL)'; $fquery = sprintf($query, $v['Symbol'], $v['Prize'], $v['Odds']); Here I assume that gameID is a primary key defined as: NOT NULL with the option AUTO_INCREMENT A shovel and rope comes with the package
  8. 'not implemented' means that the http protocol was not yet implemented for scandir(), opendir(), .. So you may want to look at other alternatives like FTP (http://us3.php.net/manual/en/book.ftp.php) or cURL (http://be.php.net/curl) I tried it locally and didn't work either altough allow_url_fopen = On P.S. If you opt for FTP, once you have established a ftp connection use http://be.php.net/manual/en/function.ftp-nlist.php to get all files within the directory.
  9. before you pass it to fetch_assoc() (not array if you only need the associative part) check the result first: if ($result && mysql_num_rows($result)) Won't parse any info to the textarea If you are using my code then yes this fails: $rettxt[0] change 0 to the column name.
  10. It limits certain functions a detailed report can be found here: http://be.php.net/features.safe-mode
  11. foreach($data as $key=>$v) { $query = 'INSERT INTO gameprizes (name, prize, odds, gameID) VALUES (\'%s\', \'%s\', %s, %s)'; $fquery = sprintf($query, $v['Symbol'], $v['Prize'], $v['Odds'], $gameID); $insert = mysql_query($fquery); if (!$insert) { //die("There's little problem: ".mysql_error()); $MyError = "An error occured while saving data. Please try again later." + mysql_error(); echo "<sqlError>".$MyError."</sqlError>"; } else { echo "<success>prizes added</success>"; } } I do not suggest just printing the xml like: echo '<success>..'; use dom instead: http://be.php.net/book.dom
  12. Licensing of software code is a pain, plus it's easy (for any programmer that can put 2 and 2 together) to 'null' your script (and thus bypassing your license). The way you are doing it is wrong and it would be better to give users a serial that they enter into your script and everytime it runs (or only certain parts) it queries a script on your server to see if the license hasn't expired and is allowed to get updates. Then use Zend Guard to protect your source code. However this will only make it harder not impossible to null your script. To avoid that people want to null your script think of things that make your script a necessity for them, something that motivates them to renew their license instead of null'ing it. Otherwise, If you truly want to protect your code then the best option is to host it yourself and let others pay you (yearly) for the hosting and the updates of which they benefit, but then again they may need some encouragment from time-to-time telling them why they are paying for your services and why they are worth every penny.
  13. $cdb = mysql_connect("$sqlhost", "$sqluser", "$sqlpass"); // connection mysql_connect("$sqlhost", "$sqluser", "$sqlpass"); should be: $cdb = mysql_connect($sqlhost, $sqluser, $sqlpass); If you want to create an additional connection: $cdb2 = mysql_connect($sqlhost, $sqluser, $sqlpass, true/*$new_link*/); $iddel = "DELETE ipid FROM txt"; is wrong and should be: $iddel = "DELETE FROM txt"; This will delete all rows from txt echo "mysql_error()"; does work (because of the complex string) but should be: echo mysql_error(); while($rettxt = mysql_fetch_array($rettxt)) holds to much (both numerical and associative) use mysql_fetch_assoc() instead while($rettxt = mysql_fetch_array($rettxt)) { echo "mysql_error()"; } does nothing if you want to store the result, use: $data = array(); while($rettxt = mysql_fetch_assoc($rettxt)) { $data[] = $rettxt; } STRIPSLASHES(TRIM(nl2br($rettxt[0]))) altough this works it's best to write it lowercase $txtsql['input'] = mysql_real_escape_string($_POST['input']); should be within the if (isset($_POST['submit'])) part or will throw errors otherwise $txtsq = "INSERT INTO txt (fronttxt1[[0]]) VALUES ( '{$txtsql['input']}' )"; is invalid and should be: $fonttxt1 = mysql_fetch_assoc($txtresult); $txtsq = "INSERT INTO txt (fronttxt1[[0]]) VALUES ( '{$txtsql['input']}' )";
  14. First of all, why use the @ (error-suppressing operator)? $result = @mysql_query("SELECT * FROM whatever"); mysql_query() only returns a resource or true or false, so no need to suppress. The code also need a slight modification or will throw a nasty error otherwise when your query fails and you try to access it with mysql_fetch_array() as it expects a resource and gets a boolean (false). Also don't use mysql_fetch_array() if you only use the the associative part, use mysql_fetch_assoc() instead. mysql_fetch_array() returns the result both as a numerical and as a associative array (unless a second parameter MYSQL_NUM or MYSQL_ASSOC is provided by default MYSQL_BOTH) thus doubling the result (numerical and associative instead of only the associative part) + your memory is affected to, the cached mysql result set + your array that contains the result in both a numerical and an associative array. $result = mysql_query("SELECT * FROM whatever"); if ($result && mysql_num_rows($result)) { while ($record=mysql_fetch_assoc($result)) { echo $record["adminonline"]; sleep(60*2); //Two minutes flush(); //Prevent output buffer from sleeping } }//Else: Query failed
  15. meaning $ex contains North, Dakota (two separate words) and not North Dakota (one whole word)
  16. Here is my code again with comments // absolute path to the local image directory $mydir = realdir('path/to/directory'); // path to the remote images directory $dir = 'http://radar.weather.gov/ridge/RadarImg/N0Z/EAX'; // fixed this, it had a trailing slash // get all files (images) from the remote directory $images = scandir($dir); // go over each image foreach ($images as $image) { // if $image starts with . ignore it (., .., .htaccess) if ('.' === $image[0]) continue; // 'absolute' path to the remote file (image) $fullurl = implode('/', array($dir, $image)); // absolute path to the local file (or where it should be) $fullpath = implode(DIRECTORY_SEPARATOR, array($mydir, $image)); // if the image does not yet exists, create it! if (!file_exists($fullpath)) { // get the size in bytes, we'll use this to read and write the total number of bytes $fs = filesize($fullurl); // file handle for the local image file (if it doesn't exist, mode 'w' creates it) $fh1 = fopen($fullpath, 'w'); // file handle to the remote image file (read-only, write won't work unless the server is badly configured) $fh2 = fopen($fullurl, 'r'); // write the data to $fh1 using the read data from $fh2 using a total length of $filesize bytes fwrite($fh1, fread($fh2, $filesize), $filesize); // close handles fclose($fh1); fclose($fh2); } }
  17. What does $ex contain?
  18. $row['$craftsperson_id'] should be: $row['craftsperson_id']
  19. mysql_query("UPDATE `a8129045_central`.`videos` SET thumbs_up = '$rand1'"); Updates each and every row meaning all rows will get the last random number given. Use: $id = $row['id']; mysql_query("UPDATE `a8129045_central`.`videos` SET thumbs_up = '$rand1' WHERE id = '$id'");
  20. Don't use: $result = mysql_query($query) or die("Couldn't execute query"); What usefull information does "Couldn't execute query" contain for your visitors? Please post your entire code, what does $word contain?
  21. $round = 3600;// in seconds $lastupdate = strtotime($user['lastupdate']); $diff = $time - $lastupdate; $totalhours = $diff / $round; $all_money = $totalhours * $add_money; UPDATE test SET lastupdate = now(), money = money + $all_money WHERE id = '$id'
  22. Please don't use: if (!$con) { die('Could not connect: ' . mysql_error()); } Imagine you being the clueless visitor who visits your website at the time your SQL server kicks it and sees: Could not connect: Can't connect to MySQL server on 'localhost' (2003) Instead log these and display a nice error message to your visitor that you are having some technical difficulties.
  23. Woeps sorry my bad should be realpath It returns an absolute path to your directory. You can read more about it here: http://us.php.net/manual/en/function.realpath.php
  24. both
  25. Go over each and every row and print the new day when shows_date changes so you get something like: Monday Aug 10 00:00-01:20: You should be sleeping 01:30-02:50: Still 'up? .. Tuesday Aug 11 00:00-01:20: Insomnia trouble! .. Add CSS magic to align each day next to each other don't use a table keep it as flexible as possible CSS helps you to style it like you want your visitors to view it.
×
×
  • 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.