darubillah
-
Posts
54 -
Joined
-
Last visited
Never
Posts posted by darubillah
-
-
Hello,
I am trying to fetch data which is one day old,
I used now() function to insert current date,
What could be the query??
<? //This query will select the data which is submitted today. $sql="SELECT * FROM table_name WHERE date=". now(); ?>
so what will be the query to fetch yesterday's records, should be some thing done with now() function
Thankyou
-
Problem solved
what we have to do is to download the file from remote server to local
<?php // maximum execution time in seconds set_time_limit (24 * 60 * 60); //File Location to restore the downloaded DB $filename = 'backup/backup.zip'; //Checking if database already exists then delete it first if (file_exists($filename)) { @unlink($filename); } // folder to save downloaded files to. must end with slash $destination_folder = 'backup/'; //File URL to download zip database $url = "http://example.com/backup.zip"; $newfname = $destination_folder . basename($url); $file = fopen ($url, "rb"); if ($file) { $newf = fopen ($newfname, "wb"); if ($newf) while(!feof($file)) { fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 ); } } if ($file) { fclose($file); } if ($newf) { fclose($newf); } //Call above restore function to restore database restore($filename) ?>
-
i am on shared hosting is their any way to open it through PHP
or can you help me in coding it using cURL?
-
hi,
I am trying to restore a mysql db from a remote location
below is the function it is working fine when i am passing local location, but gives error on passing remote location
function restore($path) { $f = fopen('restore.sql' , 'w+'); if(!$f) { echo "Error While Restoring Database"; return; } $zip = new ZipArchive(); if ($zip->open($path) === TRUE) { #Get the backup content $sql = $zip->getFromName('adobe4u_new-sqldump.sql'); #Close the Zip File $zip->close(); #Prepare the sql file fwrite($f , $sql); fclose($f); #Now restore from the .sql file //$command = "mysql --user=root --password=password --database=adobe4u < restore.sql"; //exec($command); // Name of the file $filename = 'restore.sql'; // Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file($filename); // Loop through each line foreach ($lines as $line) { // Skip it if it's a comment if (substr($line, 0, 2) == '--' || $line == '') continue; // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';') { // Perform the query mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />'); // Reset temp variable to empty $templine = ''; } } // Restoring END #Delete temporary files without any warning @unlink('restore.sql'); echo '<div class="success">Successfully Updated!</div>'; } else { echo '<div class="error">Some thing went wrong! Updation Failed</div>'; } }
Please can anyone help me in it, so That if i pass a remote location of database it will extract it locally
-
hello,
I am using a script which takes backup of my database and convert it into a zip file,
I am getting following error
Fatal error: Maximum execution time of 30 seconds exceeded in /home/USERNAME/public_html/functions.php on line 110
I know I read and search forum for solving this by editing PHP.INI file, but i Have no access to it
So is their any way that I can able to run the script but modifying it??
Its working fine on localhost
I have also attached the files
<?php /** * Class to dynamically create a zip file (archive) * * @author Rochak Chauhan */ class createZip { public $compressedData = array(); public $centralDirectory = array(); // central directory public $endOfCentralDirectory = "\x50\x4b\x05\x06\x00\x00\x00\x00"; //end of Central directory record public $oldOffset = 0; /** * Function to create the directory where the file(s) will be unzipped * * @param $directoryName string * */ public function addDirectory($directoryName) { $directoryName = str_replace("\\", "/", $directoryName); $feedArrayRow = "\x50\x4b\x03\x04"; $feedArrayRow .= "\x0a\x00"; $feedArrayRow .= "\x00\x00"; $feedArrayRow .= "\x00\x00"; $feedArrayRow .= "\x00\x00\x00\x00"; $feedArrayRow .= pack("V",0); $feedArrayRow .= pack("V",0); $feedArrayRow .= pack("V",0); $feedArrayRow .= pack("v", strlen($directoryName) ); $feedArrayRow .= pack("v", 0 ); $feedArrayRow .= $directoryName; $feedArrayRow .= pack("V",0); $feedArrayRow .= pack("V",0); $feedArrayRow .= pack("V",0); $this -> compressedData[] = $feedArrayRow; $newOffset = strlen(implode("", $this->compressedData)); $addCentralRecord = "\x50\x4b\x01\x02"; $addCentralRecord .="\x00\x00"; $addCentralRecord .="\x0a\x00"; $addCentralRecord .="\x00\x00"; $addCentralRecord .="\x00\x00"; $addCentralRecord .="\x00\x00\x00\x00"; $addCentralRecord .= pack("V",0); $addCentralRecord .= pack("V",0); $addCentralRecord .= pack("V",0); $addCentralRecord .= pack("v", strlen($directoryName) ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $ext = "\x00\x00\x10\x00"; $ext = "\xff\xff\xff\xff"; $addCentralRecord .= pack("V", 16 ); $addCentralRecord .= pack("V", $this -> oldOffset ); $this -> oldOffset = $newOffset; $addCentralRecord .= $directoryName; $this -> centralDirectory[] = $addCentralRecord; } /** * Function to add file(s) to the specified directory in the archive * * @param $directoryName string * */ public function addFile($data, $directoryName) { $directoryName = str_replace("\\", "/", $directoryName); $feedArrayRow = "\x50\x4b\x03\x04"; $feedArrayRow .= "\x14\x00"; $feedArrayRow .= "\x00\x00"; $feedArrayRow .= "\x08\x00"; $feedArrayRow .= "\x00\x00\x00\x00"; $uncompressedLength = strlen($data); $compression = crc32($data); $gzCompressedData = gzcompress($data); $gzCompressedData = substr( substr($gzCompressedData, 0, strlen($gzCompressedData) - 4), 2); $compressedLength = strlen($gzCompressedData); $feedArrayRow .= pack("V",$compression); $feedArrayRow .= pack("V",$compressedLength); $feedArrayRow .= pack("V",$uncompressedLength); $feedArrayRow .= pack("v", strlen($directoryName) ); $feedArrayRow .= pack("v", 0 ); $feedArrayRow .= $directoryName; $feedArrayRow .= $gzCompressedData; $feedArrayRow .= pack("V",$compression); $feedArrayRow .= pack("V",$compressedLength); $feedArrayRow .= pack("V",$uncompressedLength); $this -> compressedData[] = $feedArrayRow; $newOffset = strlen(implode("", $this->compressedData)); $addCentralRecord = "\x50\x4b\x01\x02"; $addCentralRecord .="\x00\x00"; $addCentralRecord .="\x14\x00"; $addCentralRecord .="\x00\x00"; $addCentralRecord .="\x08\x00"; $addCentralRecord .="\x00\x00\x00\x00"; $addCentralRecord .= pack("V",$compression); $addCentralRecord .= pack("V",$compressedLength); $addCentralRecord .= pack("V",$uncompressedLength); $addCentralRecord .= pack("v", strlen($directoryName) ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("v", 0 ); $addCentralRecord .= pack("V", 32 ); $addCentralRecord .= pack("V", $this -> oldOffset ); $this -> oldOffset = $newOffset; $addCentralRecord .= $directoryName; $this -> centralDirectory[] = $addCentralRecord; } /** * Fucntion to return the zip file * * @return zipfile (archive) */ public function getZippedfile() { $data = implode("", $this -> compressedData); $controlDirectory = implode("", $this -> centralDirectory); return $data. $controlDirectory. $this -> endOfCentralDirectory. pack("v", sizeof($this -> centralDirectory)). pack("v", sizeof($this -> centralDirectory)). pack("V", strlen($controlDirectory)). pack("V", strlen($data)). "\x00\x00"; } } /* MySQL database backup class, version 1.0.0 Written by Vagharshak Tozalakyan <vagh@armdex.com> Released under GNU Public license */ define('MSB_VERSION', '1.0.0'); define('MSB_NL', "\r\n"); define('MSB_STRING', 0); define('MSB_DOWNLOAD', 1); define('MSB_SAVE', 2); class MySQL_Backup { var $server = 'localhost'; var $port = 3306; var $username = 'root'; var $password = ''; var $database = ''; var $link_id = -1; var $connected = false; var $tables = array(); var $drop_tables = true; var $struct_only = false; var $comments = true; var $backup_dir = ''; var $fname_format = 'd_m_y__H_i_s'; var $error = ''; function Execute($task = MSB_STRING, $fname = '', $compress = false) { if (!($sql = $this->_Retrieve())) { return false; } if ($task == MSB_SAVE) { if (empty($fname)) { $fname = $this->backup_dir; $fname .= date($this->fname_format); $fname .= ($compress ? '.sql.gz' : '.sql'); } return $this->_SaveToFile($fname, $sql, $compress); } elseif ($task == MSB_DOWNLOAD) { if (empty($fname)) { $fname = date($this->fname_format); $fname .= ($compress ? '.sql.gz' : '.sql'); } return $this->_DownloadFile($fname, $sql, $compress); } else { return $sql; } } function _Connect() { $value = false; if (!$this->connected) { $host = $this->server . ':' . $this->port; $this->link_id = mysql_connect($host, $this->username, $this->password); } if ($this->link_id) { if (empty($this->database)) { $value = true; } elseif ($this->link_id !== -1) { $value = mysql_select_db($this->database, $this->link_id); } else { $value = mysql_select_db($this->database); } } if (!$value) { $this->error = mysql_error(); } return $value; } function _Query($sql) { if ($this->link_id !== -1) { $result = mysql_query($sql, $this->link_id); } else { $result = mysql_query($sql); } if (!$result) { $this->error = mysql_error(); } return $result; } function _GetTables() { $value = array(); if (!($result = $this->_Query('SHOW TABLES'))) { return false; } while ($row = mysql_fetch_row($result)) { if (empty($this->tables) || in_array($row[0], $this->tables)) { $value[] = $row[0]; } } if (!sizeof($value)) { $this->error = 'No tables found in database.'; return false; } return $value; } function _DumpTable($table) { $value = ''; $this->_Query('LOCK TABLES ' . $table . ' WRITE'); if ($this->comments) { $value .= '#' . MSB_NL; $value .= '# Table structure for table `' . $table . '`' . MSB_NL; $value .= '#' . MSB_NL . MSB_NL; } if ($this->drop_tables) { $value .= 'DROP TABLE IF EXISTS `' . $table . '`;' . MSB_NL; } if (!($result = $this->_Query('SHOW CREATE TABLE ' . $table))) { return false; } $row = mysql_fetch_assoc($result); $value .= str_replace("\n", MSB_NL, $row['Create Table']) . ';'; $value .= MSB_NL . MSB_NL; if (!$this->struct_only) { if ($this->comments) { $value .= '#' . MSB_NL; $value .= '# Dumping data for table `' . $table . '`' . MSB_NL; $value .= '#' . MSB_NL . MSB_NL; } $value .= $this->_GetInserts($table); } $value .= MSB_NL . MSB_NL; $this->_Query('UNLOCK TABLES'); return $value; } function _GetInserts($table) { $value = ''; if (!($result = $this->_Query('SELECT * FROM ' . $table))) { return false; } while ($row = mysql_fetch_row($result)) { $values = ''; foreach ($row as $data) { $values .= '\'' . addslashes($data) . '\', '; } $values = substr($values, 0, -2); $value .= 'INSERT INTO ' . $table . ' VALUES (' . $values . ');' . MSB_NL; } return $value; } function _Retrieve() { $value = ''; if (!$this->_Connect()) { return false; } if ($this->comments) { $value .= '#' . MSB_NL; $value .= '# MySQL database dump' . MSB_NL; $value .= '# Created by MySQL_Backup class, ver. ' . MSB_VERSION . MSB_NL; $value .= '#' . MSB_NL; $value .= '# Host: ' . $this->server . MSB_NL; $value .= '# Generated: ' . date('M j, Y') . ' at ' . date('H:i') . MSB_NL; $value .= '# MySQL version: ' . mysql_get_server_info() . MSB_NL; $value .= '# PHP version: ' . phpversion() . MSB_NL; if (!empty($this->database)) { $value .= '#' . MSB_NL; $value .= '# Database: `' . $this->database . '`' . MSB_NL; } $value .= '#' . MSB_NL . MSB_NL . MSB_NL; } if (!($tables = $this->_GetTables())) { return false; } foreach ($tables as $table) { if (!($table_dump = $this->_DumpTable($table))) { $this->error = mysql_error(); return false; } $value .= $table_dump; } return $value; } function _SaveToFile($fname, $sql, $compress) { if ($compress) { if (!($zf = gzopen($fname, 'w9'))) { $this->error = 'Can\'t create the output file.'; return false; } gzwrite($zf, $sql); gzclose($zf); } else { if (!($f = fopen($fname, 'w'))) { $this->error = 'Can\'t create the output file.'; return false; } fwrite($f, $sql); fclose($f); } return true; } } function mailAttachment($file, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $filename = basename($file); $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use diff. tyoes here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, "", $header)) { echo "mail send ... OK"; // or use booleans here } else { echo "mail send ... ERROR!"; } } function directoryToArray($directory, $recursive) { $array_items = array(); if ($handle = opendir($directory)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($directory. "/" . $file)) { if($recursive) { $array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive)); } $file = $directory . "/" . $file ."/"; $array_items[] = preg_replace("/\/\//si", "/", $file); } else { $file = $directory . "/" . $file; $array_items[] = preg_replace("/\/\//si", "/", $file); } } } closedir($handle); } return $array_items; } function pr($val) { echo '<pre>'; print_r($val); echo '</pre>'; } ?>
[attachment deleted by admin]
-
COoool Thnx every1 for solving my prob,
n
@kenrbnsn
you code look too awesome, but i cant figure out how to use it
my prob is solved but still wanna know how to use it.
-
Oh I got that Paul lemme try it,
actually with out using mysql_real_escape_dtring() it may breaking my query coz i have quote text fields
i'll back
-
@harristweed
done as you said above but now it show this error
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 ''ProductName', 'CategoryID', 'ShortDesc', 'LongDesc', 'TrialURL', 'Boxshot', 'Sc' at line 1
-
can u please tell me how to do it, coz i am very new to PHP
-
I am getting the following error when performing insertion in mysql db
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 's Editor's Choice * Secures against internal and external attacks * Bl' at line 1
This is my script, I cant figure out the prob, some time it insert record successfully and sometime not.
<?php $con = mysql_connect("localhost","userName","PassWord"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_name", $con); $sql = "INSERT INTO `ura_items` (`ProductName`, `CategoryID`, `ShortDesc`, `LongDesc`, `TrialURL`, `Boxshot`, `Screenshot`, `VendorID`, `VendorName`, `VendorHomepageURL`, `Add_Date`, `size`, `soft_type`, `current_ver`) VALUES("; $sql .= "'$_POST[ProductName]', '$_POST[CategoryID]', '$_POST[shortDesc]', '$_POST[LongDesc]', '$_POST[TrialURL]', '$_POST[boxshot]', '$_POST[screenshot]', '$_POST[VendorID]', '$_POST[VendorName]', '$_POST[VendorHomepageURL]', now(), '$_POST[size]', '$_POST[soft_type]', '$_POST[current_ver]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added <br /> <br /> <a href=\"addproduct.php\">Back</a>"; mysql_close($con) ?>
Please help me
-
hello,
this is my .htaccess code
DirectoryIndex index.php RewriteEngine On # RewriteRule ^page/(.*)$ index.php?cstart=$1 [L] # RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&cstart=$5&news_name=$6 [L] RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page,([0-9]+),(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L] RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/print:page,([0-9]+),(.*).html(/?)+$ engine/print.php?subaction=showfull&year=$1&month=$2&day=$3&news_page=$4&news_name=$5 [L] RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*).html(/?)+$ index.php?subaction=showfull&year=$1&month=$2&day=$3&news_name=$4 [L] RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$4&news_page=$2&cstart=$3 [L] RewriteRule ^([^.]+)/page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$2 [L] RewriteRule ^([^.]+)/print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$2&newsid=$3 [L] RewriteRule ^([^.]+)/([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2 [L] RewriteRule ^page,([0-9]+),([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$3&news_page=$1&cstart=$2 [L] RewriteRule ^page,([0-9]+),([0-9]+)-(.*).html(/?)+$ index.php?newsid=$2&news_page=$1 [L] RewriteRule ^print:page,([0-9]+),([0-9]+)-(.*).html(/?)+$ engine/print.php?news_page=$1&newsid=$2 [L] RewriteRule ^([0-9]+)-(.*).html(/?)+$ index.php?newsid=$1 [L] # RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2&day=$3 [L] RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&day=$3&cstart=$4 [L] # RewriteRule ^([0-9]{4})/([0-9]{2})(/?)+$ index.php?year=$1&month=$2 [L] RewriteRule ^([0-9]{4})/([0-9]{2})/page/([0-9]+)(/?)+$ index.php?year=$1&month=$2&cstart=$3 [L] # RewriteRule ^([0-9]{4})(/?)+$ index.php?year=$1 [L] RewriteRule ^([0-9]{4})/page/([0-9]+)(/?)+$ index.php?year=$1&cstart=$2 [L] # RewriteRule ^tags/([^/]*)(/?)+$ index.php?do=tags&tag=$1 [L] RewriteRule ^tags/([^/]*)/page/([0-9]+)(/?)+$ index.php?do=tags&tag=$1&cstart=$2 [L] # RewriteRule ^user/([^/]*)/rss.xml$ engine/rss.php?subaction=allnews&user=$1 [L] RewriteRule ^user/([^/]*)(/?)+$ index.php?subaction=userinfo&user=$1 [L] RewriteRule ^user/([^/]*)/page/([0-9]+)(/?)+$ index.php?subaction=userinfo&user=$1&cstart=$2 [L] RewriteRule ^user/([^/]*)/news(/?)+$ index.php?subaction=allnews&user=$1 [L] RewriteRule ^user/([^/]*)/news/page/([0-9]+)(/?)+$ index.php?subaction=allnews&user=$1&cstart=$2 [L] RewriteRule ^user/([^/]*)/news/rss.xml(/?)+$ engine/rss.php?subaction=allnews&user=$1 [L] # RewriteRule ^lastnews/(/?)+$ index.php?do=lastnews [L] RewriteRule ^lastnews/page/([0-9]+)(/?)+$ index.php?do=lastnews&cstart=$1 [L] # RewriteRule ^catalog/([^/]*)(/?)+$ index.php?catalog=$1 [L] RewriteRule ^catalog/([^/]*)/page/([0-9]+)(/?)+$ index.php?catalog=$1&cstart=$2 [L] # RewriteRule ^newposts(/?)+$ index.php?subaction=newposts [L] RewriteRule ^newposts/page/([0-9]+)(/?)+$ index.php?subaction=newposts&cstart=$1 [L] # RewriteRule ^static/(.*).html(/?)+$ index.php?do=static&page=$1 [L] # RewriteRule ^favorites(/?)+$ index.php?do=favorites [L] RewriteRule ^favorites/page/([0-9]+)(/?)+$ index.php?do=favorites&cstart=$1 [L] RewriteRule ^rules.html$ index.php?do=rules [L] RewriteRule ^statistics.html$ index.php?do=stats [L] RewriteRule ^addnews.html$ index.php?do=addnews [L] RewriteRule ^rss.xml$ engine/rss.php [L] RewriteRule ^sitemap.xml$ uploads/sitemap.xml [L] # SiteMap RewriteRule ^sitemap.html$ index.php?do=sitemap [L] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^.]+)/page/([0-9]+)(/?)+$ index.php?do=cat&category=$1&cstart=$2 [L] RewriteRule ^([^.]+)/?$ index.php?do=cat&category=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^<]+)/rss.xml$ engine/rss.php?do=cat&category=$1 [L] RewriteRule ^page,([0-9]+),([^/]+).html$ index.php?do=static&page=$2&news_page=$1 [L] RewriteRule ^print:([^/]+).html$ engine/print.php?do=static&page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+).html$ index.php?do=static&page=$1 [L] RewriteRule ^search/(.*).html?$ /index.php?do=searchcloud&subaction=search&story=$1&x=$4&y=$5 [L]
My domain is ondb.pk now i want to change my domain to downloads.ondb.pk
the problem is that I have soo many links indexed in google, so when someone comes from google
he will get 404 error
Now I want that if some comes to this link for eg. http://ondb.pk/free-tutorials/
then he will be redirected to http://downloads.ondb.pk/free-tutorials/
hope you understand my point
Can anyone please help me in this
-
hi,
I am trying to convert my SMF v2 forum to IP.BOARD 3.1.2
I am using official converter by IPB,
While converting categories it done by showing that NO ERROR OCCURRED
but After redirecting ti main converter page it say that DONE WITH ERRORS
and when I go to main forum page it dont show any category or board or forum,
But the DEFAULT TEST FORUM, when i go to manage board option
Its shows all categories, in admin panel BUt not showing in Main Forum Page
If anyone gone through this problem then Please Help me...
Best Regards
-
Here the whole code
<?php ini_set("display_errors", "1"); error_reporting(E_ALL); session_start(); session_register("id_session"); session_register("password_session"); include "header.php"; include "customMenu.php"; $id=$_SESSION["id_session"]; $password=$_SESSION["password_session"]; if ($id=="" && $password=="") { ?> <script> var RecaptchaOptions = { theme : 'blackglass' }; </script> <form action=members.php method=post><br /><center> <table> <tr> <td width=25%></td> <td valign="middle"><img src="images/login.png" alt="Log into <? echo $sitename; ?>" /></td> <td><h2>Member's Area</h2></td> </tr> </table> <table width=50%> <tr> <td width=20%></td> <td width=33%>Member's ID</td><td><input type=text name=id></td></tr> <tr> <td></td> <td>Password</td><td><input type=password name=password></td></tr> </table> <table align="center"> <tr> <td align="center"> <?php require_once('recaptchalib.php'); $publickey = "6Le4SboSAAAAAORd5lhQBwJVERfrtinzF5QF48aY"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <FONT face=Arial,Helvetica,Geneva,Sans-serif,sans-serif size=-1><small> Please Enter The Characters you see in the image.</small></FONT> </td> </tr> <tr> <td align="center"> <a href="forgot.php" onclick="doexit=false;"><small><strong>Forgot Your Password?</strong></small></a> </td> </tr> </table> <table width="100%"> <tr> <td width="40%"></td> <td> <div class="buttons"> <button type="submit" class="positive"> <img src="images/textfield_key.png" alt="Login To <? echo $sitename; ?>"/> Login </button> </div> </td> </tr> </table></form> <? } else { if (!$_POST) { middle(); } elseif ($_POST["fname"]!="" && $_POST["add"]!="" && $_POST["city"]!="" && $_POST["state"]!="" && $_POST["country"]!="" && $_POST["pzcode"]!="" && $_POST["pwd"]!="") { if($password==$_POST["pwd"]) { print "<center><div class=\"success\">Your Account has been updated successfully</div></center><br />"; $id=$_SESSION["id_session"]; if (!empty($_POST["file"])) { //Uploading Avatar START if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists("uploads/avatar/" . $id.".png")) { //if used ids.png file already exist then delete it first $path_to_profile_imgs="/public_html/pakmoneymatrix.com/new/uploads/avatar/"; $profile_pic_name = $id.".png"; unlink($path_to_profile_imgs.$profile_pic_name); } //Now Upload file move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/avatar/" . $id .".png"); } } else { echo "<center><div class=\"error\">Your Profile Avatar cant be updated, Please <a href=\"contact.php\">Report us</a> about this problem!</div></center><br />"; } } //Uploading Avatar END $rs = mysql_query("select * from members where ID=$id"); $arr=mysql_fetch_array($rs); $check=0; $check=1; $db_field[1]=$_POST["fname"]; $db_field[2]=$_POST["add"]; $db_field[3]=$_POST["city"]; $db_field[4]=$_POST["state"]; $db_field[5]=$_POST["pzcode"]; $db_field[6]=$_POST["country"]; $db_field[7]=$_POST["changepass"]; if($db_field[7]!="") { $query="update members set Name='$db_field[1]', Address='$db_field[2]', City='$db_field[3]', State='$db_field[4]', Zip='$db_field[5]', Country='$db_field[6]', Password='$db_field[7]' where ID=$id"; } else { $query="update members set Name='$db_field[1]', Address='$db_field[2]', City='$db_field[3]', State='$db_field[4]', Zip='$db_field[5]', Country='$db_field[6]' where ID=$id"; } $rs = mysql_query($query); } else { print "<center><div class=\"error\">Invalid Password ! Account cannot be updated!</div></center></div>"; } middle(); } } ?> <br><br> <? include "footer.php"; function middle() { include "config.php"; $id=$_SESSION["id_session"]; $rs = mysql_query("select * from members where ID=$id"); $arr=mysql_fetch_array($rs); $name=$arr['Name']; $address=$arr['Address']; $city=$arr['City']; $state=$arr['State']; $zip=$arr['Zip']; $country=$arr['Country']; $password=$arr['Password']; $email=$arr['Email']; ?> <?php include 'menu.php'; ?> <form method="post" action="update_pf.php" enctype="multipart/form-data"> <table> <tr> <td width=25%></td> <td valign="middle"><img src="images/Profile.png" alt="Update my <? echo $sitename; ?> Profile!" /></td> <td><h2>Update Profile</h2></td> </tr> </table><br /> <table width="400" border="0" cellspacing="0" cellpadding="0" align="center"> <tr align="left" valign="middle"> <td width="10%"></td> <td width="140"> <?php if (!is_file("uploads/avatar/".$id.".png")) { ?> <img class="roundleft" src="uploads/noavatar.jpg" width="140" height="150" alt="<? echo $name; ?> Profile Pic" /></td> <? } else { ?> <img class="roundleft" src="uploads/avatar/<? echo $id.".png" ?>" width="140" height="150" alt="<? echo $name; ?> Profile Pic" /></td> <? } ?> <td valign="top"><h1 align="center"> <? echo $name; ?>'s<br /><br />Profile </h1></td> </tr> </table> <table width="400" border="0" cellspacing="0" cellpadding="0" align="center"> <tr align="left" valign="middle"> <td width="10%"></td> <td width="44%"><b>FULL NAME*</b></td> <td width="56%" height="40"><b> <input type="text" name="fname" maxlength="40" value="<? echo $name; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%" height="18"><b>EMAIL ADDRESS* </b></td> <td width="56%" height="40" align="left"><b> <? echo $email; ?> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%" height="18"><b>ADDRESS*</b></td> <td width="56%" height="40" align="left"><b> <input type="text" name="add" value="<? echo $address; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%"><b>CITY*</b></td> <td width="56%" height="40" align="left"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input type="text" name="city" maxlength="30" value="<? echo $city; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td height="18" width="44%"><b>STATE*</b></td> <td height="40" width="56%" align="left"><b> <input type="text" name="state" maxlength="30" value="<? echo $state; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td height="18" width="44%"><b>COUNTRY*</b></td> <td height="40" width="56%" align="left"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> <input type="text" name="country" maxlength="30" value="<? echo $country; ?>"> </font></b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%"><b> ZIP CODE*</font></b></td> <td width="56%" height="40" align="left"><b> <input type="text" name="pzcode" maxlength="20" value="<? echo $zip; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%"><b> PROFILE PIC</font></b></td> <td width="56%" height="40" align="left"><b> <input type="file" name="file" id="file" /> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%"><b> CHANGE PASSWORD</b></td> <td width="56%" height="40" align="left"><b> <input type="password" name="changepass" maxlength="20" value="<? echo $password; ?>"> </b></td> </tr> <tr align="left" valign="middle"> <td></td> <td width="44%"><b>CURRENT PASSWORD* </b></td> <td width="56%" height="40" align="left"><b> <input type="password" name="pwd" maxlength="40"> </b></td> </tr> </table> <table width="100%"> <tr> <td width="40%"></td> <td> <div class="buttons"> <button type="submit" class="positive"> <img src="images/validation/update.png" alt="Update My <? echo $sitename; ?> Profile!"/> Update </button> </div> </td> </tr> </table> </form> <? return 1; } ?>
-
Is their any direct way to upload images directly in to uploads/avatar folder
like in above logic we are first uploading images in the temp dir. and then moving it from temp to uploads/avatar
-
yap your code also dont work
-
after adding if (!empty($_POST["file"])) { php debug is not gving error but its also not uploading
its showing 64M in post_max_size
when i am moving folder do i have to write whole path like home/usrname/public_html/.... or simply the path from the root
move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/avatar/" . $id .".png");
-
i try remving unlink function, removing if statement as MrAdam said, After adding debugging I am getting this
Notice: Undefined index: file in /home/usrename/public_html/update_pf.php on line 98
line 98 has this code
if($_POST["file"]!="") {
-
its giving no error
dont know the php version
-
hello,
I need a little help I am working on a script the code below uploads an image file, and rename it to Users Id.png,
It was working fine on my localhost, But when I uploaded it on my Hostgator account but now it doesn't upload images dont know why plzzz help me
if($_POST["file"]!="") { //Uploading Avatar START if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 200000000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { if (file_exists("uploads/avatar/" . $id.".png")) { //if used ids.png file already exist then delete it first $path_to_profile_imgs="/public_html/pakmoneymatrix.com/new/uploads/avatar/"; $profile_pic_name = $id.".png"; unlink($path_to_profile_imgs.$profile_pic_name); //Now Upload file move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/avatar/" . $id .".png"); } } } else { echo "<center><div class=\"error\">Your Profile Avatar cant be updated, Please <a href=\"contact.php\">Report us</a> about this problem!</div></center><br />"; } }
Best Regards!
-
I made this and it working
<a href="index.php?id=<? if($_GET["id"]==null) { echo "0"; } else { echo $_GET["id"]; } ?>">HOME</a>
-
hi,
i want a little help, i am making a site in which i also added a referral system
now I want to create an IF ELSE condition
for eg
<a href="index.php?id=<? echo $_GET["id"]; ?>">HOME</a>
now if some one refers to my page it will get id from QUERY STRING
but I want that if someone not refers him, or he come from googling or direct
then the value of QUERY STRING id will be " 0" ,,, id=0
can anyone tell me how to do this
thankyou best Regards
Shayan
-
Ok I got it,
We just have to restrict the users for their DIRECT REFERRAL DOWNLINE
and the all work would be done in account page to show earning for total no. of direct / indirect referrals,
If anyone want to know then PM me
-
well i also want to tell a point which makes unstable this business
see if you have a 2x4 Forced Matrix system,
what most coders do restrict amount of referrers on first Downline
and dont restrict the total amount of referrals which will be 2x4=8<<-- If they do so system wont get unstable
Thanks for your help But I need help in coding to create logic of restricting total no. of users like in above example of 2x4 I want to restrict them to only 8 users
-
Now thats really a nice joke,
This is not about scamming, If you are good coder then you can code a Stable system if you aren't then people always says thing like these
And you honestly expect us, to help you scamming people?
Well I think I have made a logic, I will have to test it and will then share here. Dont mark topic as solved
[PAID WORK] OpenSocial Integration into UCHome Script
in Archived Job Offerings
Posted
hello,
I want an experienced freelance PHP coder who is familiar to OpenSocial,
I want it to be integrated into UCHome Script, I want whole integration so that
developers can create applications/games for my site and my users will be asked to
allow and disallow apps, a developer platform and full explained docs, with example in wiki script.
Please show me you work and also your bid on this project
Regards,
Shayan