Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. I would go in a totally different way, and let PHP generate the images, all you have to do is pass the name to the PHP image file. The steps are. 1. Choose your font file. You can use any True Type Font, or .ttf file, some located Here 2. Make you a PHP file named image.php, it should look like: image.php <?php // Set the content-type header('Content-type: image/png'); $text = (isset($_GET['text'])) ? preg_replace('~[^a-zA-Z\.\s]~','',$_GET['text']) : exit(); $font = 'A.C.M.E._Explosive_Bold.ttf'; //location of your true type font. File name should NOT have any spaces. // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 150, 150, 150); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // Add some shadow to the text imagettftext($im, 20, 0, 31, 30, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 30, 29, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> 3. After login, set their name to a $_SESSION variable. //Login is complete. $_SESSION['user'] = $userId; 4. Pass the user id to the image file through an html image tag. <img src="image.php?text=<?php echo $_SESSION['user']; ?>" alt="none" /> Or for testing <img src="image.php?text=John%20Smith" alt="none" />
  2. Ereg is depreciated. Of course you could do: echo str_replace('x','in. x ',$row['DIMENSIONS']) . 'in.';
  3. Try using the DATE(), MONTH(), YEAR() functions in Mysql. Ex. SELECT MONTH(`date`) FROM table; SELECT * FROM table WHERE MONTH(`date`) = MONTH('2009-01-01 00:00:00') AND YEAR(`date`) = YEAR('2009-01-01 00:00:00'); SELECT * FROM table WHERE MONTH(`date`) = '12' AND YEAR(`date`) = '2009';
  4. This should work: SELECT * FROM table WHERE 1 IN(`categoryid`);
  5. You are losing your the id in your url after the submit. You could do this 2 ways. 1. post the form to: echo '<form action="" method="post">'; 2. Add a hidden input field holding the Id, and grab it via the $_POST array.
  6. https://www.paypalobjects.com/en_US/ebook/subscriptions/integrating.html Describes how Paypal talks to your site when set up with the subscribe button.
  7. ++$i increments the number BEFORE testing against it, $i++ would increment it AFTER the test runs.
  8. Try something like: <?php $i = 0; foreach($pictures->result() as $p): if(++$i == 9) break; ?> <div class="item"> <ul> <li><a href="images/gallery/<?=$p->category;?>/<?=$p->photo_name;?>" rel="example1" ><img src="images/gallery/<?=$p->category;?>/thumb_<?=$p->photo_name;?>" alt="#" /></a></li> </ul> </div><!-- end item --> <?php endforeach; ?>
  9. So you want to get rid of the passwords in this file. $filename = 'text.txt'; //name of your file. $file = file($filename); //pull the file, and put it in an array. foreach($file as $v) { //loop through the array. list($email,$password) = explode(':',$v); //split each row by the : assigning the variable $email before the colon, and $password after it. $emails[] = $email . ','; //append a comma onto the end of the email, and assign it to the emails array. } file_put_contents($filename,implode("\n",$emails)); //implode the data on a newline and send it back to the file, in OVERWRITE mode. This will do it, although make sure you really want to, or at least make a copy of the original incase you want to reverse it.
  10. CREATE TABLE cdKey ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, cd_keys VARCHAR(100) NOT NULL, used_by VARCHAR(20) NOT NULL, used INT(1) DEFAULT 0 ); $sql = "SELECT id,cd_key FROM cdKey WHERE used = 0 ORDER BY id DESC LIMIT 1"; $result = mysql_query($sql); //Get the results of the query into a resource pool. if(mysql_num_rows($result) > 0) { //if that resource contains data. $row = mysql_fetch_row($result); //pull that data from the resource pool. echo $row[1]; //the second index should hold the cd_key. $user = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); //get the users ip address <- faulty at best. $sql = "UPDATE cdKey SET used=1, used_by='$user' WHERE id={$row[0]}"; //update the cd_key row to used, and inserts the users IP address. mysql_query($sql); //execute the query. } Something along these lines should do it. You really need to nail down how you want the system to interact with your software. What data you want to collect from the user, and log to the cd_key. If you want to assign a software code to the cd_key. ETC.
  11. If $pictures->result() holds an array of 9 pictures, then you shouldn't need the for loop, just take it out. Right now you are printing 9 images of the same picture. Removing the for loop will let it move on to the next image in $pictures->result() after it displays the image.
  12. Guys I think it would be valuable for you two, to take 30 minutes, and look at the video/s that Garethp linked to. They will get you on track for an EFFICIENT system, that when you have a lot of people tied to it, it will not fail. Running your tables through Normalization Forms will help you build efficient queries as well. Eliminating the overhead of multiple database interactions. Of course, this is just my opinion.
  13. Dreamweaver is horrible at making PHP code, and alot is redundant, even more is useless. All of the queries will be processed by a do/while loop, that needs to be changed to a while loop, etc. Post this entire script, and we can get you pointed in the right direction.
  14. Not sure you need the for loop in there.
  15. 1. Load the page as Pik suggested. Then follow these instructions. Open this page and see if there is a section named MySQL. 2. IF IT DOESN"T, re-compile the installation with MySQL support. 3. IF IT DOES. Open up the file php.ini and make sure the line to enable MySQL support is un-commented. In Linux that line is: extension=mysql.so In Windows that line is: extension=php_mysql.dll Ensure that the files php_mysql.dll and libmysql.dll can be reached by php by modifying and uncommenting the line: extension_dir = "C:\php\ext\"
  16. You are pulling it from a different directory than you thought. Check your browsers source, and it will tell you where the image, it is looking at, is located.
  17. I believe it returns the data back to the notify_url, which is the IPN.
  18. You are correct, David. The manual does state that. And that using GROUP BY will return the same results as DISTINCT in many cases. But, I wasn't following the KISS rule on this one.
  19. You could create a timestamp column that is set to: ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP Then when you create or update a record the current timestamp will be inserted into that column. A simple query would then return the result. $sql = "SELECT * FROM table ORDER BY ts DESC LIMIT 1"; $result = mysql_query($sql); if(mysql_num_rows($result) > 0) { $r = mysql_fetch_assoc($result); echo $r['ts'] . ' is the most recent record!'; } PS. I may be wrong, but mysql_insert_id() will not retrieve an auto_increment id from an UPDATE query.
  20. where that written, i do it that way???? (i do use a primary key thu. Le Manuel Distinct Optimization There are comments at the bottom that suggest the INNER JOIN. I have found that to work in EVERY case that I have had trouble using a ORDER BY in a DISTINCT Op query.
  21. That is the simple way out, but you will have tons of overhead checking 20,000 queries. Quite simply there is no good way of doing what you want. My suggestion would be to take sohaibshaheen's advice, and implement that advice into a script that will enter the 8,000 file names into the database. That way the script will only run once, and your existing scripts will take over from there.
  22. Un-tested function stringToAnchor($str) { return preg_replace('~((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+)~','<a href="$1">$1</a>',$str); } //Testing echo stringToAnchor('You can find the best deals at http://www.google.com');
  23. Your welcome, as a side note, you can alter the database table (only if you are comfortable doing so). $sql = "ALTER TABLE members ALTER user_balance SET DEFAULT '25.00'"; mysql_query($sql); I would like to add, that this is only if the user of the database has the ability to alter tables.
  24. If you wanted to go the extra mile, you could use javascript/Ajax to query the server and make sure items are valid as the user types them. Also, session_register() is depreciated. No need to use it.
  25. Here is a paper that details what to expect kiddies to try, and how to get around it. But, you will have to read and comprehend.
×
×
  • 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.