veedeoo 474 Junior Poster Featured Poster

Redirection should be in the page or the script location where the uploads are being processed.

Example flowchart

User Upload images --> User Click Submit Button --> Script Post Data to processor.php --> Processor.php confirm uploads -->Processor.php redirects user --> end of script.

veedeoo 474 Junior Poster Featured Poster

try, look for javascript redirect. The only problem with this approach is that it will not work if javascript is turned off.

echo '<script type="text/javascript">
<!--
window.location = "http://YourDomainDotCom/uploads/$contact_name/index.html";
//-->
</script>';

Otherwise, you must end the script just right after your redirection code. Something like this

header("Location: uploads/$contact_name/index.html");
exit;

## all the codes below this will be ignored. Unless, you rearrange your statements, so that your redirection codes will be the last.
Biiim commented: useful +3
veedeoo 474 Junior Poster Featured Poster

correction!

Change this...

$total_AmountDue = $total_Mprice + $total_Mprice + $total_Mprice ;

to this

$total_AmountDue = $total_Sprice + $total_Mprice + $total_Lprice ; 
echo "Must Pay ".$total_AmountDue." Immediately, or else I will eat these Pizza";

if you will be adding sales tax to your cutomer total amount due, then it should changed to

$gross_AmountDue = $total_Sprice + $total_Mprice + $total_Lprice ; 
$tax_Rate = 9.5 ; ## this is for a sales tax rate of 9.5 percent
$total_AmountDue = round((($gross_AmountDue) * ($tax_Rate / 100)), 2 );
echo "Must Pay ".$total_AmountDue." Immediately, or else I will eat these Pizza";
veedeoo 474 Junior Poster Featured Poster

I think OOP first, singleton second (this is important in some environment), templating system third. Getting very comfortable with those three might change your perception about MVC. If it doesn't, make MVC fourth (try cake or codeigniter):).

I prefer Zend framework, because I already spent all of my monthly allowance, including my lunch money on it. If I only have known better, I probably stick around with codeIgniter or Cake. There are occasions where any of those will not fit the environment , but OOP and some simple templating system like smarty will do the job with less thinking and less grease on my hair.

veedeoo 474 Junior Poster Featured Poster

Hi,

You want to run this script from remote desktop and pass the gathered info. over the network? Just for the sake of curiosity, what are you trying to achieved?

veedeoo 474 Junior Poster Featured Poster

Hi,

You can add <input> to your form and give them a name unique to the pizza size. Fore example, take a look at the codes below..

<INPUT TYPE=checkbox NAME="pica10" VALUE="S">10" Php300 
<input type="text" name="sq" value=""/> 
      <INPUT TYPE=checkbox NAME="pica14" VALUE="M">14" Php450 
	  <input type="text" name="mq" value=""/> 
      <INPUT TYPE=checkbox NAME="pica18" VALUE="L">18" Php650
	  <input type="text" name="lq" value=""/>

Then on your form processor, you need to make sure that specific pizza has been selected, otherwise you might end up charging the customer for something they did not order. Use jquery to validate your form for the quantity.. it has to be an integer.

So, look for something like

if(($_POST['pica10']) && ($_POST['sq'])){
## set condition if the quantity is not empty then proceed below

## calculate the sum of the small pizza ordered
$total_Spizza = 1 * ($_POST['sq']);
## calculate the price of the small pizza
## WARNING! DO NOT put any integer inside the quotes..it don't matter if single or double
$total_Sprice = 300 * ( $total_Spizza );

## if quantity is empty $total_Spizza = 0

}

if(## this is for medium pizza){
## Do the same for the medium pizza exact format as above
$total_Mpizza ="";
$total_Mprice ="";

}

## do the same for the large
if(){

}

## calculate the sum of the total bills to be paid by custumer

$total_AmountDue = $total_Mprice + $total_Mprice + $total_Mprice ; 

## calculate the total Pizza you need to bake and deliver to the customer

echo "Need to bake".$total_Spizza." Small Pizza ".$total_Mpizza." Medium …
veedeoo 474 Junior Poster Featured Poster

ok, I was looking at my previous post on this forum and I just realized I posted something that can be adjusted or modified to your needs..

Example TWO - This example is one notch above the example One above. WARNING! this utilizes PDO.. I am pretty sure most servers support this.

First, create a file settings.php

<?php
$db_host = "localhost";
$db_database = "YourDB_Name";
$db_user = "YourDB_User";
$db_password = "YourDB_PassWord";

?>

then the result.php

<?php
class Video{
## warning this $title refers to the database table column "title"
public $title;
## same as above
public $remotethumb;
## same as the two variables above
public $tags;
## assign description
public $description;
## attempt to print or echo which I always prefered
## of course we can do anything with the variables as declared above.
public function echo_something(){
## make the title red
$red ="";
$red .='<b style="color:red;">'.$this->title.'</b><br/>';
$red .='<b style="color:navy;">'.$this->description.'</b><br/>';
## if we want to add more values from the query, we can always do so by extending $red variables.
## in fact, we can even use this class to ouput a thumbnail base on the url of the thumbnails from the media table..
$red .= '<img src="'.$this->remotethumb.'"/><br/>';
 return $red;
}

} 
## settings.php is a file above where the database user, password, and db name is located.
## they are defined as follows; $db_host = "localhost";$db_user = "username"; $db_password = "db password";$db_database = "dbName";
include_once 'settings.php';

try {
    $someDb = new PDO("mysql:host=$db_host;dbname=$db_database", $db_user, $db_password);
   ## double check and …
veedeoo 474 Junior Poster Featured Poster

Hi,
The problem is that you never define additional properties for your database connection..

Here is a simple example AND SHOULD NOT be used in production site. I am just trying to give you a simple example. You still need to do some dirty work and lots of reading about the visibility, methods, and I always recommend to practice with the singleton pattern, and PDO..

Example One - The beginner's class. This has no properties and constructor. As simple as it is, the functions are just wrapped inside the curly brackets of the class. If you are not sure on how the things work, I highly recommend to take baby steps just like the example codes below.

## I am always criticize by many because of my class names are always in lowerCase, but I am not going to do it this time.

class Myclass{
## notice first curly?
## we can just dump all the functions we want here
## please observe which are global and which are not

function lets_Connect($host,$db_name,$db_user,$db_password){
## this is where you want to make your script connect to the database

 // right here

## You can send the query based on the connection above. Don't forget to define table of interest, where the data are coming
$db_query = "define your database query Here";

## here you can extract the output as an array. Normally, people would use while loop

## echo output here or assign them to some variable and just …
veedeoo 474 Junior Poster Featured Poster

please ignore... ardav already got it covered :)

veedeoo 474 Junior Poster Featured Poster

UPDATED: Please ignore my response below. I think I have a wrong assumption, because I run a test class to see it cycling has effects or not, but unfortunately based on my model it has no bearing at all..

dummy script extracted from a class used for evaluation.

function multi_Mynum(){
       $this->a = ( $this->val1 * $this->val2 * $this->val3 );
	   return "{$this->a}"; 
	 }

I might be wrong on this one. try cycling this

$this->num_rows = mysql_num_rows( $this->result );

I think I must have encountered a similar problem like this before, but not very sure when and which script?. I hope it would not hurt to try.

To cycle it,it would be something like this

$res = mysql_num_rows( $this->result ); ## now res is defined and isolated
$this->num_rows = $res;
veedeoo 474 Junior Poster Featured Poster

hmmn is this mysqli? Wow! have not seen this for years.. try

$stmt->bind_param('ss', $username, $password);

## prepare your statements
$username = "define it here";
$password = "define it here also";
## now execute the prepared statements above
$stmt->execute();

ONly then, you can begin with your query or whatever task you have in mind..

veedeoo 474 Junior Poster Featured Poster

by the way, you can consolidate your statements as

<?php
include "connect.php";

if ($idevice =="pbs")
{
$tb_school = "Public School";
}

elseif ($school =="gs")
{
$tb_school = "Government School";
}

else
{
$tb_device = $school;
}

?>
veedeoo 474 Junior Poster Featured Poster

Hi,

Try to isolate what is the mysql_fetch_array output..So, you may want to try running a test query instead. Something like this

if (!($rows = mysql_fetch_array($sql3)))
    {
        return null;
      ## or maybe to print or echo something if there is none, but the return null has to be commented above.
       echo "There is nothing to show";
    }
## if the statement above is false, then we can echo
$view=$rows['view'];
echo $view;

Another helpful hint is to add or die(mysql_error()); on your query..

$rows=mysql_fetch_array($sql3)or die(mysql_error());

Overall, I prefer to use the first one above, because how about if id = 40 does not even exist due to auto increment?

veedeoo 474 Junior Poster Featured Poster

no, I need full example and place where to put it, because I just used code from tutorial and changed Values to mines and database info

Hi,

Please follow Ardav's advice, and We must also give 4 thumbs up to all the members who contributed their insights to your problems. Read php.net's manual and try to understand them. What happened here is that you have presented us with big codes (php and mysql combined) to analyze. When people post questions with big codes like yours, the assumptions is that you are an advance coder.

Looking at your codes, anyone can draw their conclusion that your codes were written by an advance coder, because of the implementations of php shorthand and so as the use of shorthand query. Please be informed that nothing is wrong in using shorthands in either php or mysql. However, it has to be used oNLY in an environment where it is feasible and supported. Meaning, this <?=$something?> can falter at times (read about php.ini directives), but in perfect environment it won't. The same set of conditions applies to your mysql query.

Some people call this as mysql hack query (not the hack most people are afraid of, but the ones that makes our coding tasks a lot easier). In a favorable environment, these codes will thrive. However, this approach requires precision on your part.. you cannot skip a column value NOT EVEN once.. It has to be perfectly matched or paired …

veedeoo 474 Junior Poster Featured Poster

Hi,

next time place your codes between the [CODE} tags... just like what I did to your codes below.

<?php

$searching=$_POST['searching'];
$searchfilm=$_POST['searchfilm'];


//If form is submitted
if ($searching =="yes")
{
echo "<h2>Film Review</h2><p>";


//If field is empty send a message
if ($searchfilm == "")
{
echo "<p>You forgot to enter a search term";
echo
exit;
}


//Connect to database
mysql_connect("nmnm", "jkjk", "mnm") or die(mysql_error());
mysql_select_db("nmnnm") or die(mysql_error());


//Filter search
$searchfilm = strtoupper($searchfilm);
$searchfilm = strip_tags($searchfilm);
$searchfilm = trim ($searchfilm);


//Qyery database
$data = mysql_query("SELECT film.filmname, review.filmreview, review.reviewtitle FROM film, review WHERE film.filmid = review.filmid AND filmname = '$searchfilm'");

//$result = mysql_query($data) or die(mysql_error());


//Display film title searched for
echo "<b>Film Name:</b> " .$searchfilm;
echo "<p>";


//Display results
while($row = mysql_fetch_array($data))
{
// echo $row['filmname'];
// echo "<b>Film Name:</b> " .$searchfilm;
echo "<table border=\"2\" align=\"left\">";
echo "<tr><td>";
echo "<b>Review Title:</b> " .$row['reviewtitle'];
echo "<tr><td>";
echo $row['filmreview'];
echo "<p>";
echo "<form method='post' action='analyse.php'>";
echo "<tr><td><input type='submit' name='analyse' value='Analyse'/></td></tr>";
echo "</form>";
echo "</table>";
}



//If result doesn't exist give an error message
$anymatches = mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Your request could not be processed, please enter a valid search<br><br>";
}

}

?>

It hurts the eyes, and I have to take some break for now..

veedeoo 474 Junior Poster Featured Poster

Hi,

try to set up an AND operator, like

if(($gravity == 0)&&($weight == 0)){
## show something, instead of the calculated value here.

}

else{

## show calculation if both the gravity and the weight are greater than zero

}

Test your codes by removing the value in

<input type="text" name="weight" id="weight" value="<?php echo $weight ?>"/>
veedeoo 474 Junior Poster Featured Poster

when i am pressing style1 the original page is coming with 'style' button. why is it? there's nothing should come right ? whats wrong

put your style button within the else statement like

<?php
}
else{
?>
<form method="post" action="">
<input type="submit" name="submit" value="Style">
</form>
<?php
}
?>

Just to remind you that you cannot double post on the same type of question. That will throw off a lot people here, who are just trying to help you..

It could be this post, or the other one that you've just started.. you choice..

veedeoo 474 Junior Poster Featured Poster

Hi, change your codes to this

<?php
if(isset($_POST['submit']))
{ ?>
<form method="post" action="">
<input type="submit" name="submit1" value="Style1">
</form>

<form method="post" action="">
<input type="submit" name="submit2" value="Style2">
</form>

<form method="post" action="">
<input type="submit" name="submit3" value="Style3">
</form>

<form method="post" action="">
<input type="submit" name="submit4" value="Style4">
</form>

<form method="post" action="">
<input type="submit" name="submit5" value="Style5">
</form>

<form method="post" action="">
<input type="submit" name="submit6" value="Style6">
</form>

<?php
}
?>

<form method="post" action="">
<input type="submit" name="submit" value="Style">
</form>

You cannot put html tags within the php tags, without echo or print or better yet close the php tags and then re-open where it is needed as shown on your modified codes I have provided.

veedeoo 474 Junior Poster Featured Poster

I still recommend to use fieldnames or column names on the insert query, because without it your script can easily break. For instance, you have 25 columns in your table and you mistakenly insert 24 values only, then your script will be doomed with errors.

Another option you may want to utilize is PDO which is pretty handy.. especially, in reporting errors..

You can also do an inventory on how many columns are on your table by running this script..

<?php
$db_host = "localhost";
$db_user = "userName";
$db_password = "password";
$db_database = "database Name or table";

mysql_connect($db_host, $db_user, $db_password) or die("Sorry Dude I cannot connect");

mysql_select_db($db_database)or die("OOPS connection failed. While trying to connect to ".$db_database);
## I modified this script from another script author..so, I don't know why id won't print out on the output.
$simple_query = "select * from anketa";
$res = mysql_query($simple_query);

$n_col = mysql_num_fields($res);

for ( $some_x = 0; $some_x < $n_col; $some_x++ ) {
$col_names = mysql_field_name($res, $some_x);
echo "'".$col_names."',";
}
?>

NOTE: the column "id" will not get printed. If you want to include those fieldnames on your query you can copy and just add 'id', on top of the list. Don't forget to remove the very last , (comma)

veedeoo 474 Junior Poster Featured Poster

something like this

INSERT INTO `anketa` (col1, col2, col3, moreCOL_ifNecessary)VAlUES (All the values HERE as shown on your script);
veedeoo 474 Junior Poster Featured Poster

does your db table anketa have columns at all? What i meant is that you want the script to insert the data to your dbase with all these values, but what column does these data needs to be inserted?

veedeoo 474 Junior Poster Featured Poster

try.. make sure the directory and the file name are properly assigned below.

if (file_exists($attcid."whatever.extensionOfFile"){
						@unlink($attcid."whatever.extensionOfFile") ;
					}
else{

echo "Are you kidding me? This file don't even exist. I already looked.";

}
karthik_ppts commented: Useful post +6
veedeoo 474 Junior Poster Featured Poster

good thing it all worked out for you...Another thing I noticed on your code is the php error suppressor @.. as in

@$username = $_POST['name'];
@$country = $_POST['country'];

it should be like this

$username = @$_POST['name'];
$country = @$_POST['country'];

Here are the reasons why?

The posted value of $_POST; is assigned to variable $username right? The error will not come up until fault is detected during the POST. So, the error is definitely coming from the post and not from the variable $username. My explanation is a little bit cloudy.

Your final practice codes should be something like this

<?php
    mysql_connect("localhost", "root", "test") or die(mysql_error());
    mysql_select_db("testdb") or die(mysql_error());
     
    
     
    if (isset($_POST['submit'])) {
	
	## if the form is submitted then we can post name and country
	
	## suppressors should be placed on the item or items assigned for the variables.
    $username = @$_POST['name'];
    $country = @$_POST['country'];
	
    ## we need to comment out the query first to see if it is posting your form
   
      mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) ")
      or die(mysql_error());
     
     
     
      }
    ## lets echo the username and country to view the result
    echo $username."<br/>";
    echo $country."<br/>";
     
    ?>
    <form method="post">
    username<input type="text" name="name" value=""> </br>
    country<input type="text" name="country" value=""></br>
    <input type="submit" name="submit" value="Submit">
    </form>

As you become proficient with this type of database query, try to attempt learning and working on PDO, because you can isolate the problems as they arise a lot better. It is not that hard.. it is all about how you design the flow …

veedeoo 474 Junior Poster Featured Poster

The echo test..

ok let's do it this way first.. We need to see if the form data is being posted on the script side and the data is even being pick up; what we are trying to insert.

<?php
    mysql_connect("localhost", "root", "test") or die(mysql_error());
    mysql_select_db("testdb") or die(mysql_error());
     
    ## lets remove the error suppressors for now
    $username = $_POST['name'];
    $country =  $_POST['country'];
    
    if (isset($_POST['submit'])) {
## we need to comment out the query first to see if it is posting your form
/*
        mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) ")
    or die(mysql_error());

  
*/

## lets echo the username and country to view the result
 echo $username."<br/>";
echo $country."<br/>";
    }   
    ?>
    <form method="post">
    username<input type="text" name="name" value=""> </br>
    country<input type="text" name="country" value=""></br>
    <input type="submit" name="submit" value="Submit">
    </form>

If you are viewing the username and country, you script is working. You can then remove the comment tags and try again if it will post on your database.


I just realize that all along the error on your code are these..

if (isset($_POST['Submit']))

and

<input type="submit" name="submit" value="Submit">

to correct the problem, the above should be changed to this

if (isset($_POST['submit']))

You will probably noticed that I already made a correction on your codes on the echo test

veedeoo 474 Junior Poster Featured Poster

Hi,

Try searching it on google "image upload php script". If you find one, which I am 100% sure you will. Test the script within your server's environment.

In case, you bump into to troubles, post the codes here and we will attempt to decipher the codes and will try to give sound advice as to where the problem is coming from.

veedeoo 474 Junior Poster Featured Poster

try changing this

mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) "); 
or die(mysql_error());

to this

mysql_query("INSERT INTO users(name, country) VALUES('$username', '$country' ) ")
or die(mysql_error());

The T_LOGICAL_OR error is caused by ; the or die is part of your statement and should not be separated from the query.

Just a humble question, what is the reason behind this code?

if (isset($_REQUEST['Submit']))

Can't we just make it like this?

if (isset($_POST['Submit']))

or

if (isset($_GET['Submit']))

$_REQUEST is generalized form processor function. Many people find it handy, because you don't even have to take a second look on whatever form method assignment they have on the form. One function takes all...

I don't see much problem using $_REQUEST in non-database pagination applications, or maybe some flat file processing where data is somewhat pretty casual in terms of security. However, if the application is going to be inserting, deleting, dropping, and updating data, it can create some security issues on the application.

veedeoo 474 Junior Poster Featured Poster

show us the root of this, and we will tell you.

$custom[0]->value

the root could be class or function..

veedeoo 474 Junior Poster Featured Poster

ok, after giving this question much thoughts over a gallon of starbucks coffee, I decided to write and test based on the environment similar to the question.

This script uses a class, and then utilizing the PDO FETCH_CLASS. So, instead of investing some memory twice for the return of one, we will utilize the FETCH_CLASS by PDO, which is deemed to be the only way of doing things properly.

Feel free to modify this script for your needs.. I tested it under the php 5.X environment and it is working the way I expected it to be.

Here you have it.. the script is well commented. Please ignore the Morpheus an Neo thing, I just got carried away.. :)

<?php
## once again this script is written by PoorBoy or veedeoo.
## for whatever it's worth, feel free to use it.

class video{
## warning this $title refers to the database table column "title"
public $title;
## same as above
public $remotethumb;
## same as the two variables above
public $tags;
## assign description
public $description;
## This will be the output, either  print or echo which I always prefered
## of course we can do anything with the variables as declared above.
public function echo_something(){
## make the title red
$red ="";
$red .='<b style="color:red;">'.$this->title.'</b><br/>';
$red .='<b style="color:navy;">'.$this->description.'</b><br/>';
## if we want to add more values from the query, we can always do so by extending $red variables.
## in fact, we can even use this …
veedeoo 474 Junior Poster Featured Poster

this code is already a loop over

$row 	= $rs->fetch(PDO::FETCH_OBJ);

meaning, the objects can be called like this

echo $row->Name; and echo $row->Email;

However, if those objects are needed to be called through the instantiation of the class without being printed or echoed within the class, it may cost a little bit of server resources. Memory wise, but not a lot :).

We need to pass the obj to something else that we can call during the class instantiation. Not the best choice, but this is all I can think of right now.

Let's expand your code a little

## remember this is a loop over
$row = $rs->fetch(PDO::FETCH_OBJ);

## let's assign them
$item['name'] = (string)$row->name; 
## Warning name is case sensitive which pertains to your database column name.
## let's set the next one email
$item['email'] = (string)$row->email;

$output[] = $item;
return $output;

Now, this is not a very clever thing to do, but since we don't want to print anything inside the function and within the class, I guess it is ok to do this. This is like a double jeopardy, because we already spent some memory on the loop over and will be spending the same amount for the foreach loop below

## instantiate the clas here
## call your function $something = $Customer -> getCustomer($_GET[customer_id]);

now the part that I don't like

foreach($something as $info){
  
echo $info['name']."<br/>";
echo $info['email']."<br/>";

}
veedeoo 474 Junior Poster Featured Poster

Try changing

$query = "SELECT COUNT(*) as num FROM shopcatid = '" . $shopcatid . "' AND shopsubcatid = '" . $shopsubcatid . "'";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];

to this

$query = "SELECT COUNT(*) FROM shopcatid = '" . $shopcatid . "' AND shopsubcatid = '" . $shopsubcatid . "'";
$total_pages = mysql_fetch_row(mysql_query($query));
$total_pages = $total_pages[0];

Just my humble opinion, why not remove the entire pagination codes out of your codes and make it a function. This way your page is only left with the database query and the results.

veedeoo 474 Junior Poster Featured Poster

no not really, you can always clean everything up, and then pass it on. Normally, people would do something like this..

somedomainDotcom/index?something=Whatever&page=somePage

Before passing the "Whatever" and "somepage" to the url, you can clean it up really well and do something like this

$something = base64_encode('Whatever');
$page = base64_encode('somepage');

and then on the processor page, you can pick it up by

$something = base64_decode($_GET['something']);
$page = base64_decode($_GET['page']);

A classic example of this is Google... take a look at their implementations..

veedeoo 474 Junior Poster Featured Poster

If you did not do any filtering on the users input, they maybe able to pass DROP upload -- by way of looking at the source code of your form. My wannabie hack codes can easily drop all of your upload table, if they just know where to look for an opening.

$query = "SELECT name, type, size, content " .
         "FROM upload WHERE id = '$id' DROP upload --";

This will get executed first,

$query = "SELECT name, type, size, content " .
         "FROM upload WHERE id = '$id'

followed by this

DROP upload --

The next thing we know, the entire upload table is gone. Honestly, I really hate discussing holes and hacks in public, because it teaches people how to do it, either for fun or for some unknown personal gratifications.

Try searching online.. I have a black book I downloaded long time ago when I was 13, I experimented with it,and it work really well. However, the main concept behind the book is for protection and not to cause harm to others.

Here are the classic login tricks to hack, and you must put great efforts on how to protect your codes..

admin' --
    ' or 1=1--
    admin'/*
    ' or 1=1/*
    ' or 1=1#
    ') or ('1'='1--
     ....
     admin' #
    ') or '1'='1--
veedeoo 474 Junior Poster Featured Poster

Hi,

I found echoing $a and $b kind of boring, so I have to make something up to make it a little bit interesting. Here is the basic setup of what you are trying to achieved..not sure, but that's my only guess.

you cannot get a result by doing return $this; and return $thisAlso; .. Due to the script is already been stopped on the very first return $this..

here is a simple script where you play around with values ... I just made this up and I don't have the time to test it locally, but I am sure it should echo something if not error :)..when you do get an errors, please let us know..

<?php
class demo{
var $a ; ## where r u?
var $b ; ## how about me?
var $c;

    function demo(){
	#the constructor needed for the function lets_echoAll below, but NOT necessary for the first two functions below
	## this is intended to be empty and MUST be empty. NOtice it has the same name as the class "demo"?
	}
    public function multi_Mynum($val1,$val2,$val3){
       $this->a = ( $val1 * $val2 * $val3 );
	 return $this->a; ## a 'm here..
	 }
	 function q_Mynum($val1,$val2,$val3){
	 	 if($val1 <=0) $val1 = 1; ## we don't want zero here
	 $this->b = ($val2 + $val3) / ($val1); ## $val1 CANNOT be equal to ZERO
	
	   return $this->b; ## you should b here
	 
         }
    
     function lets_echoAll(){
	 ## the reason we are able to echo these @ all, because of the …
veedeoo 474 Junior Poster Featured Poster

Hi,

I am busy on my school homework right now, but I will attempt to post a solution sometime this weekend if you don't get a response until that time.

Before making my promise a final one, can you please tell us how these information are used?

$method = 'ipinfo/';
$apikey = '100.hva7qa7893wzcsc3x8dk';
$secret = 'uHZVvYK5';

Does the site needs log in?
Do you need to validate?

those questions are really important, because cURL will not work or not allowed to access those info.

Another hint! Did you ever try to use cookiejar on your cURL to make it work?

veedeoo 474 Junior Poster Featured Poster

You can also try this.

veedeoo 474 Junior Poster Featured Poster

To test if the attributes ..

$t_one = $c_thumb->thumbnail[0]->attributes();
$t_two = $c_thumb->thumbnail[1]->attributes();

exist, then you will have to use bool like this

$t_one =(bool)( $c_thumb->thumbnail[0]->attributes());
$t_two = (bool)($c_thumb->thumbnail[1]->attributes());

If the attributes ever exist on the xml file, then the script should return 1.. Based on this response, you can use it to switch your thumbnails or whatever you want to access.

Comment the if statement and trigger the (bool) and then echo out the "$t_one".. This should give you something like this on your page

1
1
1
1
1
1
1
1

10
and so forth... For none existing attributes it should return zero (0)..

That's all you have to do.. It is true or false..

IMPORTANT! Once you use the "$t_one" for boolean, you will have to assign another variable for your thumb like

if($t_one == 1){
$t_one_is_true = $c_thumb->thumbnail[0]->attributes();
$thumb_one = $t_one_is_true['url'];

}

Once the script has been tested several times, I strongly suggest for you to rewrite in condensed form, or you can just leave like that.

veedeoo 474 Junior Poster Featured Poster

Here is the corrected codes for the above

$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_one = $c_thumb->thumbnail[0]->attributes();
## try to grab the second thumbnail of the article
$t_two = $c_thumb->thumbnail[1]->attributes();
## url of the first thumb
$thumb_one = $t_one['url'];
## url of the second thumb
$thumb_two = $t_two['url'];
## set condition if
## we cannot use !=null, becuase simpleXML views the file as xml file
if($thumb_two != ""){
$thumb = $thumb_two;
}
else{
$thumb = $thumb_one;
}

for the second codes

$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_one = $c_thumb->thumbnail[0]->attributes();
## try to grab the second thumbnail of the article
$t_two = $c_thumb->thumbnail[1]->attributes();
## url of the first thumb
$thumb_one = $t_one['url'];
## url of the second thumb
$thumb_two = $t_two['url'];
## set condition if
## we can use !=null, if simpleXML can return NULL as value for not found attributes
if($thumb_two != null){
$thumb = $thumb_two;
}
else{
$thumb = $thumb_one;
}

Make sure to test which one of the codes above works for you.. Double check and make sure you are displaying the second thumb "image info"..

veedeoo 474 Junior Poster Featured Poster

Hi this may work. I just don't have the time to test it locally. It should work..

$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_one = $c_thumb->thumbnail[0]->attributes();
## try to grab the second thumbnail of the article
$t_two = $c_thumb->thumbnail[1]->attributes();
## url of the first thumb
$thumb_one = $t_one['url'];
## url of the second thumb
$thumb_two = $t_two['url'];
## set condition if
## we cannot use !=null, becuase simpleXML views the file as xml file
if($thumb_two != ""){
$thumb = $thumb_two;

else{
$thumb = $thumb_one;
}

or this may work also

$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_one = $c_thumb->thumbnail[0]->attributes();
## try to grab the second thumbnail of the article
$t_two = $c_thumb->thumbnail[1]->attributes();
## url of the first thumb
$thumb_one = $t_one['url'];
## url of the second thumb
$thumb_two = $t_two['url'];
## set condition if
## we can use !=null, if simpleXML can return NULL as value for not found attributes
if($thumb_two != null){
$thumb = $thumb_two;

else{
$thumb = $thumb_one;
}
veedeoo 474 Junior Poster Featured Poster

Yes, you are correct.. You can always control the start and the stop. To achieved this, we need to assign another variable. Just like in basic mathematics where we invent another constant or variable Z , so that we can solve for the X and Y. Something like this Z = X+Y , Y = Z- X , X = Z - Y respectively. Can we apply those simple transpositions? Yes..

He we go. Remember our codes in the previous page? We can upgrade it to this

<?php
## Some pretty basic RSS parser
### some Announcement from me
## Written by PoorBoy from http://veedeoo.com/forum or Veedeoo from http://daniwed.com
## Date Created : January 18, 2012
## end of my tiny announcement

## type in your xml file location or rss feed
$xml ='http://feeds.bbci.co.uk/news/england/london/rss.xml';
## remove @ to debug
$xml = @simplexml_load_file($xml); 
$somecount = 0;
$base = 10;
$limit = 5;
 foreach($xml as $items)
 ## disecting the xml as items
{

## we are only interested on the <item> and its children
$item = $items->item;
foreach($item as $news){
## parse title
$title = $news->title;
## parse description
$description = $news->description;
## parse news link
$news_link = $news->link;
## parse publication date
$pub_date = $news->pubDate;
## this is standards in all xml and rss parsing
$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_attrs = $c_thumb->thumbnail[0]->attributes();
## we only want the url for this purpose
$thumb = …
veedeoo 474 Junior Poster Featured Poster

You are very much welcome. Good thing it all worked out for you..

asif49 commented: Offered great and thorough help, and even answered subsequent questions. Great Member! +3
veedeoo 474 Junior Poster Featured Poster

have you tried doing it on .htaccess?

given: actualDirectory and dummyDirectory.

If we provide a link in this form <a href="YourDomainDotCom/dummyDirectory/somevideo.wmv" target="_blank"/>Download Here</a>, then we can add a simple entry to our .htaccess like this;

Redirect /dummyDirectory/ http://YourDomainDotCom/actualDirectory/

If they view the source code of the page, they will only see this <a href="YourDomainDotCom/dummyDirectory/somevideo.wmv" target="_blank"/>Download Here</a> , and NOT <a href="YourDomainDotCom/actualDirectory/somevideo.wmv" target="_blank"/>Download Here</a>

Another method is to convert all of your videos to flv, inject metadata on them with flvtool2. Stream the video by way of pseudostreaming using xmoov. In fact, you can assign token on the xmoov streaming to filter who gets to watch your videos, but that's another lengthy process.

Big adult sites, the video url's are stored in the database, and then a view key is assigned with time limits. So, for every view key, a time limit is set on how long the url remains to be valid and accessible. For example,

table
| id | title | down_url | viewkey | expiration |
| 50 | | someVid | |this.wmv | |123564 | | 3600 |

You can then send a query for video from $_GET, to pull out other information.


You can also create an xml file using php , and then just extract the download url from xml file hidden from your viewers view.

veedeoo 474 Junior Poster Featured Poster

Hi, that's pretty easy... This is how you stop foreach loop iteration at any given point, assuming that the item within the loop is greater than 0.


On the codes above, find

$xml = @simplexml_load_file($xml);

just below it add;

$somecount = 0;
$limit = 10;

scroll down the page and find;

echo "Publication Date: ".$pub_date."<br/><br/>";

Just below it, add;

if (++$somecount >=$limit) break;

You must define your limit as integer like this $limit = 10; common mistakes even experts would do it like this $limit = "10"; which is a string..

veedeoo 474 Junior Poster Featured Poster

ok since I don't feel lazy today, here is a simple RSS parser I just wrote for anyone who needs it. The source code is heavily commented already that I don't even see the needs of explaining anything right now.

<?php
## Some pretty basic RSS parser
### some Announcement from me
## Written by PoorBoy from http://veedeoo.com/forum or Veedeoo from http://daniweb.com
## Date Created : January 18, 2012
## end of my tiny announcement

## type in your xml file location or rss feed
$xml ='http://feeds.bbci.co.uk/news/england/london/rss.xml';
## remove @ to debug
$xml = @simplexml_load_file($xml); 
 foreach($xml as $items)
 ## disecting the xml as items
{
## we are only interested on the <item> and its children
$item = $items->item;
foreach($item as $news){
## parse title
$title = $news->title;
## parse description
$description = $news->description;
## parse news link
$news_link = $news->link;
## parse publication date
$pub_date = $news->pubDate;
## this is standards in all xml and rss parsing
$c_thumb = $news->children('http://search.yahoo.com/mrss/');
## try to grab the first thumbnail of the article
$t_attrs = $c_thumb->thumbnail[0]->attributes();
## we only want the url for this purpose
$thumb = $t_attrs['url'];
## echo everything
echo $title."<br/>";
echo "<img src='".$thumb."'/> </br>";
echo "Description: ".$description."<br/>";
echo "Link: ".$news_link."<br/>";
echo "Publication Date: ".$pub_date."<br/><br/>";

}
}
  ?>

HINT: Do not double post your question in the future.. That's a bad practice..

veedeoo 474 Junior Poster Featured Poster

Hi,

Are there anymore codes above <item></item>? Can you give me the live url, so that I can take a look.

veedeoo 474 Junior Poster Featured Poster

edit reason: Wrong codes..

You can try

$r = mysql_fetch_row($result);

$textboxes_sum = $r[0];

Use $textboxes_sum in the value="$..."

veedeoo 474 Junior Poster Featured Poster

What I meant by "1. Make sure the directory is CHMOD to 0755 or 755 or 0777 or 777 depending on your server settings." is the upload_v directory. The script needs to write in this directory..

veedeoo 474 Junior Poster Featured Poster

Have you set the mercury as mail service?

veedeoo 474 Junior Poster Featured Poster

I almost forgot, add before the while{

$sum_ofsalary = 0;
veedeoo 474 Junior Poster Featured Poster

try replacing these lines

echo "<tr>";
        echo "<td>";
        echo $count."</td>";

With these

$sum_ofsalary += int_val($row['default_salary']);
        echo "<tr>";
        echo "<td>";
        echo $sum_ofsalary."</td>";

You can then use the $sum_ofsalary as the total of all salaries "default_salary" within the while loop..

veedeoo 474 Junior Poster Featured Poster

try taking this out of your do-while loops..

<table border="0" id="dcmdRtlmp" style="display:none;">
<tr>
<th></th>
<th scope="col">baltimore_zone</th>
<th scope="col">pepco_zone</th>
<th scope="col">dominion_zone</th>
<th scope="col">dominion_hub</th>
</tr>

something like this

<table border="0" id="dcmdRtlmp" style="display:none;">
<tr>
<th></th>
<th scope="col">baltimore_zone</th>
<th scope="col">pepco_zone</th>
<th scope="col">dominion_zone</th>
<th scope="col">dominion_hub</th>
</tr>

<?php 
do{ //whatever here 

}
while{ //whatever is true 

}
?>