veedeoo 474 Junior Poster Featured Poster

HI,

You should HTML DOM Parser.. search on it on google..and you can parse the target page as simple as

echo file_get_html($myurl)->plaintext; 

Of course, you can do a more advance filtering. It all depends on what items you want to scrape.

veedeoo 474 Junior Poster Featured Poster

Hi,

You can try creating another column on your members table, you can name it anything e.g. notified..

Just right after your script send the email, update this column by inserting some indicator e.g true or false

You can then modify your query above to something like this...

select email from myusers WHERE notified = 'false' AND DATE_ADD(FROM_UNIXTIME(prelogin), INTERVAL 30 DAY) < CURDATE()";
## do your update query below
update myusers WHERE .....set notified value to true, for all affected rows above...
veedeoo 474 Junior Poster Featured Poster

Thanks for sharing.....

and you can also expand the above codes to make a cache file of the index.php above.

Using the same concept, we can make a cache of the index.php above . Create a new directory called cache. make sure this is writtable for the script.

Say, we have a page called entry.php page. add this code in the middle where you want the index.php to appear.

<?php

## you must define how many seconds you want the cache to last..
$cachetime = 10080 * 60; 
$cachefile = "cache/index.html";

if(file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile)))  {


   ## the page has been cached from an earlier request

   ## output the contents of the cache file

    include($cachefile); 

    }
    else{
      ## this will create cache html page of the index.php
    ob_start(); 

    include ('index.php');

    $cachefile = "cache/index.html";

  ## open the cache file "cache/index.html" for writing
   $fp = fopen($cachefile, 'w');

  ##save the contents of output buffer to the file

  fwrite($fp, ob_get_contents());
  ## close the file

   fclose($fp);

  ## Send the output to the browser
  ob_end_flush();

?>

That will create a templating system cache like function of the index.php , which is proven to speed up the page load. Ideal if the content does not change a lot..

Coool :)

veedeoo 474 Junior Poster Featured Poster

@lwaterfo

Here is the deal, you can unconditionally buy us a cup of starbucks coffee, a gallon will be greatly appreciated..:). I want mine colombian with brown sugar, and no creamer.

  1. Download this script Here.
  2. Unzipped the downloaded zip file.
  3. In the unzipped file, find membersite_config.php and load this file to your editor.

On membersite_config.php, you will find the following codes.

<?PHP
 require_once("./include/fg_membersite.php");

 $fgmembersite = new FGMembersite();

 //Provide your site name here
 $fgmembersite->SetWebsiteName('user11.com');

 //Provide the email address where you want to get notifications
 $fgmembersite->SetAdminEmail('user11@user11.com');

 //Provide your database login details here:
 //hostname, user name, password, database name and table name
 //note that the script will create the table (for example, fgusers in this case)
 //by itself on submitting register.php for the first time
 $fgmembersite->InitDB(/*hostname*/'localhost',
                  /*username*/'root',
                  /*password*/'',
                  /*database name*/'testlogin',
                  /*table name*/'member');

 //For better security. Get a random string from this link: http://tinyurl.com/randstr
 // and put it here
 $fgmembersite->SetRandomKey('qSRcVS6DrTzrPvr');

 ?>
  1. Let's set aside this file loaded in your editor. Direct your browser to your cpanel and login to your account. In the cpanel area, click on mysql database wizard and create a database called testlogin or whatever name you want. Create a user for this database giving it all the priviledges. If you will be running this on your localhost.. create a database testlogin if it does not exist. Otherwise, name it with something else.
  2. After creating the database, edit this part of the script above. DO nOT change the member. This script will automatically create …
veedeoo 474 Junior Poster Featured Poster

Hi,

Can you double check what is the column name on your database? This should be called id.. remember this is a case sensitive.. make sure the id in your query matched the actual mysql database column name for the id..

veedeoo 474 Junior Poster Featured Poster

Hi,

What you can do is to create a dummy check out button that will make them login, when they successfully logged in, then show them the paypal pay button or other payment button.

However, this may be make other shoppers to feel of being forced to register and logged in, so there should be an option for you to send this type of shoppers where they don't want to be bothered logging in or registering.

thats simple.. I know all these, because I once helped my older brother in developing extension modules for oscommerce and zen cart long time ago.. oscommerce and paypal sandbox was my training ground for php programming, and then one famous video site hired me as a non-contract developer, because I was a minor.

In fact, I think some people are still using the one and only contribution I have.. folding left category menu :). That was pretty weak, but I managed to contribute something at a very young age.. I don't even remember the name of the plugin anymore.. I need to look it up.. ;) that was long long time ago..

veedeoo 474 Junior Poster Featured Poster

Hi,

Session will work on this type, I mean even in a much more complicated applications. Session can even handle an array, and it will save the data in it , until it is unset -> removes the item in the session but not the session itself, OR session destroy-> which eventually destroy everything including the session.

Script below is something I wrote for testing. I used this for capturing a dynamic playlist and viewed videos history.. pretty much similar to what you see on youtube. I wrote this script to allow users to go back to items they already watched.

I tweaked it a little bit. I removed some of the items that will not make sense if included in this discussion. I also rewrite it for your needs. The only thing I did not do is to create two pages, and I used POST instead of GET.

This script is easy to modify. Again, data submitted through this form are not sanitized. It will be your responsibility to test it and mocked this script to your application.

The script is pretty much commented already, up to the point that I felt myself as being extremely becoming redundant.

Here is the code.. this will be the final codes I'll be writing for today. My wrists are feeling pretty bad now.

Save this as test.php, load the file on your server, and direct your favorite browser to it.

<?php
## first we create a session
session_start();

## second we create …
veedeoo 474 Junior Poster Featured Poster

Hi,

I think you need to focus more on validating which submit buttons were click. You have two of them. If I click one only, then on POST, you will get the undefined index error on the other.

Why not try validating your form submission based on the submit button clicks. for example

  if((isset($_POST['save1'])) || (isset($_POST['save']))){

   ## check here which one is not empty, and then prepare it for the database inclusion or posting.


  }

Please forgive my vigorous use of parenthesis. I can't just help it and it is becoming more of a second nature to me overtime, it is probably because of my mathematics background and calculator projects I have been working on and in the past. In mathematics, extra care is needed in isolating integers and variables, so that the program will calculate based on the PEMDAS convention. Otherwise, the calculated output is inaccurate, and others will not be able to replicate it.

veedeoo 474 Junior Poster Featured Poster

Just in case people want to do the same, which I don't really recommend. However, there are some cases where the content of the site requires mobile users to be redirected to the mobile version of the mainsite. Here is the code for it.

<?php

## borrowed these codes from someone, but forgot his site url

$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i',substr($useragent,0,4)))

## Redirect URL
header('Location: mobileVersion.xml');

?>

If you don't want an auto redirection, then just modify this part of the code

  ## mobile content redirect url
header('Location: mobileVersion.xml');

To something else like link to the mobile version of the site. Something like this

 $showMobileLink = true;

Then somewhere in the header section of the stie if so equiped, I would do like this.

 if($showMobileLink){
  $mobilelink = '<a href="mobileVersion.xml")>Mobile Version</a>';

 }
 else{
 ## you can remove this or just keep it this way
  $mobilelink = '';
 }

Just call it anywhere you want the link to show up.

  echo $mobilelink;

That's it.. the good thing about my recommendation is you don't have to spend a single penny. You can always use .html for the file. I use xml, because that was the one I used on my previous project, but apple turn it down, because my plugin was not sutiable for general audience.. I wrote an iphone apps to spice up the mobile surfers, but …

HayLift commented: Thank you. +0
veedeoo 474 Junior Poster Featured Poster

This is just my personal opinion. I think it is a bad practice and convention to forcefully redirect your mobile users to the minimum version of the site. Most iphones are able to take on the regular site. What would I do if I am in your shoes, I would just definitely detect the mobile phones , and then show the link for the mobile version of my site. This way you don't have to worry about auto redirect.

Detecting mobile browser is not that hard, so if they present just show them the link somewhere near the header.

veedeoo 474 Junior Poster Featured Poster

ok, here is the second part. All you need to do is put back the css styling on your html codes. This should work..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!-- put back your css styling here -->

<title>pagination
</title>
</head>
<body>
<div id="container" class="round10">

<?php 
include_once 'includes/header.php'; 
include_once 'includes/sidebar.php';
?>

<div id="content" class="left round10">

<h1><img src="images/images.jpg" width="30" height="30" /> &nbsp; Student List</h1>

<div class="box box-info">Please click the name of the Students if you want to send them a message</div>
<div align="right">
<a href="search.php">
<u>Search Student?</u>
</a>
</div>

<?php
/*
Place code to connect to your DB here.
*/
include('config2.php'); // include your code to connect to DB.
## include pagination script 

include ('pagination.php');

$tbl_name="account_student"; //your table name

## count rows from database for pagination.
$query = "SELECT COUNT(*) as num FROM $tbl_name";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages['num'];

## pagination settings
$adjacents = 5;
$limit = 5; //how many items to show per page
$targetpage = "view_student_account.php"; //your file name (the name of this file)


if(isset($_GET['page'])){
    $page = $_GET['page'];
    $start = ($page - 1) * $limit; //first item to display on this page


    }
else{
    $start = 0; //if no page var is given, set start to 0
    $page = 1;
}

## initialize pagination
$pagination = vpagination($total_pages);

$sql = "SELECT id, fullname, course, year, section, year FROM $tbl_name LIMIT $start, $limit";
$result = mysql_query($sql);

## do not put strain on your server by echoing html tags. Just close the …
veedeoo 474 Junior Poster Featured Poster

Hi,

Please don't call me sir. I just barely turned 19 years old. :) . On the other hand, I always think I am already old, but my parents said not yet. "You are just barely getting in there young man".

Thanks a lot though, I really appreciate it, must be a sign of respect. We don't get that much here in the States. We call each other Dude, or something really geeky in that regards..

Ok, back to your problem, I will do this in two parts.

First, I tried to work on you pagination script, but I think it is missing some features I would like to see in pagination script. I modified some pagination scripts that I stumbled upon on the Internet. I really don't know who was the original author. I think it was 4 to 5 years ago. Overtime, I was experimenting on how to improve this script. However, I think it already maximized its potential that it is now pretty old for me to use in my applications. However, this script has been helpfull to me years back.. It just need 1 variable and 5 globals.

Here we go...copy codes below, save as **pagination.php
**

<?php
function vpagination($numrows){
global $page,$start,$limit,$adjacents,$targetpage;

## edit based on the global assigned above ##
$rowsperpage = $limit; 
$range = $adjacents;


## do not edit beyond this line ----------------------##
$page_v = "";
## calculate total pages
$totalpages = ceil($numrows / $rowsperpage);
## get current page or set a default …
veedeoo 474 Junior Poster Featured Poster

Here is the demo of your array, using my recommended fix above.

veedeoo 474 Junior Poster Featured Poster

Hi,

Where do want to put the last else? Your conditions are set like this

if(){

## this is your first if

}

else{

## this is else for the if above..

## you have all the ifs here for error checking
## below is your last if within this else

if(){


} ## end of if followed by your database query

#your query here

} ## end of else statement

## then you set another else statement on line 383

else{

}

## then you have your extra curly bracket below

} // line 389

You have little over one curly bracket on line 389. Now let us go back to my question. Where do want the last else to be included? You want it within the first else,? following the last if?

If so, then remove the entire else..

  else
   {
   echo "<script type=\"text/javascript\">;
   alert(\"You don't belong here!\");
   window.location=\"index.htm\"</script>";
    }

and put it just below line 376 and above your database query.

remove the last curly bracket on line 389.

test your script..

veedeoo 474 Junior Poster Featured Poster

Hold on, let me run a test on my editor..

veedeoo 474 Junior Poster Featured Poster

try doing the arrays like this

 $data = array(
 array('', 1800,   5), array('', 1810,   7), array('', 1820,  10)

 );

Brief explanation on how the arrays related to plotting..

for example the above array represents the following 1800 is the x-axis 5 is the y-axis values, followed by the next dot or line continuation of the 1800 x-axis and the y-axis which 1820 and 10.

so by looking at your codes above you must add '' if it is a line graph, If it is a bar graph.. you can do like this

$data = array(
 array('x-axis value 1', 1),    array('x-axis value 2', 2),    array('x-axis value 3', 3)

 )

Again the second array above, demonstrate the proper convention of php plot.. x-axis, y-axis value. AND every thing in the array should be in ascending order.. like

(x = 1, y = 1), (x = 2, y =2),,, and so forth..

Before modifying your codes above, try this first by changing your codes below..

 $graph->SetDataValues($example_data);
 $graph->DrawGraph();

to this

 $graph->SetDataValues($example_data);
 $plot->SetDataType('text-data');
 $graph->DrawGraph();

try it, that should work.. here is the demo. of the same plot class using the same convention I described above..

veedeoo 474 Junior Poster Featured Poster

try doing a var_dump.. that should give you something in return. Actually, I created a demo of this type of script as shown Click Here.

What I did was disassembled the class, because it is creating so much trouble. I don't think it is worth the hassle. So, class have to go.

veedeoo 474 Junior Poster Featured Poster

Hi,

This is just a suggestion. Why not remove your pagination script first. Go back to where your script works. Then create a pagination class. If you are not comfortable with writing a class just write it in the simplest form.. like this

  ## filename: pagination.class.php ##

  class PageIt(){

  ## we don't have to define any var here, because this is just a simple class to get you going.

  ## create the pagination function

  function doPagination($total_pages){
  ## since that this is a simple class at the very minimum, we can set our globals below. Otherwise these items must be difine as var above.
  global $tbl_name, $start, $limit;

  ## put your pagination script below,WITHOUT the database query in it. I mean both of them must not be included here. Explanation will be provided below.



  ## this will return the .pagination

  return $pagination;
  }


  }
  ## end of this tiny and simple class

Like what I have already commented inside our little tiny class above, we need to remove and send query to your database here..

   include 'pagination.class.php';
  ## top section of your script here before the while loop.


  ## first do a count query Remember! $tbl_name is global, and has to be define above this section of the script.

   $query = "SELECT COUNT(*) as num FROM $tbl_name";
   $total_pages = mysql_fetch_array(mysql_query($query));
   $total_pages = $total_pages[num];

   ## we instantiate our simple pagination class.
   $page_it = new PageIt;
   $paginate = $page_it->($total_pages);

   ## now our pagination above is ready.. we do the second …
veedeoo 474 Junior Poster Featured Poster

Do you mind if I ask you this.. who originally wrote the php.php was it Valums? or was it part of axiom ? Without retracing the original working codes, it will be pretty difficult for us to analyze and find the actual part of the script that is not working after your modifications. The way I see it , this script is intended to work as ajax uploader without a viewable form (it has, but it should be picking up the uploads inside a division .. I hope I am wrong.

If it was written by valum, then the upload button should be showing on the page onLoad, right below the division ->file_uploader_demo1, and this is the same division that will pick up the upload. I am not sure, but that's how the script is laid out..

veedeoo 474 Junior Poster Featured Poster

I know most of us were pretty much have the same beliefs about PHP being the templating system itself, as what Fabien Fotencier (The father and The mother of Symfony) wrote on his blog. Before the birth of twig, he pretty much have the same reasoning as the majority in PHP coders world. However, he did changed his mind as what he had written here.

Although he pointed out the lack of functionalities of the old smarty and the smarty3, he also aknowledged the importance of smarty .

Smarty is the de-facto PHP standard template engine

I still believe however that smarty may still have some few more tricks left underneath its sleeve. A good example of this is the smarty's iteration functions. Only DWOO and Smarty have this and no other template engine would be able to do it on a template side, except when the switch method is passed from php.

The usefulness of smarty iteration property become extremely important, when a coder wants to insert something in between loops, or in any specific nth part of the iteration. For example, we have 100 items stored in some variable as data. If we want to paginate allowing 20 items per page, but at the same time we want banner ad or different item (not from the same variable where the 100 items where stored) every 4th item, this can be easily done on smarty. Although php alone can do this (NOT as precise as …

veedeoo 474 Junior Poster Featured Poster

Hi Pritaes,

I think that would require a little bit of work... people were talking about it, why it has to be cache key instead of a name? This person got some tweaks, but encounter some minor problems.

Twig should work on this limitation. I hope it will be pretty soon.

Meanwhile, the file responsible for writing and loading the cache/template file is the Twig/environment.php. They have an updated and modified version of this file at gitHub. The most updated distribution with fixes is Here.

Moments ago, I ran a simple script with cache enabled, the cache sub-directories and files were arranged this way.

cache
->templates
--->of->f1->the actual child template cached file.
--->16->5d->the actual master template cached file.

Template nesting and inheritance in twig is exactly the same as in Smarty, with one exemptions on the grandchild's ability to pick up some of the grandparent's (master template) defined block characteristics.. for example, the master template can have the following blocks. The same thing in smarty master template, all css, js and valid html tags must be included here.

For other people who just stumbled upon this discussion, this is the file where all of the styling and beautification must be focused. Designer can have all of freedom to work on this file. There is nothing to break here really. They can delete or missed-up on the curly and percent symbols all day long, our php script will remain safe in the …

pritaeas commented: Much appreciated. +13
veedeoo 474 Junior Poster Featured Poster

Twig's cache is almost the same as smarty..with the only exemptions of twig is doing it much better, because the cache directory is created automatically, and it can detect any changes made on the template files.

Normally, without cache we can initialize twig environment like this

 ## initialize twig environment without cache
 $twig = new Twig_Environment($loader);

To enabled cache, we can just replace the initialization above with

   ## twig environment initialization cache enabled
   $twig = new Twig_Environment($loader, array(
   'cache'       => 'cache/templates',
   'auto_reload' => true
  ));

The cache page of the tpl file will be located the root of the script if cache/templates does not exist.. twig will create them automatically.

Now the beauty of twig is its ability to detect any changes in the template file.. if changes were made after the cache file has been recompiled, the twig will use the auto reload function.

In my example code above, I made auto_reload equal to true. So, pretty much it will be a self serving, whenever it detects changes on template file.

The one I like the most about twig is its ability to do a data dump. In smarty, people normally do this

   while(SomeRowsFromDatabase){
   $value['one'] = $row['one'];
   ## sometime it should have to be like this (string)$row['one'];
   $value['endOfItems'] = $row['lastRow'];

   $valueOut[] = $value;

   }
   $smarty->assign('valueOut', $valueOut);

While in twig it is a lot shorter and faster I think...

 ## twig approach
 while(SomeRowsFromDatabase){
   $valueOut[] = $row; 

   }

   ## send the above data to …
veedeoo 474 Junior Poster Featured Poster

Correction,. not auto increment.. and the first query should be corrected once again to add the id. The same id as in the old table and the archive. Without out this we won't be able to request any result

$result= mysql_query("INSERT INTO archieve (id,username, password, fullname, course, year) SELECT id, username, password, fullname, course, year FROM account_student WHERE id='".$id."'")

The query above should post the item in the archive table with the same id value as in $id..

Sorry about that... I must be pretty tired already or just having a weekend fever.. I will look at this again tomorrow... I out of here...

veedeoo 474 Junior Poster Featured Poster

Please observe the $result2 .. I just updated the codes above... I don't want the two results colliding each other...

veedeoo 474 Junior Poster Featured Poster

The problem in the mysql_fetch_array(), I just realize that when you insert something from another table to a new one, once the query is execueted.. it is done.., and we won't be able to pick up the result..

Before goin on further, on your achive table, is the id set as auto increment??? Make sure that it is set to autoincrement otherwise, the archive table will not have an id value.

To check if the insert to the archive table has been executed. Using the php admin take a look at the archive table.. I am pretty sure , even with the error above.. the script managed to insert..

to fix the error above, we need to create a query specific only to the inserted values on the archive table.. However, if the ID on the archive is not set to auto increment the query below will bring another error. So, please double check..

Here is the new query for the newly posted data on the archive. This will serve as a confirmation on what was posted by the first query.

     $result2 = mysql_query("SELECT * FROM archieve WHERE id='".$id."'")
      or die (mysql_error());          
      while ($row = mysql_fetch_array($result2))

     {
     echo '<td><center><a href="write_message.php?id=1">' . $row['fullname'] . '</a></center></td>';
     echo '<td><center>' . $row['username'] . '</center></td>';
     echo '<td><center>' . $row['password'] . '</center></td>';
     echo '<td><center>' . $row['fullname'] . '</center></td>';
     echo '<td><center>' . $row['course'] . '</center></td>';
     echo '<td><center>' . $row['year'] . '</center></td>';
     }

Before running the updated script above make sure to delete the entry on …

veedeoo 474 Junior Poster Featured Poster

HI,

You need to remove the * from your select. Try using this

   $result=mysql_query("INSERT INTO archieve (username, password, fullname, course, year) SELECT  username, password, fullname, course, year FROM original_table WHERE id='$id'")

Don't get too agressive on your DELETE query.. YOu need to make sure that data has already been posted on your achive table.

Put the delete query somewhere else, not on the very top..

veedeoo 474 Junior Poster Featured Poster

hi, take a look at this.

veedeoo 474 Junior Poster Featured Poster

Here is the modified version of script TWO. This will only work on live server or XAMPP portable or full install. Again it all depends on your Internet connection speed. Live servers connections are extremely fast, that is why it is able to pull the entire html page of the target url.

<?php
## include the dom.php
include 'dom.php';
## define your target url
$url = 'http://books.rediff.com/categories/fiction-genres/2180204';

## your function as derived from your posted question on daniwed
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
## end of your function




    $outhtml = get_url_contents($url);
    $html= str_get_html($outhtml); 


foreach($html->find('a')as $link){

    //echo $link;
    foreach($link->find('img')as $value){
     ## filter extension.. we know books thumbnails are more likely to be jpg
     $ext = substr(strrchr($value->src, '.'), 1);

     ## we don't want gif images, we only want the book thumbnails.
     if($ext != 'gif'){
     echo '<img src="'.$value->src.'"/><br/>';
        echo html_entity_decode($value->title)."<br/>";

        }
        //echo $ext."<br/>";

    }
}



//print_r($outhtml);

?>

If I get extra time later on, or my lazyness to get back on my project does not subside, I will modify this script to be able to send search query to rediff.com . That's pretty easy than the project I am currently working on right now.

veedeoo 474 Junior Poster Featured Poster

Hi,

I just uploaded the above scripts on my server and it is working fine.

Script TWO, I modified it a little to eliminate the gif image from being picked up by the script.
Script TWO

Script ONE, this si the generalized parsed version, where you see lots of artifacts in it. I prefer the version two of the script.
Script One

The inability of your localhost to execute cURL might have been due to your settings. Make sure the server can access the internet to get the $url.

veedeoo 474 Junior Poster Featured Poster

Hi,

change this

 $html= str_get_html($outhtml); 

With this...

 $html = file_get_html($url);

The output should give you something.. YOu just need to use the regex that Pritaes have given you to sort out the jpg from gif, to eliminate the shopping cart images and the search..

Let me know... what is the outcome though...

veedeoo 474 Junior Poster Featured Poster

I wish I could help, but Biim already got it under control, and doing a hell of an excellent job .. :) At the least, I managed to provide my humble contribution of a short definition of vegetables and fruits... :)

You can also put your important values in session as an array.. for example,

  $_SESSION['important'] = array($data1, $datat2, $data3,$data4, $moreHereIfyouWant);

Then you can easily access session items from the array by

   $_SESSION['important'][0]; // for data1
   $_SESSION['important'][1]; // for data2
   ## add as many as you want.

Not much of a contribution from me, but I hope it can be considered..

Honestly, it is looking pretty good guys...

veedeoo 474 Junior Poster Featured Poster

These are the reasons why I LOVE PHP over anything else.. I mean I also like active server language, but I think PHP is more extendsible. PHP can also be a very powerful coding language , if either one or all are used.. framework, templating system, OOP..

The same thing with ASP, php just need a descent templating system.. like what Pritaeas have recommended. I prefer smarty or twig, but dwoo is something I can fall back into.

In smarty you can make one master template, and then just extends it for every pages you want to create.. Besides, it will never complicates with the script updates, because each page has its own php file, you are just assigning them to your template file..

Please allow me write an example. Just because I am getting bored on my current google/youtube API work they want me to overhaul.

I prefer using some of my precious time in promoting and convincing other people why PHP is a good programming language if not excellent? In PHP you can also have a master template .

In my example let us call this main.tpl all of the major css and design aspects of your site must be included here...

          <!-- filename main.tpl -->
          <html>
          <head>
          <title>[block name=title][/block]</title>
          <meta name="keywords" content="[block name=meta][/block]"/>
          </head>
          <body>
          <div id="mainwrap">
          <div id="leftcol">
          <!-- you can assign your left column content here, by creating a left column block -->
          [block name=leftcontent][/block]
          </div>
          <div id="maincontent">
          <!-- you can assign your maincontent …
pritaeas commented: Nice. +13
veedeoo 474 Junior Poster Featured Poster

Hi,

did you try adding ???

  parent::executeIndex($request);

just below

 public function executeIndex(sfWebRequest $request)
 {

Not sure though, I only used this framework for less a month... So, my memory was not able serialized whatever I did on my practice applications.

veedeoo 474 Junior Poster Featured Poster

Hi,

add this just above $result

 $band = $_POST['band'];
veedeoo 474 Junior Poster Featured Poster

Hi,

Try changing this

 $query = "SELECT * FROM interviews WHERE vacancyid = $applyid'";

To

 $query = "SELECT * FROM interviews WHERE vacancyid = '$applyid'";

Double check your queries above and do the same..

You can also change your code to this...

 if($row["vacancyid"] == $applyid)
 {
  ## show your form here
  }
  else{
  echo "no interviews are be held";

  }

It is a lot easier for your script to evaluate the $applyid equal to vacancyid, because applyid is your parameter in your query. It could have been an easy query, but since you need to echo the form with values from the same query, we don't have a choice but loop over.

veedeoo 474 Junior Poster Featured Poster

Hi,

I don't know if this will help, but I will post it here anyway for whatever it's worth take it.. I could have written this much better, but I am pretty busy right now to experiment with a much better approach.

Step One: Save this file as dom.php

Step Two: Copy , save codes below and upload to your server

<?php
include 'dom.php';

## your function as derived from your posted question on daniweb
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
## end of your function




$url = 'http://books.rediff.com/categories/fiction-genres/2180204';
$outhtml = get_url_contents($url);
$html= str_get_html($outhtml); 

foreach($html->find('table',9)as $item) {

 ## this is general and pretty broad output
    echo $item;

    }


//print_r($outhtml);

?>

The above script should give a pretty broad result.. Meaning, shopping cart buttons, and other stuffs on the page maybe present as artifacts. It might even have an array array artifacts.. but those can be easily fix later on.

Step Three: Actually, this is NO STEP at all, but rather a modified approach of the above. Since the above is pretty general in the sense of parsing the remoter page, this one will target the 'a' tag..of the page. This will be able to parse the title , thumbnail, alt. I am really hoping it would... :)

<?php
## include the dom.php
include 'dom.php';
## define your target url
$url = 'http://books.rediff.com/categories/fiction-genres/2180204';

## …
veedeoo 474 Junior Poster Featured Poster

Hi,

What are you trying accomplished? Parse the books with their, description, thumbnails.?.

veedeoo 474 Junior Poster Featured Poster

@Muralikalpana,

Just to clear some of my doubts, can you run this script on your wamp server

 <?php
 var_dump(curl_version());
 ?>

Did you see anything on the screen?

NO? Run

 <? phpinfo(); ?>

Look for your server loaded configuration file .. e.g. apache/bin/php.ini OR php/php.ini.. based on the loaded configuration file, find the php.ini file, load the php.ini file on your editor and then find

   ;extension=php_curl.dll

Change it to

   extension=php_curl.dll

Go to your wampp/php/ extension directory and double check if the php_curl.dll is present... if not, go and check the wampp website on how to enabled and add extension on their distros..

I am not sure if you can trim cURL output.. coming from the exec handler... I need to read about that..The output is already known by your server to be an array. So adding (array) might be an overkill..

veedeoo 474 Junior Poster Featured Poster

Hi,

Try removing the extra equal operator in your query..

$result2 = MYSQL_QUERY("select title, content, tag, date from article where author == ." .$_SESSION['id']. ".");

like this

 $result2 = MYSQL_QUERY("select title, content, tag, date from article where author = '" .$_SESSION['id']."'");
veedeoo 474 Junior Poster Featured Poster

Your problem is this..

 $fileContents = file_get_contents($file);
 $sql ="insert into invoice(filelocation) values('$fileContents')";

file get_contents is for parsing text, html and coverting it to string. I really don't understand the reasons of using it, unless you want to collect webpages, text and store all of the parse contents in database. I thought all you need is the filename to be inserted in your database..

veedeoo 474 Junior Poster Featured Poster

ok, thanks for posting your codes.. now I need to see how your database table are structured. This will be the target database for your search query. I am expecting something like this..

Datatbase Name: Automobile
tables:
vehicle =>columns : id --- name -- title -- year -- model -- poster --- date posted -- etc..etc.

If you another table/s to list just list it here..

veedeoo 474 Junior Poster Featured Poster

Hi,

This is how I visualize it for me to understand it fully well. They said it is MVC, but for me personally it is CMV or Controller Model View.

One might ask why?

Because it is easy to remember these in order INPUT->PROCESSOR ->OUTPUT or CMV. In practice, I would create the MODEL first followed by the controller and then the view..

Or, in the most simplest term I can think of right now. It is the distribution of labor among 3 different script group devided into pages. One is responsible in connecting to the database and gathering user input, the second is responsible for processing collected data, and the third one is showing the preprocessor data collection and post processor data presentation ( this is the view)..

veedeoo 474 Junior Poster Featured Poster

What is the error message you are getting? Another possible problem is the db class. Are you using a database connection class? If so, what is the name of the class? Look for something like this..

class Something{

// more stuffs here
function someFunction(){

}
}

In my example above, the name of the class is Something, In your case it can be any name, look on your headerloggedin.php file and find ** $db = new Something();** Something is the name of your database connection class.

Make sure the class responsible for connecting, fetching, updating, inserting to your database in included and instantiated..

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you load the actual file of this script on your editor and tell us what is on line 51?

veedeoo 474 Junior Poster Featured Poster

Hi,

Just for the sake of curiousity, why they don't want cookie? You can make cookie's lifetime until the session is unset. Before jumping into this project, make sure you have the general understanding in vulnerabilities of both and not having either one. Please read more about session fixiation, and how to implement session and cookie at the same time. You can read more about security here

Going back to the log in script, there are many of them out there, but I always recommend something that is still a barebone.. Why? Because, you want to see all the codes and able to view, analyze to make sure there is nothing malicious script inserted to steal some of your user's important data. Sometimes starter script is all we need to get going.

Copying and pasting is good at times, but only if you are just using it to use existing functions rather than writing it yourself.

Here is a very simple login script , you can start with this script and you build on it. I strongly suggests to use smarty templating system for this. This will add a little protection too.

I was thinking of recommending Ignitier or Cake, but the learning process is pretty lengthy.

I will attempt to help you with the smarty templating conversion of your final script, BUT not until I am finished with my project. I was asked to write video class script for google/Youtube API based on the latest …

veedeoo 474 Junior Poster Featured Poster

try using single qoute for the double quotes and double quoutes for the single quotes. Otherwise, yo can escape it. Another alternative is to use heredoc for a longer string., but for your situation something like this will do..
<?php
echo '"';
echo "' '";
?>

veedeoo 474 Junior Poster Featured Poster

can you check if rewrite_mod is enabled on your server? Inside your directory yourSite.com/mvc there should be an .htaccess file that came with the phpcake files.. the codes on it look something like this. Actually there are two of them.. one is located in the app/directory.

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteRule    ^$ app/webroot/    [L]
 RewriteRule    (.*) app/webroot/$1 [L]
 </IfModule>

If your root directory have a pre-existing .htaccess, try experimenting by adding the same entries you found on the .htaccess in mvc/app/ directory.

Be carefull when uploading and editing .htaccess file. There are times this file can get corrupted, even if you set the FTP program file transfer type to auto.. Some server are pretty delicate on this settings. Sometimes, setting it to binary works.. However, .htaccess file is more of an ASCII file rather than binary, but it works for me all the time using the setting as binary, because I have lots of php files with the extensions such as .inc .module. So, setting it to auto makes the ftp program go flip/flopping between binary and ASCII and this behaviour is enough to corrupt the php files with different file extensions,

veedeoo 474 Junior Poster Featured Poster

what happened if you access yoursite.com/mvc/users/ ? Does it give you an error message about app/Controller/UsersController.php?

veedeoo 474 Junior Poster Featured Poster

You can scale the image based on the proportional ratio of your maximum width and the actual height. However, if we properly scale 452x507 to your maximum dimension. The properly scaled output will only be around 54.21px by 60.84 px.

Here are the reasons why?

To scale we need to check if the actual image is a wide image or tall image. To find out if the image is either one, we need to put the actual image dimension into simple calculation.

let x = width, and y = height.

Image is wide if(x > y), and image is tall if(y > x).

If the image is tall, then we can properly scale the image by calculating the slope or in this case the quotient of the maximum height vs. the actual height of the image. Therefore, in our case the quotient can be presented by this simple formula.

let max_y = 61px, and max_x = 235px

calculate quotient => mq = (max_y) / (y) => (61px)/ (507px) = 0.12

calculate the scaled width => final width => x * mq => 452px * 0.120 = 54.24px for the output width

calculate the scaled height => final height-> y * mq => 507px * 0.120 = 60.84 px or round it 60px.

If you want me to translate the above calculation in php script to work with images , please let me know..

veedeoo 474 Junior Poster Featured Poster

Hi,

You mean like this?

link -->link is clicked -> use "link" string as part of the database query -> script returns result based on the query

So, for the above logic the query can be something like this -> select from link, or select from some table where something is equal to link.

Is that it?

If that is what you need you could either grab the link string from the database OR take it from an array. It is reverse of what you have in mind.