@evanburry,
Try changing this part of you codes
$src = 'images/outofstock.gif';
To this
echo 'images/outofstock.gif';
@evanburry,
Try changing this part of you codes
$src = 'images/outofstock.gif';
To this
echo 'images/outofstock.gif';
Hi,
First we need to see if the ffmpeg is outputting an error. This is very important, because we don't know what are the missing parameters if there are any.
1. Make sure the directory is CHMOD to 0755 or 755 or 0777 or 777 depending on your server settings.
2. Let's ignore the flvtool2 function first, and work on the ffmpeg diagnostic before anything else.
3. Copy codes below and run it on your server.
<?php
## written by PoorBoy from veedeoo.com
## or veedeoo Junior Poster in Training from daniweb.com
## define ffmpeg location
$ffmpeg_loc = "/usr/bin/ffmpeg";
## define location of video to be converted to flv and some other settings
$input = "upload_v/veer.avi";
$a_freq = "44100";
$a_br = "64";
$v_br = "600";
$v_fr = "30";
$out_flv = "upload_v/veer.flv";
$encodeVideo = ($ffmpeg_loc." -i ".$input." -ar ".$a_feq." -ab ".$a_br."k -b ".$v_br."k -r ".$v_fr." -ac 2 -f flv -y -s 640x420 ".$out_flv);
## now we need to fire up the $encodeVideo through exec command..
## while the ffmpeg is being executed, we need to trap any errors it may have.
exec($encodeVideo." 2>&1", $res, $err);
$errorlog = '' ;
foreach ($res as $errodata) {
$erorlog .= $errodata."<br>" ;
}
## you can echo the error if you want, by uncommenting the code below
//echo $errorlog;
## or you can write it as an html page for you view on the browser.
$errordatapath = "upload_v/erroroutput.html" ;
$file = fopen($errordatapath, "w") ;
fwrite($file, $erorlog) ;
fclose($file) ;
?>
Run …
Ardav is right, if javascript is off then user is trapped..
you can still use the same codes as you were, but you will have to rotate your codes.. like this
Remove the php closing tag below line 47, and then rearrange your codes as shown below.
// Get the data:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);
$_SESSION['email'] = $_POST['email'];
//wait at least 1 second and then fire the header location
sleep(1);
header('Location:welcome.php');
The problem with the above is that if 1 second is not enough time to wait for the $row result to comeback, then it has to be increased to at least 2. Users are impatient to wait even a fraction of a second in front of a blank page. While the javascript, allows the browser to take over after the $row is returned by the mysql server. Once the browser is on the welcome.php, the server takes over again to parse the content.
This is common problem if you are hosted by c__tex or some other hosting servers having the same setting as C__tex or h__tV where the mysql server is slow to respond, but the server where the PHP codes resides already parse your header location command. Often times, in a hosting like this you would get something like this "mysql server has gone away", or something in this regard. Believe me, I spent a good months exchanging nasty messages with c__tex support, but to no avail. So, I came out with the javascript …
oops, thanks for clearing that out. :)
reference change log.. >> http://code.google.com/p/smarty-php/source/browse/trunk/distribution/change_log.txt
And >> Auto literal http://www.smarty.net/docs/en/variable.auto.literal.tpl
Hi,
What he was referring you was these codes.
<?php
define('YOUR_APP_ID', 'YOUR APP ID');
//uses the PHP SDK. Download from https://github.com/facebook/php-sdk
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => YOUR_APP_ID,
'secret' => 'YOUR APP SECRET',
));
$userId = $facebook->getUser();
?>
<html>
<body>
<?php if ($userId) {
$userInfo = $facebook->api('/' + $userId); ?>
Welcome <?= $userInfo['name'] ?>
<?php } else { ?>
<div id="fb-root"></div>
<fb:login-button></fb:login-button>
<?php } ?>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?= YOUR_APP_ID ?>',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
</body>
</html>
First, you need to register your app ID in facebook site, and then download this file here https://github.com/facebook/php-sdk.
Second, if you have not program anything, maybe this is the right time to practice on something a lot smaller. Pretty soon, you maybe wanting to do it with twitter oauth, where the process will be more tedious than facebook.
Third, just try to write something so that people can guide you, but they will not write the codes for you. However, if you really don't know where to start, try reading and downloading the script from this site http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/ .
Fourth, try to understand how the script works. As you become familiar with the script, your confidence will …
This pretty much falls into the category of no can do, but you can try reading some trick on http://klewos.wordpress.com/2010/04/16/using-php-to-fill-a-word-document-quick-tip/ . Just ignore the codeigniter part, if it does not apply to your situation. The author's solution looks promising.
Hi,
Try this, modify your codes by adding the php closing tag just below line 47, and then in your php codes find
// Get the data:
header('Location:welcome.php');
change it to this
// Get the data:
//header('Location:welcome.php');
$welcomepage = "welcome.php";
echo '<script language="javascript" type="text/javascript">
window.location.href="'.$welcomepage.'";
</script>';
As long as it is within the if condition, it should work I think..
Hi,
Thanks for clearing that out. :) I was only joking of course. :).
To print the current page where the browser is on, we need javascript function something like window.print()
So, my example would be like this..
<?php
echo "Hello I am written by way of php echo function, but I will definitely get printed by way of javascript function";
?>
<!-- we do it by form -->
<form>
<input type="button" value="Print Me" onClick="window.print()" />
</form>
<br/>
<!-- or do it by text link -->
<a href="#" onClick="window.print()"/>Print Me</a><br/>
and you expect this echo "<a target='_blank' href=$dir>$name</a> <br>"; to deliver your audience the video or the audio?
Shouldn't it be like this?
echo '<a target="_blank" href="'.$dir.$name.'">'.$name.'</a> <br>';
How about the file extension? Is it included in your $name? If not, it should be wiser to find the extension of the file $dir.$name first and then assign the extension to $ext. so that the codes will be
echo '<a target="_blank" href="'.$dir.$name.$ext.'">'.$name.'</a> <br>';
I am assuming here that $dir = "someDirectory/"; and $name = "somefile.whateverext";
If you want the video to play on the page, then you should have a way of delivering the $name.$ext to the next page, so that it will be loaded on the player. The above codes, just gives the browser to download the file and not to play it.
There are so many ways in passing the video info. to the play page.. In fact, the most common is either by $_GET, or by session like in
$_SESSION = $name.$ext; whatever you choose, it has to have the $dir.$name.$ext because player can be different for audio and video.
@nguoixanh,
Don't be confused with it. It is just a comparison operator. What the thing meant is that IF total_pages is LESS THAN or EQUAL to scroll_pages, THEN do something.
What you should have paid attention closely, is on how the script come up with this..
$this->$total_pages and $this -> scroll_pages, because that's the one that will prime yourself in OOP.
Something like this..
$this -> scroll_pages = $scroll_pages;
$this -> total_pages = $total_pages;
Without using the class pages, you can also practice using those operators by just practicing in something simple like..
<?php
$scroll_pages = 5;
$total_pages = 10;
## let's practice something similar to the page class above.
## normally in class you would start as $whatever = new page(); $whatever->page_link();, and the function page_link will get executed or evaluated..
if($total_pages <= $scroll_pages){
echo "Total pages is less than or equal to Scroll pages";
}
else{
## if you run this script, it should print Total pages is greater than Scroll pages on your screen
echo "Total pages is greater than Scroll pages";
}
?>
Hi,
I don't intend to sound like as if I am really dumb or stupid, I mean nothing like that :). You mean "print" as in "echo" in php? Or print as executing the viewer's printer attached to its desktop?
Hi,
Wow, how old is your server? :). I am definitely sure, it must be older than me, because my dad was writing program in CGI because that's the only language of choice, before I was born :).
Anyways, if that is what you want.. you can use microsoft frontpage. The reason I am recommending this because it has an option for you to make thumbnails of your bigger photos or images. That's all I can think of. Or, you can try posting this question at the javascript section of Daniweb. Like php, javascript can work on photogallery and maybe with better results.
you may also fix your comment tag on line 480 /* and on line 492 */. The first is within html tags, while the second is within the php tags.
Another concern I have, what is the smarty version your script is currently using? The reason I am asking, because {literal} is no longer supported by the latest version of smarty ..
ok, sorry for the wait. To parse any website you want to throw at it all you need to do is use the codes as shown at source forge.
Please allow me to focus on your question above, this is how I would parse any websites. I would use object oriented..
Save this as parsethis.php
<div class="header">
<div class="container">
<ul id="nav">
<li><a id="home" href="http://thinkclay.com" class="selected" title="Return to the home page">Return to home</a>
</li>
<li><a id="about" href="http://thinkclay.com/about" title="Read more about Clay McIlrath">About Clay McIlrath</a>
</li>
<li><a id="design" href="http://thinkclay.com/graphic-design" title="View my Graphic Design Portfolio">Web Design Portfolio</a>
</li>
<li><a id="development" href="http://thinkclay.com/web-development" title="View my Web Development Portfolio">Web Development Portfolio</a>
</li>
<li><a id="photography" href="http://thinkclay.com/photography" title="View my Photography Portfolio">Photography Portfolio</a></li>
<li><a id="wallpaper" href="http://thinkclay.com/desktop-wallpapers" title="Download free desktop wallpapers">Free Desktop Wallpapers</a></li>
<li><a id="wordpress" href="http://thinkclay.com/wordpress" title="Download free wordpress themes">Free Wordpress Themes</a></li>
</ul>
<div style="clear:both;"></div>
<p>My name is Clayton McIlrath and I am an entrepreneur currently living in CO. I personally enjoy the process of learning, exploring, and doing all things creative as well as sharing my experiences with others. Being an entrepreneur and <a
href="http://bychosen.com">business owner</a>, I hope that my experiences may help someone else start their own venture and find success and freedom as I have! Feel free to <a href="http://bychosen.com/contact">contact me</a> anytime for questions or opportunities.</p> <a class="close" href="#close" title="Close the Cloud"><img src="http://thinkclay.com/wp-content/themes/thinkclay_v2/images/close.png" alt="close" /></a>
</div>
Save this as your parser.php
<?php
require_once 'simplehtmldom/simple_html_dom.php';
$html …
Hi,
Please hold on to this topic, and I will show how to scrape that thing down to its bone. I am in the middle of something really important.
I spent a little more than 6 months on learning how to bake the Cake, because it was the hype in our family dining table. Four of my older brothers are all programmers working for the big Companies here in California the G, PP, and the eB. Then all of the sudden that mood had changed and everyone are going for the Zend framework. I tried to learned it, but it is taking most of my time just to get familiarize with the framework's lingo.
After learning some of the few tricks, I came to realize that what I have learned does not even apply to what I am trying to make. It is just like putting a piece of pitted olive in a 10 quart can. Big framework and small application don't matched pretty well. Learning frameworks will help a lot if you will be applying for jobs, and most importantly having the Zend certificate can give a better chance of being hired for the job.
After many sleepless nights learning these frameworks, I finally settled in for much simpler approach. I am currently using NetBeans IDE an integrated tools for PHP with smarty plugins, and a reliable msyql class. That's should suffice to whatever what I have to invent script wise :).
@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 …
Just a suggestion, not even sure if I am understanding your question pretty well.
Make a language directory..and in this directory assigned the language files for pages..you can break them as many file as you want.
Then this
$text='成人業余高中中国中成人玩具的人二千七百成人業余高中成人業余高中零一就像小炸弹,不二流子小心就会爆炸。 虽然他们的样子看起来很平和,但阿巴多是心里藏二流子着很大的攻击性。几十年二千七百零一前毛成人玩具泽东就利用了这一点去建立他心目中的中国,但也是因为这一点很多人在1949年至1977年间失去了生命。攻击性其实是一种很可怕的武器,没人控制得了。一旦失控就不容易停止,要等到人们的情绪慢慢平静下来 。';
assign to something related to the its use.
$lang['this_text'] = '成人業余高中中国中成人玩具的人二千七百成人業余高中成人業余高中零一就像小炸弹,不二流子小心就会爆炸。 虽然他们的样子看起来很平和,但阿巴多是心里藏二流子着很大的攻击性。几十年二千七百零一前毛成人玩具泽东就利用了这一点去建立他心目中的中国,但也是因为这一点很多人在1949年至1977年间失去了生命。攻击性其实是一种很可怕的武器,没人控制得了。一旦失控就不容易停止,要等到人们的情绪慢慢平静下来 。';
save the above to your language file..and then just include the language file to your php document needing it and then just call it like this..
$text = $lang;
By doing this, the page don't have to wait for the annotations.
I think this
$result = mysql_query("SELECT * FROM post_categories");
while ($row = mysql_fetch_array($result)){
echo $row['Name'];
}
Will not stop outputting, while $row = mysql_fetch_array($result)) if still equal to be true.
And this one will only output one
$result = mysql_query("SELECT * FROM post_categories");
$row = mysql_fetch_array($result)
echo $row; //because of this
However, this will output all of them also
$result = mysql_query("SELECT * FROM post_categories");
print_r(mysql_fetch_array($result));
Let me just add, that in case the $x, $y, and $z are given the way they are laid out on your codes above, then this will calculate the same result. The only time you will have to probably assign a new value for $x, $y, and $z in
$newformula = str_replace($x, $x, $formula);
$newformula1 = str_replace($y, $y, $newformula);
$newformula2 = str_replace($z, $z, $newformula);
if the values for $x, $y, and $z are not assigned, or there will be new value or values that the script needs to be included. Otherwise the codes below will suffice.
<?php
$x = .0832;
$y = .0673;
$z = 1.5;
$formula = $x -(($x-$y)*($z-1.0));
echo '</br>'.$formula;
?>
Hi,
Just my humble opinion..If you want your formula to do the calculation, then don't treat them as a text string.. For example $x = 1; echo $x, will give us 1 which is treated as integer rather a text string, and so forth.
Try this
<?php
$x = .0832;
$y = .0673;
$z = 1.5;
$formula = $x -(($x-$y)*($z-1.0));
$newformula = str_replace($x, $x, $formula);
$newformula = str_replace($y, $y, $newformula);
$newformula = str_replace($z, $z, $newformula);
echo '</br>'.$newformula;
?>
The above codes should give you a result of 0.07525 if that's the answer you want to be calculated. Or do you want the derivatives of the $newformula? e.g. x² + 2x − 8 ->2x + 2 = 0 or => (x + 4)(x − 2).
Hi,
Here is the simple example for both of the responses above.
<?php
$first_ar = array('one','two','three','four','five','six','seven');
$second_ar = array('two','ten','eleven','five','twelve','nine','three');
$result = array_intersect($first_ar, $second_ar);
foreach($result as $something){
echo "Matched: ".$something."<br/>";
}
?>
@ 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.
## …
@ unknown_rocks,
read my response on this thread http://www.daniweb.com/web-development/php/threads/389852 .
That should give you some idea on how to store and retrieve images from database.
Hi,
Try this..
r.php
<?php
$rule['ab'] = "afd";
$rule['vf'] = "ghe";
$rule['as'] = "rtg";
## something has to carry the rule out of this
$rules[] = $rule;
?>
and on the other file
<?php
include_once("r.php");
## it is costly, memory wise, but this is the only thing I could think of right now
## to get the rule printed out.
foreach($rules as $show_rule){
echo $show_rule['as'];
}
?>
@ rse,
Try using this simple example. Maybe, it will help you locate the problems on your codes.
<?php
## we can do it the simpler way, and if it is working properly, we can add more into
## it to make it fancier. For now it is always nice to start in simpler form.
## define your database connection credentials
mysql_connect( $db_host, $db_user, $db_password ) or die(mysql_error());
mysql_select_db( $db_database ) or die(mysql_error());
## make sure that 'YES' can be found as shown on in the country rows under active column
$countries = mysql_query("SELECT * country FROM countries WHERE active='YES'")
or die(mysql_error());
## lets loop the crap out of the toid
while($country = mysql_fetch_array( $countries ))
{
## I am assuming here that your countries table has the following columns
## id | name | active
## 100 | Bundagle | YES
## 200 | Somewhere | YES
$country_id = $country['id'];
$country_name = $country['name'];
## Now, let's assign the country inside the option form tags.
## the country named bundagle and somewhere should be now inside the option tags.
$country_block .= '<OPTION value="'.$country_id.'">'.$country_name.'</OPTION>';
} ## end while loop
## now lets show the result from the table countries.
?>
<!-- notice the country_block is outside the crap, of which will give you more freedom to modify the html tags without so much clutter-->
<label for="country">Country</label>
<select name="countryID"><?php echo $country_block; ?></select>
@rse
fix this first, and then repost your codes. Unless, you define it somewhere it would make sense, but right now, I don't see it making any sense at all. Can you please elaborate or shades some light on where this line of codes coming from??
$HTML['country_options_escape']=$nt[country];
The only time I remember writing such arrangement was for smarty array, but not like yours.
this is valid
//while begins here
$something = (string) $so;
$something = (string) $so;
$assignItHere[] = $something;
//end of while loop
return $assignItHere;
Hi,
This maybe the simplest example I could ever think of.. Say, your above xml file is called test.xml, then you can easily parse the email XX and the name: XX from it by using these few lines of php codes.
<?php
## type in your xml file location
$xml ='test.xml';
## remove @ to debug
$xml = @simplexml_load_file($xml);
foreach($xml as $items)
{
echo "Name: ".$items->value[2]." Email: ".$items->value[4]."<br/>";
}
?>
We can also assign them into variables as you wish, as shown in my example below..
$name = $items->value[2];
$email = $items->value[4];
You may want to consider setting up some check points to see if the xml file does exist, like so
if (file_exists('test.xml')) {
$xml = @simplexml_load_file($xml);
}
## instruct the script what to do if xml file does not exist.
else{
## it's your call here
}
Hi,
Since, you have not provided any codes to begin with, why not try the simulator first and then once you are familiar with how the things are processed, you can write similar script that applies to your situation.
I am not sure if there is something you can learn from this, but for whatever it's worth. here you go,
save as whatever.php, upload to your server.. tweak it as much as you can, and then attempt to use the actual query from database.
<?php
echo '<table cellpadding="4" cellspacing="4"><tr><td><form method="post" action=""><select name="option1">';
## strangely enough lets make $x equal to your query, duh!
$x=1;
## below represents the query results from db
## we have 4 different items to choose from.
## each value of $x has a matching value on $y of which another group of query based on the selected value of $x
while($x<=4)
{
echo "<option> " . $x . "</option>";
$x++;
}
echo '</select><input type="submit" name="option_one" value="Query"></form></td>';
if($_POST['option_one']){
echo '<td valign="top"> Result of Query One--> </td>';
## first we need to provide the result based on the selected option above
## just to simulate the result lets put another form here
echo '<td><form method="post" action=""><select name="result1">';
$y = $_POST['option1'];
## portion below is the modeled interpretation of a query from the database, such as
## SELECT" FROM something WHERE y ='" . $x . "' LIMIT 1
## now we provide values for selected $x above
## Array below represents columns in mysql …
Try searching for php Iteration or implementing IteratorAggregate in php. That should do it with switch function.
Hi,
Try this,
<?php
## define your url
## change comments tags to the proper syntax as recommended by php.net.
## unless you are a developer, you can give reason why these ## are valid.
## even if the rest of the world would argue that it is wrong,
## it does not mean it is not valid.
$url = "http://www.daniweb.com/web-development/php/threads/256243";
echo '<img src="http://open.thumbshots.org/image.aspx?url='.$url.'" width = "150" height = "150" />';
?>
If my guess is right, we can use a Dot notation array access class. In addition, an array can be nested within an array deeper than what we can normally do without the dot notation class.
Then we can implement the loop the way twig and smarty implement their loops.
Hi,
Copy codes and read instructions below.. For security reason, DO NOT post the url of your AnyNameYouWant.php
<?php phpinfo(); ?>
copy,paste on notepad, save as AnyNameYouWant.php, upload to your server, direct your browser to this file. e.g. YourDomainDotCom/AnyNameYouWant.php .
After performing the above recommendations, please post the following values of what you see on your YourDomainDotCom/AnyNameYouWant.php.
I need values for the following from your server configurations.
PHP Version anything below 5.2.7 is less problematic. Due to some issues not related to your questions, but will post my answer if addressed.
Server API CGI, FAST CGI or Apache module?
max_execution_time normally, a new hosting account gets about 30, and you need more than that. At least 1000 to 2000 is ideal.
post_max_size The value of this must be equal to the value of upload_max_filesize. In some server settings this value is preset to about 8M. Again 8M is not enough to accept file uploads for much bigger files.
upload_max_filesize The values here must be more than what you are trying to upload. Default server settings as handed to you by your hosting provider is set to 2M or 2MB. Depending on your server setting CGI or Apache module, we can do some adjustments to meet your needs.
Hi,
I can show you how to do a pseudostreaming for flv videos, and a quick start on MP4/h264 just like the one you see on youtube. However, before I can do that you need to change your player preferences . It has to be jwplayer or flowplayer. On top of the player change, you will need to have flvtool2,ffmpeg, and ffmpeg php installed on your server, OR at least have the means to inject metadata on your videos prior to uploading them in your server.
The quick start for the mp4/h264 videos requires an mp4box installed on your server, and the ffmpeg installation must be compiled with the x264 if you are to encode videos in the server. Otherwise, some GUI video encoders and MOOV ATOM relocators will just do as fine as what I have already mentioned above.
I wrote many scripts for video applications, including bandwidth calculators, remote server transfer to and fro, video server load balancer, and remote server streamers by way of HTTP and RTMP video streaming, and the script that went flop flv VOD..that did not make the cut at all ;).
Can you please confirm if the password in your database was posted as md5 hash? You can check it on your MyPhpAdmin..locate the member in questions, and then check the password column. In the password column the password should look something like this 9cafeef08db2dd477098a0293e71f90a, or you can check the form processor on your registration page if the password made by the new user is being posted as md5..for example $password = md5($_POST).
If it was not or your registration form processor does not convert the password to md5, then do what prvnkmr194 is suggesting.
Hi,
you can read more about session time out warning by way of jquery and php here. I don't own the site NOR I have affiliation with them. I must clarify that, so that the link don't get snipped ..I learned a lot of things in this forum in a very short period of time...Another interesting life experiences I guess. :)
Hi,
Just my guess, by glancing at your codes, aren't you supposed to post this name="app" to have some value for your second query?
Something like this
$whatever = $_POST;
and then on your query, it can be like this
$query="select * from $stuff where appname='$whatever'";
Notice I did not use $name, because you already used it on the earlier part of your script. I am afraid, I might just caused a naming collision. :).
Just a humble suggestion...for a tutorial such as this..The coding standard must follow the Zend Framework PHP Coding Standard. By doing so, the new learners or readers of the tutorial will be exposed to the proper coding standard and convention.
Please allow me quote one of the best quote I have read, when I was active in Zend community. Here I quote
One of the joys of PHP is that it’s very flexible, and that flexibility extends to how you layout your code. As long as you observe the basic rules, such as terminating each command with a semicolon and wrapping code blocks in curly braces, you can format your code however you like, because PHP ignores whitespace inside code blocks. As a result, many different styles of coding have sprung up. There’s nothing inherently right or wrong with any of them. As long as the code is readable—and works—that’s all that really matters.
But then again, there is a solid opposition to opening your php codes in shorthand..the coding style conventions states that
1. Always use the full opening PHP tag (<?php).
2. Omit the closing PHP tag (?>) in files that contain only PHP code. The closing PHP tag is optional, provided nothing else (e.g., HTML) comes after the PHP code. Leaving out the closing tag has the advantage of preventing unwanted whitespace triggering the “headers already sent” error when using includes(http://docs.php.net/manual/en/language.basic-syntax.instructionseparation.php).
3. Indent code four spaces (I always followed this, but …
Hi,
Without any intend of disrespect, session_register is deprecated in php version 5.3.x . Plus it is a dangerous thing to do security wise. http://php.net/manual/en/function.session-register.php
Just in case some people are trap into using this php function, because their sessions are stack within an array.. The simple solution is put the sessions in an array as shown below.
$session_inarray = array($user,$info1,$info2, $info3, $some_moreinfo_here);
## assign the above into session
$_SESSION = $session_inarray;
## to get the values in the session onto the other page, we simply do it
$user = $_SESSION[0]; $info1 = $_SESSION[1];...and so forth.
My post may not directly answer your questions, but it addressed one of the most critical issues on your script.
Hi martymaven,
Can we please see at least a sample of the codes that you have..
e.g. $query =("SELECT * FROM employee WHERE id = '".$some_id."' LIMIT 1") ;
Something like that or your employee table structure such as
id | name | department | position | rate | supervisor | personal info 1 | personal info. 2 |
something very similar to the above can truly get people here going at it :).
Hi Matt,
You may want to read this first http://php.net/manual/en/features.file-upload.php.
The keywords for your question are if (empty($_FILES) && empty($_POST) && isset($_SERVER)
Please read the above link and try to integrate some of the methods they used. If still does not work for you, let us know and I will write the codes for you.
Im not sure if it matters since it would appear to the browser like it was originally their, but I have added this script as an include on this page below another include I would like to remove once this script works.
oh no...:), the script responsible for showing your content must be the same script counting the row and doing the pagination. Try looking at the script responsible for showing your content on your page. You can probably insert the pagination codes there. I am pretty sure it will be a lot easier than including a new one to do the pagination for the other.
Sorry about that. It should read
$total_results = mysql_fetch_row($query);
I think you are missing the numerical rows..
Try this
## we need to get the count of affected rows by your query
## putting a LIMIT will obviously limit your result and may not have anything left ## for the script to paginate.
$sql = "SELECT COUNT(*) from inthemix WHERE inthemixid = $inthemixid ORDER by inthemixid desc";
$query = mysql_query($sql,$db);
## we get the result count
$total_results = mysql_num_row($query);
## the numerical rows
$num_rows = $total_results[0];
## define the number of items on the page
$limit = "4"; //limit of archived results per page.
## calculate how many pages the script has to make
$total_pages = ceil($num_rows / $limit); //total number of pages
Try it first..the rule of thumb are like these
1. Count the rows of the items you want to paginate.
2. Once we have gotten the number of rows, divide that number by the items we want to be showing on the page.
3. Give the current page a number designation e.g. 1
4. Calculate the offset. Such as $offset = ($currentpage - 1) * $rowsperpage;
5. Send your database query to fetch the actual items in the database using the criterion of the count as LIMIT.
6. Sit back, relax, analyze, and if it doesn't work go back and do it all over again.
@khialbadshah,
ok here it is I tested this and modify the script a little. This may not be suitable for production site without proper evaluation of the script's security vulnerability.
here we go let's have some fun it is Sunday night, so who cares :)
Step One: go to this site , and download the attached file, unzipped or untar..
Step Two: direct your browser to your phpMyAdmin, create a new database, name this database as test.
Import the following codes to the newly created "test" database above.
CREATE TABLE IF NOT EXISTS `images` (
`id` int(11) NOT NULL auto_increment,
`image` blob NOT NULL,
`title` varchar(255) collate latin1_general_ci default NULL,
PRIMARY KEY (`id`)
)
Whatever you do or modified, this is the most important [B]`image` blob NOT NULL,[/B] . It has to be like that and nothing else.
Step Three: With your favorite php editor, open the insert.php. Update the database credentials to your database credentials.
$username = "root";
$password = "bananaman";
$host = "localhost";
$database = "test";
, and then just mid-part of the page, find these codes about line 33 down to line 40
// Create the query and insert
// into our database.
$query = "INSERT INTO tbl_images ";
$query .= "(image) VALUES ('$data')";
$results = mysql_query($query, $link);// Print results
print "Thank you, your file has been uploaded.";
change the above codes to these
// Create the query and insert …
@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.
This is just an update just in case someone is following my post above. If you get an error similar to this
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /……../ on line (..)
The temptation is great to turn the allow_url_include to on. DON'T DO IT for security reason. You only turn this thing to on when there is no other way.
The solution is this..lets create another funtion and just add it above line 6
function get_ytube($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$xml = @simplexml_load_string($output);
return $xml;
}
and then on line 35 $yt_xml = simplexml_load_file($yt_videoq);
change it to
$yt_xml = get_ytube($yt_videoq);
That should work without putting your server into so much risks....
Hi,
This may not be the direct answer to the question. However, this is how much you have to write just to send query to youtube using their API. I wrote different types and flavors of this.
It is my day off today and I am just lazy to actually write a more complicated example accessing youtube for upload from a remote server. It can be done.
You can also do a player targeting without refreshing a page as shown here in my old experiment for a client.
<?php
## script was written by PoorBoy from veedeoo.com/forum
## no warranty of any kind, so please don't even bother asking
## Can help during my freetime, but still no guarantee.
#### First we need a function fot get youtube video id
function getPatternFromUrl($url)
{
$url = $url.'&';
$pattern = '/v=(.+?)&+/';
preg_match($pattern, $url, $matches);
//echo $matches[1]; die;
return ($matches[1]);
}
## function above we will use later
## define our query for youtube
$query = "ac+dc";
## define the order by published or viewCount
## viewCount is case sensitive
## you can also do the publisher or author only, read the youtube API about this
$order ="published";
## define start index. Youtube allows you query 50 videos per page, but no more that 1000 per $query
## lets define start index to be 1 . Depending on the result of the query this should return at least 1000/50 = number of pages
$s_page = 1; …
To some people who maybe wondering why, evstevemd:D suggested to use $_POST or $_GET. I totally agree with him 1000%, please experiment with simple codes below save it as formtest.php run it on your xampp. Warning! this if($_POST) maybe improper in php.
<?php
if($_POST){
## extract ($_REQUEST); ## should use this if more data are coming from the form
$name = $_REQUEST['name'];
$last = $_REQUEST['last'];
echo "$name <br/>";
echo "$last <br/>";
}
elseif($_GET){
extract ($_REQUEST);
$name = $_REQUEST['name'];
$last = $_REQUEST['last'];
echo "$name <br/>";
echo "$last <br/>";
}
else{?>
<!-- to demonstrate why $_REQUEST is something to avoid, try changing the method to post, and see what will happen -->
<form method="get" action="formtest.php" />
<input type="text" name = "name" value="enter name here"/>
<br/>
<input type="text" name = "last" value="enter last name here" />
<input type="submit" value="test">
</form>
<?}?>
For the second part, try changing the form method to "post". This example should give us the idea why not use it for applications other than simple non-critical data. Better yet remove the method making it like this method="", and see what will happen again.
@evstevemd,
I don't use $_RESQUEST in anyways NOT EVEN as a last resort.."People" should exclude me :) at all cost..
I am just trying to respond based on the codes that were already written and presented that's all. Besides, it is the programmers choice which function to use, otherwise if he is asking for security advice, then it would be the perfect time to discuss what are the consequences of using $_REQUEST shall bring.