Jump to content

ask9

Members
  • Posts

    51
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ask9's Achievements

Member

Member (2/5)

1

Reputation

  1. @byron2k12 If you want FREEDOM then learn PHP and Framework. If you want to stay in the box then don't learn it. Wordpress for me is for noobs. If you learn PHP & Framework not only you can make website you can also make your own WordPress System and perhaps much more better.
  2. The error is this, PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/coder9/public_html/spider/email.scraper.php on line 98 The codes are these, <?php /* Written by: Aziz S. Hussain Email: [email protected] Website: www.azizsaleh.com Produced under GPL License */ class scraper { // URL that stores first URL to start var $startURL; // List of allowed page extensions var $allowedExtensions = array('.css','.xml','.rss','.ico','.js','.gif','.jpg','.jpeg','.png','.bmp','.wmv' ,'.avi','.mp3','.flash','.swf','.css'); // Which URL to scrape var $useURL; // Start path, for links that are relative var $startPath; // Set start path function setStartPath($path = NULL){ if($path != NULL) { $this->startPath = $path; } else { $temp = explode('/',$this->startURL); $this->startPath = $temp[0].'//'.$temp[2]; } } // Add the start URL function startURL($theURL){ // Set start URL $this->startURL = $theURL; } // Function to get URL contents function getContents($url) { $ch = curl_init(); // initialize curl handle curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($ch, CURLOPT_AUTOREFERER, false); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,7); curl_setopt($ch, CURLOPT_REFERER, 'http://'.$this->useURL); curl_setopt($ch, CURLOPT_URL,$url); // set url to post to curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 50); // times out after 50s curl_setopt($ch, CURLOPT_POST, 0); // set POST method $buffer = curl_exec($ch); // run the whole process curl_close($ch); return $buffer; } // Actually do the URLS function startScraping() { // Get page content $pageContent = $this->getContents($this->startURL); echo 'Scraping URL: '.$this->startURL.PHP_EOL; // Get list of all emails on page preg_match_all('/([\w+\.]*\w+@[\w+\.]*\w+[\w+\-\w+]*\.\w+)/is',$pageContent,$results); // Add the email to the email list array $insertCount=0; foreach($results[1] as $curEmail) { $insert = mysql_query("INSERT INTO 'emaillist' ('emailadd') VALUES ('$curEmail')"); if($insert){$insertCount++;} } echo 'Emails found: '.number_format($insertCount).PHP_EOL; // Mark the page done $insert = mysql_query("INSERT INTO 'finishedurls' ('urlname') VALUES ('".$this->startURL."')"); // Get list of new page URLS is emails were found on previous page preg_match_all('/href="([^"]+)"/Umis',$pageContent,$results); $currentList = $this->cleanListURLs($results[1]); $insertURLCount=0; // Add the list to the array foreach($currentList as $curURL) { $insert = mysql_query("INSERT INTO 'workingurls' ('urlname') VALUES ('$curURL')"); if($insert){$insertURLCount++;} } echo 'URLs found: '.number_format($insertURLCount).PHP_EOL; $getURL = mysql_fetch_assoc(mysql_query("SELECT 'urlname' FROM 'workingurls' ORDER BY ASC LIMIT 1")); $remove = mysql_query("DELETE FROM 'workingurls' WHERE 'urlname'='$getURL[urlname]' LIMIT 1"); // Get the new page ready $this->startURL = $getURL['urlname']; $this->setStartPath(); // If no more pages, return if($this->startURL == NULL){ return;} // Clean vars unset($results,$pageContent); // If more pages, loop again $this->startScraping(); } // Function to clean input URLS function cleanListURLs($linkList) { foreach($linkList as $sub => $url) { // Check if only 1 character - there must exist at least / character if(strlen($url) <= 1){unset($linkList[$sub]);} // Check for any javascript if(eregi('javascript',$url)){unset($linkList[$sub]);} // Check for invalid extensions str_replace($this->allowedExtensions,'',$url,$count); if($count > 0){ unset($linkList[$sub]);} // If URL starts with #, ignore if(substr($url,0,1) == '#'){unset($linkList[$sub]);} // If everything is OK and path is relative, add starting path if(substr($url,0,1) == '/' || substr($url,0,1) == '?' || substr($url,0,1) == '='){ $linkList[$sub] = $this->startPath.$url; } } return $linkList; } function drop_table() { mysql_query("DROP TABLE emaillist;"); mysql_query("DROP TABLE finishedurls;"); mysql_query("DROP TABLE workingurls;"); } function show_emails() { $result = mysql_query("SELECT * FROM emaillist"); while($row = mysql_fetch_array($result)){ echo $row['emailadd']; echo "<br />"; } } } ?> Thanks in advanced.
  3. :'( Still forgetting it. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $data = array(); class Main extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('form'); $this->load->helper('html'); $this->load->helper('url'); $this->load->library('ion_auth'); $this->load->library('session'); $this->load->library('form_validation'); $this->load->database(); //$this->load->model('prod_m'); } function login() { $this->$data['header'] = $this->load->view('header', null, TRUE); $this->load->view('front_page', $this->data); } } /* End of file main.php */ /* Location: ./application/controllers/main.php */ All I just is to make the $data array variable as public and works across all function inside the class. Where did I made wrong? Thanks in advance.
  4. Hi guys, Can you hel p me with 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 ‘1’ at line 1 Controller: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Prod_c extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('form'); $this->load->helper('html'); $this->load->model('prod_m'); } //fetch all product records //display all records to prod_show.php //http://herpescureresearch.org/researchers/prod_c/prod_show/ function prod_show() { $data['rows'] = $this->prod_m->getAll(); $this->load->view('prod_show', $data); } function prod_edit() { //capture url $prod_name = $this->uri->segment(3, 0); $query = $this->prod_m->getProduct($prod_name); //echo '<pre>'; //print_r($query); //echo '</pre>'; $data['prod_name'] = $query['prod_name']; $data['org'] = $query['org']; $data['phase'] = $query['phase']; $data['type'] = $query['type']; $data['description'] = $query['description']; $data['main_url'] = $query['main_url']; $data['donation_url'] = $query['donation_url']; $this->load->view('prod_edit_form',$data); } function prod_edit_update() { //capture all post data if (isset($_POST['butedit'])) { $data['prod_name'] = $_POST['prod_name']; $data['org'] = $_POST['org']; $data['phase'] = $_POST['phase']; $data['type'] = $_POST['type']; $data['description'] = $_POST['description']; $data['main_url'] = $_POST['main_url']; $data['donation_url'] = $_POST['donation_url']; //update database $data['message'] = $this->prod_m->updateProduct($data); //redirect to success page $this->load->view('prod_success', $data); } } function prod_delete() { $prod_name = $this->uri->segment(3, 0); } function prod_success() { } } /* End of file prod_c.php */ /* Location: ./application/controllers/prod_c.php */ Model: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Prod_m extends CI_Model { function getAll() { $this->db->select('prod_name'); $this->db->from('products'); //$this->db->where('id', 1); $q = $this->db->get(); if($q->num_rows() > 0) { foreach ($q->result() as $row) { $data[] = $row; } return $data; } } function getProduct($prod_name){ $this->db->select('prod_name, org, phase, type, description, main_url, donation_url'); $this->db->from('products'); $this->db->where('prod_name', $prod_name); $query = $this->db->get(); if($query->num_rows() > 0) { return $query->row_array(); } } function updateProduct($data) { $prod_name = $data['prod_name']; $this->db->where('prod_name', $prod_name); $query = $this->db->update('products', $data); echo '<pre>'; print_r($data); echo '<pre>'; if (mysql_query($query)) { $message = 'Record successfully updated!'; } else { $message = mysql_error(); } return $message; } } /* End of file prod_m.php */ /* Location: ./application/model/prod_m.php */ The error occur when the method in the model “productUpdate” is called. Why is this exactly? Thanks in advanced
  5. Hi guys I have created these codes below, uploadform.php <html> <head> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data"> <table> <tr> <td><div align="left">Submit photo </div></td> <td><div align="left"> <input type="file" name="file" id="file" /> </div></td> </tr> <tr> <td><div align="left"></div></td> <td><div align="left"> <input type="submit" name="Submit" value="Submit" /> </div></td> </tr> </table> </form> </body> </html> upload.php <?php /************************ * Upload file *************************/ if (isset($_POST['Submit'])) { //if "email" is filled out, send email /*** Upload File ***/ if($_FILES["file"]["size"] < 20000) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { //echo "Upload: " . $_FILES["file"]["name"] . "<br />"; //echo "Type: " . $_FILES["file"]["type"] . "<br />"; //echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; //echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { //$_FILES["file"]["name"] // Do nothing... } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); $url = "http://asiamodeltalent.com/php/mt/" . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } /************************ * Insert path and filename to array *************************/ $fname = $_FILES["file"]["name"]; $files = array("$fname"); /************************ * Send Message to email *************************/ $to = "[email protected]"; $from = "[email protected]"; $subject ="Email File"; $message = "Test email with file attached.\n"; $headers = "From: $from"; // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments $pathupload = "http://coder9.com/php/mt/" . "upload/"; for($x=0;$x<count($files);$x++){ //$file = fopen($files[$x],"rb"); $file = fopen($url[$x], "rb"); //$data = fread($file,filesize($files[$x])); $data = fread($file, filesize($url[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send $ok = @mail($to, $subject, $message, $headers); if ($ok) { echo "<p>mail sent to $to!</p>"; } else { echo "<p>mail could not be sent!</p>"; } } ?> The problem with this codes is the file is attached but it's empty. By the way if you want to test it you need a sub directory of /upload What is the cause of this problem? Thanks in advanced.
  6. Hi guys I installed XAMPP on windows 7. But I have a little problem, on DOS prompt. When I execute c:\php while XAMPP is running it says, "php is not recognized as internal or external command, operable program or batchfile" By the way I already set the path variables into this below and restarted my computer. %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Trend Micro\AMSP;c:\xampp\php\php.exe; Thanks in advanced.
  7. @thorpe Have you tried XAMPP for development? So How do I fix this? Thanks in advanced.
  8. Hi guys This is my first time using XAMPP for development purpose. I created a PHP script that will create a table and I encountered this error message below, Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in C:\xampp\htdocs\mysql_create_table.php on line 3 Access denied for user 'admin'@'localhost' (using password: YES) I already configured the username and password of the MySQL. As you can see under the file of c:\XAMPP\phpMyAdmin\config.inc.php /* Authentication type and info */ $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['user'] = 'admin'; $cfg['Servers'][$i]['password'] = 'asdf1234'; $cfg['Servers'][$i]['extension'] = 'mysql'; $cfg['Servers'][$i]['AllowNoPassword'] = true; What am I missing here? Thanks in advanced.
  9. Hi guys I'm trying to modify the jqGrid jquery plugin. So that it will only display records that is according to the currently logged-in username, an not to display all the records. here is the modified jqGridCrud.php codes, more codes here... switch($postConfig['action']){ case $crudConfig['read']: /* ----====|| ACTION = READ ||====----*/ if($DEBUGMODE == 1){$firephp->info('READ','action');} /*query to count rows*/ $username = $_SESSION['Username']; $sql="select count({$postConfig['id']}) as numRows FROM $crudTableName WHERE '.$postConfig[username].'='$username'"; //$sql='select count('.$postConfig['id'].') as numRows from '.$crudTableName; if($DEBUGMODE == 1){$firephp->info($sql,'query');} $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result,MYSQL_NUM); $count = $row[0]; if($DEBUGMODE == 1){$firephp->info($count,'rows');} $intLimit = $postConfig['limit']; /*set the page count*/ if( $count > 0 && $intLimit > 0) { $total_pages = ceil($count/$intLimit); } else { $total_pages = 1; } if($DEBUGMODE == 1){$firephp->info($total_pages,'total_pages');} $intPage = $postConfig['page']; if ($intPage > $total_pages){$intPage=$total_pages;} $intStart = (($intPage-1) * $intLimit); /*Run the data query*/ $sql = 'select '.implode(',',$crudColumns).' from '.$crudTableName; if($postConfig['search'] == 'true'){ //$sql .= ' WHERE ' . $postConfig['searchField'] . ' ' . fnSearchCondition($_POST['searchOper'], $postConfig['searchStr']); } $sql .= ' WHERE '.$postConfig[username].' = '.$username; $sql .= ' ORDER BY ' . $postConfig['sortColumn'] . ' ' . $postConfig['sortOrder']; $sql .= ' LIMIT '.$intStart.','.$intLimit; //if($postConfig['search'] == true){ $sql .= ' where '.$searchCondition; } if($DEBUGMODE == 1){$firephp->info($sql,'query');} $result = mysql_query( $sql ) or die($firephp->error('Couldn t execute query.'.mysql_error())); /*Create the output object*/ $o->page = $intPage; $o->total = $total_pages; $o->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_NUM)) { /* 1st column needs to be the id, even if it's not named ID */ $o->rows[$i]['id']=$row[0]; /* assign the row contents to a row var. */ $o->rows[$i][$crudConfig['row']]=$row; $i++; } more codes here... But unfortunately I tried many times modifying it, but it seems I can't get the right formula. You can find the original and complete template plugin here, http://suddendevelopment.com/?p=38 Thanks in advanced.
  10. I fixed the problem with this codes below, $sql="select count({$postConfig['id']}) as numRows FROM $crudTableName WHERE username='$username'";
  11. @Pikachu2000 thanks, I copied your codes, and this is the new error below, 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 ''orgs' WHERE username='solid9'' at line 1
  12. hi guys I know this is very basic. But this codes below has something wrong, $sql="select count('.$postConfig['id'].') as numRows from '$crudTableName' WHERE username='$username'"; Thanks in advanced.
  13. Hi guys I have this strange problem. When I change the html or jquery codes and upload them to my website. And refresh the page the new changes don't show up, why is this? Also this happens to all my internet browsers like FireFox4, Chrome, MSEI9 and Safari. And this only happen to my computer, I tested it into another computer and the changes show up. By the way I'm using Windows Vista (Licensed) and TrendMicro Titanium (Licensed). I have a strong feeling that this problem, Is related to my computer cache? am I right? or a Virus? How do I fix this? I hope someone will help me to fix this problem. Thanks in advanced.
  14. ask9

    jqGrid ?

    Hi guys I'm trying to display the navigator with add, edit and delete, below are the codes, http://www.herpescureresearch.org/meter/jgrid/mygrid3.txt and below is the .htm http://www.herpescureresearch.org/meter/jgrid/mygrid3.htm What the hell I'm missing here?, because it's not showing anything? Thanks in advanced.
  15. Hi guys Has anyone tried flexigrid here? My first attempt failed. Anyone would like to share on how to implement it properly? Thanks in advanced.
×
×
  • 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.