Jump to content

achintha

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

achintha's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks you sir.....
  2. Hi, I need simple function to validate email address format. I have found follwoing function form google. function isemail($email){ return (bool)ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } It's working fine with php < 5.2. But when I'm using with PHP 5.3 is says Is any solution to this without error disable? Thanks
  3. I found image resizing code. But it's only showing the resized image. But I want to save it to server.how can I do that? 1. <?php 2. header('Content-type: image/jpeg'); 3. //$myimage = resizeImage('filename', 'newwidthmax', 'newheightmax'); 4. $myimage = resizeImage('test.jpg', '150', '120'); 5. print $myimage; 6. 7. function resizeImage($filename, $newwidth, $newheight){ 8. list($width, $height) = getimagesize($filename); 9. if($width > $height && $newheight < $height){ 10. $newheight = $height / ($width / $newwidth); 11. } else if ($width < $height && $newwidth < $width) { 12. $newwidth = $width / ($height / $newheight); 13. } else { 14. $newwidth = $width; 15. $newheight = $height; 16. } 17. $thumb = imagecreatetruecolor($newwidth, $newheight); 18. $source = imagecreatefromjpeg($filename); 19. imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 20. return imagejpeg($thumb); 21. } 22. ?>
  4. I have coded to display mysql results.but when I enter mysql login details to onefile (config.php) I'm getting this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Here the index.php <? include("config.php"); mysql_connect($host,$user,$pass) or die("ERROR:".mysql_error()); mysql_select_db($db) or die("ERROR DB:".mysql_error()); $p = $_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view the news article! if(isset($_GET['act']) && $_GET['act'] == "view") { $id = $_GET['id']; $sql = mysql_query("SELECT * FROM data WHERE id = '$id'"); while($r = mysql_fetch_array($sql)) { $title = $r['url']; $id = $r['id']; } }else{ //view all the news articles in rows $sql = mysql_query("SELECT * FROM data order by id DESC LIMIT ".$limits.",$max ") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM data order by id DESC"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); //the table while($r = mysql_fetch_array($sql)) { $title = $r['title']; $author = $r['id']; echo "<table border='0' cellspacing='0' cellpadding='0'> <tr> <td><span style='text-decoration: none'><div align='center'><img src='$title' alt='Sinhala Comments - Suduputha.Com' border='0' /></span></div></td> </tr> <tr> <td><div align='center'><textarea name='textarea' cols='37' rows='4' onmouseover='this.focus()' onfocus='this.select()'> <a href= \"http://www.suduputha.com\" target=\"_blank\"><img src=\"$title\" alt=\"Sinhala Comments - Suduputha.Com\" border=\"0\"></a><b><table border=\"1\" cellspacing=\"1\" bgcolor=\"#FFFFFF\" style=\"border-collapse: collapse\" bordercolor=\"#000000\" id=\"table1\"><tr><td><font face=\"Tahoma\" style=\"font-size: 8pt; font-weight: 700\"><a target=\"_blank\" href=\"http://www.Suduputha.com\"><font color=\"#000000\"><span style=\"text-decoration: none\">Get Free Sinhala Comments</span></font></a></font></td></tr></table></textarea></div><br><br>"; } //close up the table echo "<div align='center'>"; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='index.php?p=$i'>$i</a> | "; } echo"</div>"; } ?> Here the config.php <? //Database Settings $host = "localhost"; //your sql host, usually 'localhost' $user = "****"; //username to connect to database $pass = "****"; //password to connect to database $db = "****"; //the name of the database $max = 5; //amount of articles per page. change to what to want ?>
×
×
  • 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.