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

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

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.

veedeoo 474 Junior Poster Featured Poster

have you seen This ? Hold on, free is with limited features though....

This code should be able to do it

<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>

<br/>Country Code:
<script language="JavaScript">document.write(geoip_country_code());</script>
<br/>Country Name:
<script language="JavaScript">document.write(geoip_country_name());</script>
<br/>City:
<script language="JavaScript">document.write(geoip_city());</script>
<br/>Region:
<script language="JavaScript">document.write(geoip_region());</script>
<br/>Region Name:
<script language="JavaScript">document.write(geoip_region_name());</script>
<br/>Latitude:
<script language="JavaScript">document.write(geoip_latitude());</script>
<br/>Longitude:
<script language="JavaScript">document.write(geoip_longitude());</script>
<br/>Postal Code:
<script language="JavaScript">document.write(geoip_postal_code());</script>
veedeoo 474 Junior Poster Featured Poster

Hi,

Remove extra curly bracket on line 111 just below echo $page_content.

veedeoo 474 Junior Poster Featured Poster

Hi,

This is what I am currently using, but my script records the IP of the visitors and the members as well, so that I can show who is online with their respective country flags based on the remote address.

Since I don't know your database instructures, I will use a simple script of which you can build what you are trying to make..

First, we need to detect the IP address of the browser...

$ip = $_SERVER['REMOTE_ADDR'];

Once we know about the IP address, we can pass that on to the hostip.info API to get the flag. hostip is not 100% is sluggish during redundant query.. So, I suggests for you to store the information gathered in your own database. The API returns two letter country codes.

Second, based on the ip above we can send our query to the API for the country flag to show on the page. We can use the codes below to do just that. Here is the complete script..

$ip = $_SERVER['REMOTE_ADDR'];
echo '<IMG width="20px" height="15px" SRC="http://api.hostip.info/flag.php?ip='.$ip.'" ALT="IP Address Lookup">';

Depending on the requesting traffic from the hostifp.info, your IP and flag specific to the country of your IP should be showing on this Demo. I am using the same script above with minor modification..

Of course you can expand and extend the above codes by visiting the hostip.info API usage guides. http://www.hostip.info/use.html

rayidi commented: This need registration & this won't work for Indian based IP Addresses +2
veedeoo 474 Junior Poster Featured Poster

Here is the Demo I made it for the other question in this forum.. Please feel free to copy the source and save all the javascript files to your server, and do not hotlink them from my site. I am just trying help out that is why I am publishing it on my site.

for the definite days of the month I think I must made one already.. I have just look where I keept those files..

cereal commented: nice! +8
veedeoo 474 Junior Poster Featured Poster

They are using ajax and other libraries.. Read more about this here.

For the username availability checker,, normally this is written in jquery and php try this tutorial

For ajax sample without page reload on click... check out my demo . You can view the source of the page and copy it at your own convinience.

veedeoo 474 Junior Poster Featured Poster

Try this...create a test page by copying the codes below and save it as delete.php

 <script type="text/javascript">
function check(){
var r = confirm("Are you sure you want to drop this appointment?!");
if(r){

return true;

}
else{

alert("The appointment will not be cancelled");
return false;

}

}
</script>
<a href="delete.php?delete=yes" onclick="return check();" />Delete</a><br/>
<?php

if(isset($_GET['delete'])){

 ## this is where you put the deletion, but make sure to get the right info.
 echo "Appointment has been cancelled";
}

?>

Codes above should mimic the process with alert and confirmation ..Then should echo Appointment has been cancelled, if choose to drop appointment. I hope you are seeing the pattern here when javascript is used along side with php. Php will not wait for this "alert("The appointment has been canceled!");".. Unless, you make a switch or if statement to confirm that the delete value has been passed.

However, the javascript will be responsible for allowing the href to get through and therefore, setting off the isset to true. Observe closely, when the prompt is on, the url of the page is at default, but when you confirm the delete, the url goes to delete.php?delete=yes, and that is the triggering mechanism for the php script. Making this if(isset($_GET['delete'])) equal to true.

veedeoo 474 Junior Poster Featured Poster

You could try using ReflectionFunction class as shown here -> http://php.net/manual/en/class.reflectionfunction.php and just call it something similar to this. Will only work on php 5..

$findMyFunction = new ReflectionFunction('Name_Of_Function_You_Need_to_look_At');

## print will work better here than echo ..

print $findMyFunction->getFileName() . ':' . $findMyFunction->getStartLine();

Checking if the function exist before calling it will also help greatly..

 if(!function_exists('some_function'){

 ## do some_function..

 }
diafol commented: good link +0
veedeoo 474 Junior Poster Featured Poster

here is the simple Demo of the above script . Although the string is not being pulled from the database, the term gets highlighted..

veedeoo 474 Junior Poster Featured Poster

Hi,

Try this. First lets make a function to do the hightlight..

function highlightTerms($text_string, $terms){

    ## We can loop through the array of terms from string 
    foreach ($terms as $term)
    {
         ## use preg_quote 

            $term = preg_quote($term);

           ## Now we can  highlight the terms 

            $text_string = preg_replace("/\b($term)\b/i", '<span class="hilitestyle">\1</span>', $text_string);
    }
          ## lastly, return text string with highlighted term in it
          return  $text_string;
    }

How to use the function above? It could be something like this.. I am only be showing your while loop, and you still have to assemble everything..

    ## this is your while loop from above.
while ($row = mysql_fetch_array($sql))
{
     ## we need to pick up the search terms or terms and put them into an array

     ## in this example, I will be using the $row['title'] as the text string

 $text_string = $row['title'];

     ## the array of terms from the search keywords as $term 

 $terms = array($term, $term);

     ## return the string with hightlighted terms

 $highlite_string = highlightTerms($text_string, $terms);

     ## echo everything here.
     ## Use $highlite_string as subtitute to your actual title.


     ## end of whille loop

 }

On your css file add style to hilitestyle using the highlight css property..

veedeoo 474 Junior Poster Featured Poster

I don't think there is one book that will cover them all, but this is how I did it on top of the countless nights reading every possible ebook and phpDev articles I could find. Of course, not to forget the w3schools and php.net credits. In fact, I have colletions of about 38 academic books of various programming languages. Some of them were given to me by my older brothers who are software Engineers. At a very young age, I learned from them, watching how they do things.

First to second Week of reading: Read Beginning PHP 5.3 by By Matt Doyle.

Third to Fourth Week of reading: Learning PHP, MySQL, and JavaScript
A Step-by-Step Guide to Creating Dynamic Websites By Robin Nixon

and then try-> PHP Objects, Patterns and Practice (Expert's Voice in Open Source), this book will not get you bored ever I think. Prepare to get your hair really greasy for weeks, learn how to drink lots of coffee, walk in the park or ride the bike until everything sinks in.

When finished with the php objects above, apply your gained knowledge by reading this book PHP 5 CMS Framework Development Second Edition by Martin Brampton. Try to expirement with the codeIgniter framework, cakephp, and of course the ### rated Zend Framework.

If all is well for you after the CMS and framework Development, aim for the Zend Framework Certification or write you own application based on either of this frameworks (codeigniter, phpckae, symfony.. with either …

veedeoo 474 Junior Poster Featured Poster

Hi,

Just like what Joshmac has said. You need to move few steps back for a moment and then forward if everything on the php side is confirmed to be working.

To do this, we need to check and make sure we are getting something on the screen as output from the script. Ignoring everything from the fpdf class, lets do this first.

Copy codes below and save it anyNameYouwant.php . Put this file in your localhost

<?php

  function simple_func($sql){
  ## define your database connection credentials
 $db_host = "localhost";
 $db_user = "YOUR_DATABASE USERNAME";
 $db_password = "YOUR DATABASE PASSWORD";
 $db_database ="YOUR DATABASE NAME";

 $conn = mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
 $db = mysql_select_db($db_database,$conn)  or die(mysql_error()); 
 $result = mysql_query($sql, $conn) or die(mysql_error()); 

 ## And we pulled the results 
 while($row = mysql_fetch_array( $result )) 
{
$data[] = $row;
}
## we return the data

 return $data;

 }
$text_file = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

$sql = "(SELECT * FROM lifeplan )"; 
$pdf_data = simple_func($sql);
foreach($pdf_data as $info){

$stringData = $info[1]."\n";
fwrite($fh, $stringData);

}


fclose($fh);

After running the script, it should create a text file named testFile.txt. Is the text file created? Ans: NO-> check your database creadentials and make sure they are filled in properly.. Yes-> copy codes below and run the actual pdf creator.

If you can see the actual text file created above, we need to run a second test to confirm that fpdf.php class is working on your side. Save codes below anyNameYouWant.php

<?php
 function simple_func($sql){
 ## …
veedeoo 474 Junior Poster Featured Poster

Hi,

Try this.. open your notepad or any suitable php code editor. Paste codes below

ErrorDocument 404 /404.html 

Save the above as .htaccess , and then upload to your server.

Second step..
On your notepad again or html editor, create a new page similar to the google 404 page and name it 404.html

upload the 404.html to your server.

That's about it...

veedeoo 474 Junior Poster Featured Poster

Ok, I am back to tackle this. Please bear in mind that my style of coding is somewhat different, but it will make a lot of sense if given the proper analysis logic wise. My head is always wired like this -> logic ->View -> template system.

Since there is no way for me to teach someone how to work on php frameworks and templating system in this short of time, I will be using the same coding techniques I have implemented when I was 13 years of age, and when I was barely learning how to write php programs. Even after 6 years, I am still surprised on how my mindset able to creatively do this.

I am hoping that this technique will help the new comers in php language. Although it is not perfect, I truly believe this will truly help people how to organize their codes.

**!WARNING AND DISCLAIMERS! **This script is not sanitized.. I want you to do it yourself, for you to gain an actual experience on sanitizing data for database query. I also don't give or extend any warranties for this script. The final version of this script must be all based on your own server environment.

Here we go..

STEP ONE:

On your localhost create 2 two directories. Name these directories as includes and template

STEP TWO:
Copy codes below and name it index.php or whatever name you want.

filename: index.php or whatever.php

<?php
    ## This is sample script written by PoorBoy …
veedeoo 474 Junior Poster Featured Poster

Hi,

You can also look at the form validation class in system/libraries/. Class definitions and functions are explained Here. Either extend the class as shown in this example, or set new rules

$this->form_validation->set_rules();.

I remember bumping into this problem two years back, but I can't even remember how and which files we have to tweaked. I will ask my brother Michael though to see if he ever remembers.

veedeoo 474 Junior Poster Featured Poster

@faisals701,

Here is a classic example of $_REQUEST vulnerability, if NOT properly PROTECTED.. Copy codes below and upload to your localhost. You can name it anyNameYouWant.php. Regardless of the form method use as long as it not protected, it will have the same vulnerability as to no method at all by way of REQUEST processing.

<?php
$method_one = '<form method ="POST" action ="">';
$method_two = '<form method ="" action ="">';
$method_three = '<form method ="GET" action ="">';

if (isset($_REQUEST['submit'])){
	$name = $_REQUEST['name'];
	$nickName = $_REQUEST['nickname'];
	
	echo $name."<br/>";
	echo $nickName."<br/>";
}
else{
 ## uncomment ONE method at a time here
 
 ## uncomment method one to test POST
 //echo $method_one;
 
 ## uncomment method two to test either method
 echo $method_two;
 
 ## uncomment method three to test GET method
 //echo $method_three;	
?>

<label>Name</label>
<input type = "text" name = "name" value ="" />
<br/>
<label>Nickname</label>
<input type = "text" name = "nickname" value = "" />
<br/>
<input type = "submit" name="submit" value ="submit"/>
</form>
<?php
}
?>

To test uncomment the $method_WhateverNUmberHere, comment out the one that you don't need to test.

Run the script on your browser, and try to test all the options -> $method and closely observe how the script will handle each $option. To make it a lot easier for everyone, if the method $_REQUEST isn't defined will default to $_GET effect. Meaning, if method is assigned like this method = "" (blank) it would have the same effect as method = "get".

For example, …

veedeoo 474 Junior Poster Featured Poster

I just want to let you know that I just tested codeIgniter in my thumbdrive and it is working pretty well as I thought it would be.

The latest codeIgniter ( I have not run codeIgniter for two years now). I am impressed with the latest Version 2.1.0, because it is already loaded with Template Parser Class by default.

Meaning that you can easily create an application without any php codes in your view files.

Example -> Normally, people would go this route..

<!-- this is the html file on the view side -->
<body>
<h1><?php echo $title; ?></h1>
<div id="content"><?php echo $content;?></div>
</body>

With the template parser , template parser can be easily called like this

$this->load->library('parser');

$content_forTheview = array(
            'hstring' => 'This is string for H1',
            'viewContent' => 'This is the very cool content for the view'
            );

$this->parser->parse('indexTemplate', $content_forTheview);

then the new view file (indexTemplate) will look something like this.. it is kind of the same as smarty but for what I have read it is lighter.. The parser can also handle multidimensional array.. from database or wherever..

<!-- this is the html file on the view side -->
<body>
<h1>{hstring}</h1>
<div id="content">{viewContent}</div>
</body>

So the benefit of running the template parser class is that you can give your view files to anyone to work on the design or whatever, without the worries about your codes breaking in the hands of others.

Please check out their website.. the new codeIgniter comes with many …

veedeoo 474 Junior Poster Featured Poster

Good to hear you have strong OOP concept.. you shouldn't have any problem with the transition.

I hate recommending Zend framework, but if you will be using framework as part of your resume, then I think you are better of with the Zend framework with certification. I know it is very expensive, but that will make you something special on the paper at the least.

However, if you are just trying to explore frameworks, the most common, popular and probably the most easy to get support is either cakePHP , symphony or codeIgniter. Both cake and igniter can work effectively with smarty, while the symphony can work with twig.

I tried all of them, actually I spent all of my school monthly allowances for 3 months on Zend certification, because it is an standardized approach.

However, outside Zend my take will be phpCake or CodeIgniter there aren't too many push and pull on their differences. Having said this, If you will be writing some big applications in the future, CakePHP can probably thrive with you. Of course, if you can tackle the Zend framework that would be an excellent choice not only for personal development, but also for a professional career .

Don't get confused with other people are saying. Some will tell you how great is the cake, while the others will tell you codeIgniter is the best, and Zend is the far most superior. The best thing you can do if these too …

iamthwee commented: good stuff +15
veedeoo 474 Junior Poster Featured Poster

Hi,

Something is wrong with these echoes..

echo '<tr><td class="rows">'; echo $origin_description; '</td></tr>';
echo '<td class="rows">'; echo $destination_description; '</td>';
echo '<td class="rows">'; echo $date = $res; '</td>';
echo '<td class="rows">'; echo $time = $res; '</td>';
echo '<td class="rows">'; echo $fare= $res; '</td>';
 
echo '</tr>';

it should be something like

echo '<tr><td class="rows">'.$origin_description.'</td></tr>';
echo '<td class="rows">'.$destination_description.'</td>';
echo '<td class="rows">'.$date = $res.'</td>';
echo '<td class="rows">'.$time = $res.'</td>';
echo '<td class="rows">'.$fare= $res.'</td>';
 
echo '</tr>';

And these

echo '<td class="rows">'.$date = $res.'</td>';
echo '<td class="rows">'.$time = $res.'</td>';
echo '<td class="rows">'.$fare= $res.'</td>';

Although it will get outputted , it is not standard. It should be define before echoing them. Your codes will look nice and well organized.

ADDED LATER on EDIT

The above should be changed to these, because the values has already been assigned from the query results.

echo '<td class="rows">'.$date.'</td>';
echo '<td class="rows">'.$time.'</td>';
echo '<td class="rows">'.$fare.'</td>';

OR to these

echo '<td class="rows">'.$res['date'].'</td>';
echo '<td class="rows">'.$res['time'].'</td>';
echo '<td class="rows">'.$res['fare'].'</td>';
veedeoo 474 Junior Poster Featured Poster

don't forget to trim the new_data..

$birdName = trim($new_data[0]);
$birdId = trim($new_data[1]);
veedeoo 474 Junior Poster Featured Poster

Yes, it will be in the dropdown.

veedeoo 474 Junior Poster Featured Poster

If I can help you, can I at least get a free Bus pass? Where is this place though? :). If it is too far from Princeton, New Jersey, it's ok :).

Stop punishing your fingers by typing these

<select name='dep_day'>
<option>Day</option>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select>

All dates, months, and years should be written in php like this

<?php
## you may want to write simple php function to get the number of days for the month
$days_ofMonth = 31;
echo '<select name="dep_day"/>';
for($dep_day = 1; $dep_day <= $days_ofMonth; $dep_day++){
?>
<option value="<?php echo $dep_day;?>"><?php echo $dep_day;?></option>
<?php
}
echo '</select>';
?>

You can focus more on your programming than typing identical numbers. Let the php work for you.

Biiim commented: helpful +4
veedeoo 474 Junior Poster Featured Poster

Hi,

I don't have the chance to test my codes below, because I am also busy at school.. NOOO it is not about programming. It should give you what you are trying to make.

PHP functions use in this script.. just in case your professor ask you.. empty(), $_POST, for loop, if/else, and mathematical operators addition, multiplication and !not.

<?php
## A simple pizza delivery system Written 

## layout our pizza options
 # define your maximum quantity inside the select option
 $max_q = 10;
 # define your pizza prices 
 $small = 300;
 $medium = 450;
 $large  = 650;
 
## first we detect if the submit button has been submitted, if not we show our client the form

if (isset($_POST['submit'])){
## the following prevent undefined error beyond the php 5.2.X versions.
$s_quant = "";$m_quant = "";$l_quant = "";$s_cost = "";$m_cost = "";$l_cost = "";
 ## process the form. What matters here the most is to know if the checkbox is ticked
 ## process small pizza if it is tick.
 if(!empty($_POST['pica10'])){
 $s_quant = $_POST['sq'];
 echo "<b>Small pizza</b><br/>Quantity: ".$s_quant."<br/>";
 ## always wrap var for mathematical calculation with parenthesis
 $s_cost = ($small) * ( $s_quant);
 echo "Price: ".$s_cost."<br/>";
 }
 if(!empty($_POST['pica14'])){
 $m_quant = $_POST['mq'];
 echo "<b>Medium pizza</b><br/>Quantity: ".$m_quant."<br/>";
 ## always wrap var for mathematical calculation with parenthesis
 $m_cost = ($medium) * ( $m_quant);
 echo "Price: ".$m_cost."<br/>";
 }
 if(!empty($_POST['pica18'])){
 $l_quant = $_POST['lq'];
 echo "<b>Large pizza</b><br/>Quantity: ".$l_quant."<br/>";
 ## always wrap var for mathematical calculation with parenthesis
 $l_cost = ($large) * ( $l_quant);
 echo "Price: ".$l_cost."<br/>"; …
veedeoo 474 Junior Poster Featured Poster

Do you know if it's possible to do that with EasyPHP as well? EasyPHP looks like a good local web server. Or is Xampp better?

Either one will make your development a lot easier... you can spend more time writing codes than trying to figure out your server configurations.

I am also using EasyPHP.. it all depends on what you are trying to write. If you will be developing an application in which ffmpeg, mencoder, mp4box, and flvtool2 are needed to be executed by the php script, then xampp is more flexible and accommodating for this type of applications.

Outside the youtube like development, I think EasyPHP got the upper hand, because it has more modules to offer for the most commonly develop applications such as joomla and presta shop ( I worked on some of modules and extension for this), just to name a few.

veedeoo 474 Junior Poster Featured Poster

Hi,

I can explain it in simple words without too many comments needed

The Input ---> The Processing of the Input ---> The output or the outcome of the processed input.

In short,

Controller(input) --> model(processing) --> View(output or template)..

Sample script
Controller

## checks if members logged in

$isLogged_in(){
## can instantiate class here

}

## if not logged show the form
## or make sure to offer registration

model

## process the data triggered by the controller
## registration and others
## in other words this will check username against the members in the database
## or will insert new members to the database

View

## show the output
## show content to the logged_in and to not logged_in

## if Smarty templating is included, then this is where the smarty assign takes place.
veedeoo 474 Junior Poster Featured Poster

Hi,

On your extension directory, look for the .dll files. Make sure that you are editing the php.ini file from the loaded configuration file.

If this does not work for you, then you must set the cofig file to php/php.ini, and then you copy the .dll files from the php5.3.9/ext/ dir to php/ext directory.

You should have a .dll file named php_mysql.dll in there.,

Depending on your OS, if running on window (all versions) the server configuration file is located in apache/conf directory. For the ubuntu and other distros powering desktops the configuration file is located in etc directory.


Don't forget to restart your server everytime entries are modified...

veedeoo 474 Junior Poster Featured Poster

Hi,

I did this type of testing in Paypal sandbox, too many times already. BUT, not to offend you or anything, can you please put your codes between the CODE tags. Then only that time when you did that, I will help you.. It gives me a terrible head ache looking at the codes that way..

veedeoo 474 Junior Poster Featured Poster

Hi,

jUst a friendly advice.. next time, enclose your codes with the code tag located on top of the editor.

It is a lot easier to red codes this way..

karthik_ppts commented: Yes +7
veedeoo 474 Junior Poster Featured Poster

Hi,

Do you mean text link to submit the form? Actually, you can use images if you want. We cannot accomplish this by using PHP. It has to be javascript.. I was going to advice you to post your question in the javascript forum, but I figured out the codes for it is pretty short. So, I guess I have to give it a try..

<!-- you can put the javascript anywhere in the page.. this is not one of those has to be on the head, better yet put it just above the body closing tag -->
<script type="text/javascript">
function submit_thisform()
{
    document.forms["this_form"].submit();
}
</script>

<!-- here is our form with the id = this_form -->
<form id="this_form" action="" method="post">
<input type="text" name="input1" value=""/>
<input type="text" name="input2" value=""/>

</form>
<a href="javascript: submit_thisform()" >Submit This Form </a>

there you have it :)..

veedeoo 474 Junior Poster Featured Poster

Hi,

It is getting really late in my time zone, that I really need to hit the bunk. Anyways, here is the general form for xpath in php..

I am not going to explain it in great detail, but the whole idea is well presented.

<?php
$xml = simplexml_load_file("../category.xml");

$cat_name = $_GET['category'];

## uncomment $cat_name below to test

//$cat_name = "Civil Works";

$result = $xml->xpath("category[subject='".$cat_name."']/name");

foreach($result as $name){

## echo the name of the matched
echo $name."<br/>";
}
?>

If run the script above, it should give you "Engineering" as a match from the nodes. Just expand the script above to your requirements.

veedeoo 474 Junior Poster Featured Poster

Hi,

It all depends on server configuration. You will need to find out these configurations by using the codes below.

Save as anyfileYoulike.php

<?php phpinfo(); ?>

Upload to your server and direct your browser to this file. Look for the value of Server API . If your server says CGI or FAST CGI, then you need to make those entries on php.ini file. Meaning, you can create a new file and name it as php.ini, and then upload it to your server. It could be either in the same level of the directory needing the increase in max_filesize or above it.

Here is the content of your php.ini file

upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 500
max_input_time = 500

If your server API says, Apache 2.0 Handler , apache module or anything about apache, then your .htaccess file should look like this

php_value upload_max_filesize 50M
php_value post_max_size 50M
php_value max_execution_time 500
php_value max_input_time 500

Remember to check what is on your phpinfo() first.. normally your upload_max_filesize would show 8M and not 8Mb...

WARNING! You CANNOT use BOTH.. ONLY ONE mUST be selected.. CGI or Apache...

R.Manojkumar commented: Thank your very much, problem solved brother +0
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

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

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

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

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

@rajan,

Make sure all of your form processors throughout your site is either $_POST or $_GET, and NOT $_REQUEST for any uploader script. You may want to check and make sure allow_url_include is not set to ON. If you set this to ON, because of any scrapers or any parser script requiring it, use cURL then feed the cURL output to the parser.

I really don't want to show example how its done, because it will give idea to curious people on hacking, and the next thing we know we ended up with 100 more hacking wannabees.

The second probable cause might have been coming from the sites you have visited lately and the use of filezilla ftp program. The deal here is the trojan grabs Application Data\FileZilla\sitemanager.xml file and then use whatever ftp credentials can be found in there to access your site. I helped many people 2 years ago who were victimized by this method.


The third and the most common mistakes is the form input filtering. Most upload script were written and deployed unguarded..for example, some of them don't even have any file extensions filtering mechanism, which allows the uploader to upload any files they want that includes php files that can be executed once the suspected hackers knows the location of uploaded files. Hackers can easily browse your form source codes, and then attempt to do a few remote uploads from their server.. they would try to upload php files …

madCoder commented: Useful comments about security breaches. +5
veedeoo 474 Junior Poster Featured Poster

@ amitgmail,

Yes, you can save the thumbs if you want. There are two options in doing this.

1. You can use imagecreatefromjpeg. This method requires the allow_url_fopen must be ON in your php.ini file. The consequences of using this method is somewhat greater exposure to security holes if not use properly. I will not discuss the security vulnerability here about the url_fopen, because it will fill up this page. You can search url_fopen. This topic has been discussed in great detail in php security consortium. Anyone with proper knowledge of how to take advantage of this vulnerability can easily transfer malicious file on your server. Meaning, once it is transferred they can execute their codes.

Here is how you will save the screenshots using the first option above..Let's use my example codes provided on the previous page of this thread.

<?php
## define your url

$url = "http://www.daniweb.com/web-development/php/threads/256243";

## let's change the codes
## define the image url just for the purpose of displaying it on the page.
$img_url = '<img src="http://open.thumbshots.org/image.aspx?url='.$url.'" width = "150" height = "150" />';

## define the location of the image we are going to save.
$img_url1 = 'http://open.thumbshots.org/image.aspx?url='.$url;
## let's show the screenshot
echo $img_url;

## define the destination directory of the saved screenshot
## by the way I would like itemized everything here instead of writing them in condense form
## so that people who needs it,  will easily understand these things.
## …
veedeoo 474 Junior Poster Featured Poster

@khialbadshah

You mean a BLOB? right? The cons outweighs the pros with this approach. Are sure you still want to go ahead? You will be exerting more memory than having the images stored in the directory (the conventional way). This method normally applies to images of high value copyrighted images.

cwarn23 commented: Good point +12
veedeoo 474 Junior Poster Featured Poster

Hi,

I just borrowed this from someone...please see the script's credit on top. This might be more than what you need..if it just table names that you want, then just remove the bottom part of the script.

<?php
/****************
* File: displaytables.php
* Date: 1.13.2009
* Author: design1online.com
* Purpose: display all table structure for a specific database
****************/

//connection variables

$host = "localhost";
$database = "database";
$user = "user";
$pass = "password";

//connection to the database
mysql_connect($host, $user, $pass)
or die ('cannot connect to the database:' . mysql_error());

//select the database
mysql_select_db($database)
or die ('cannot select database:' . mysql_error());

//loop to show all the tables and fields
$loop = mysql_query("SHOW tables FROM $database")
or die ('cannot select tables');

while($row = mysql_fetch_array($loop))
{

echo "
<table cellpadding=2 cellspacing=2 border=0 width=75%>
<tr bgcolor=#666666>
<td colspan=5><center><b><font color=#FFFFFF>” . $row[0] . “</font></center></td>
</tr>
<tr>
<td>Field</td><td>Type</td><td>Key</td><td>Default</td><td>Extra</td>
</tr>";

$i = 0;

$loop2 = mysql_query("SHOW columns FROM " . $row[0])
or die ('cannot select table fields');

while ($row2 = mysql_fetch_array($loop2))
{
echo "<tr ";
if ($i % 2 == 0)
echo "bgcolor=#CCCCCC";
echo "><td>". $row2[0] . "</td><td>". $row2[1] . "</td><td>" . $row2[2] . "</td><td>" . $row2[3] . "</td><td>" . $row2[4] . "</td></tr>";
$i++;
}
echo "</table><br/><br/>";

}
?>
veedeoo 474 Junior Poster Featured Poster

i just want to add, if for some reason you need to know the count of media with specific extensions, then following codes can be use.

$flvcount = count(glob("".$video_loc. "*.flv"));
$mp4count = count(glob("".$video_loc. "*.mp4"));
echo $flvcount; 
echo $mp4count;

Just echo $flvcount to display how many flv inside the directory media.

Joe_hoskins commented: Very well written respnses and they work very well +0