PHP - Reversing The Effect Of This Code
Okay, Earlier on I asked someone if they could show me a shorter way of making letters one higher, Like A becomes B and B becomes C in a string.
I was wondering if using this code: for($i=0, $n=strlen($text); $i<$n; ++$i) { $val = ord($text[$i]); if(($val>=65 && $val<=90) || ($val>=97 && $val<=122)) { $base = ($val<=90) ? 65 : 97; $text[$i] = chr($base + ($val-$base+1)%26); } } I could reverse it's effect and make A become Z and B become A in a string. Thanks in advance! Similar TutorialsThis topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=327102.0 There are two effects that I have seen on website and keep wondering how they have been achieved. The first is when you go on Facebook and you type a link into your status bar. Then Facebook will automatically get some information about that article. The second effect is something I have seen on twitter and other websites. If you scroll down to the bottom of the page it will detect this and then load more content. If anyone could link me to any article or tutorials explain how these effects have been done that would be great. Thanks for any help. Why do I get the following results (specifically the second example)? I thought it would be documented under https://www.php.net/manual/en/language.types.string.php, however, the word "ampersand" doesn't appear. Also, looked at logical operators, but found nothing. Thanks function test(string $string){ printf('%s %s %s 0'.PHP_EOL, gettype($string), $string, $string==0?'==':'!='); } test('123'); test('@123'); test('1@23'); test('123@');Quote
string 123 != 0
Hi, I have this script which does what it is meant to do. I have assigned session_id() to the variable $sid so I can use it when logging in to a users account, however I get this error. How do I get around this? Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively. in Unknown on line 0 As this is going to be installed on many servers, I do not want to have to edit the php.ini file on each one so as not to get this error. Is there an alternative way to assign the session_id() as so $sid = session_id(); so this doesnt happen? Code: [Select] <div id="pageNav"> <div id="sectionLinks"> <a href="admin.php?cmd=manage1&username=admin">Manage</a> <a href="admin.php?cmd=dashboard&username=admin">Dashboard</a> <a href="admin.php?cmd=msgcenter&username=admin">Message Center </a> <a href="admin.php?cmd=manage&username=logins">Logins</a> </div> </div> <div id="content"> <div class="page"> <table width="100%" border="1" align="center"> <td bgcolor="#99FF66"><div align="center"><span class="style3">Login</span></div></td> <td bgcolor="#99FF66"><div align="center"><span class="style3">Name</span></div></td> <td bgcolor="#99FF66"><div align="center"><span class="style3">Registration Date </span></div></td> <td bgcolor="#99FF66"><div align="center"><span class="style3">Approved </span></div></td> <td bgcolor="#99FF66"><div align="center"><span class="style3">Reset Password </span></div></td> <td bgcolor="#99FF66"><div align="center"><span class="style3">Delete</span></div></td> </tr> <?php session_start(); $sid = session_id(); session_register('sid'); include_once("data/mysql.php"); $mysqlPassword = (base64_decode($mysqlpword)); $db = mysql_connect("$localhost", "$mysqlusername", "$mysqlPassword") or die ("Error connecting to database"); mysql_select_db("$dbname", $db) or die ("An error occured when connecting to database"); $result = mysql_query("SELECT * FROM members"); while($row = mysql_fetch_assoc($result)){ echo "<tr><td><a href=templates/members/home.php?username=".$row['username']."&sid=$sid>".$row['username']."</a></td> <td>".$row['firstname']." ".$row['lastname']."</td> <td>".$row['registration_date']."</td> <td><a href=admin.php?cmd=approval&username=".$row['username']."&approved=".$row['approved'].">".$row['approved']."</a></td> <td><a href=templates/members/changepw.php?username=".$row['username']."&sid=$sid>Change Password</a></td> <td><a href=templates/members/delete.php?username=".$row['username']."&sid=$sid>Delete</a></td></tr>"; } ?> </div> </div> </div> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </div> </div> </div> Many Thanks Paul This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=359215.0 I want to link to a movie but I'd like to create an onrollover slideshow effect so that when the image that links to the movie is mouseover, it slowly slideshows each of the 4 images that I specify. Hello all, This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=357878.0 Hi all My code give this: <b>Warning</b>: file_exists(): open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/home/clients/........ I get the tmp folder and check for its existanse and whether it is writeable
$t=sys_get_temp_dir(); Both gives no which is fine, I can process that. I do it to avoid the output above, but I still get that. How should I check for allowed paths? This runs on several systems where I cannot access php.ini or other system stuff.
Hi, I have an old code from 2004 and I would like to update it to use new Session object. That means instead of session_register using the $_SESSION super global variable. The main reason for this change is that wheneve I logged out from the software I get: Warning: Unknown: Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively in Unknown on line 0 Spo I replace my old code: <?php session_name("MySite"); session_start(); reset ($_GET); session_register("ADMIN"); session_register("ADMINNAME"); session_register("MAIL") ; $USERCOOKIE_FOR_TRACKING = array(); //to get all session variables foreach ($_SESSION as $key => $value) { $value=stripslashes(trim($value)); $$key=$value; } ?> with this new code: <?php session_name("MySite"); session_start(); reset ($_GET); $_SESSION['ADMIN']=""; $_SESSION['ADMINNAME']=""; $_SESSION['MAIL']=""; $USERCOOKIE_FOR_TRACKING = array(); //to get all session variables foreach ($_SESSION as $key => $value) { $value=stripslashes(trim($value)); $$key=$value; } ?> BUT now I cannot login to the software any more. looks like I am doing something wrong here. please tell me how do I upgrade my code. Thank you. Ok I am designing a php upload that will take a image file from a form and change the name of the file to the productnumber also recieved from the form. I had it working the otherday now it says Warning: copy() [function.copy]: open_basedir restriction in effect File() is not within the allowed path(s): (/home:/tmp:/usr) addpro.php on line 51. my files are attached.... note that $pnum is the product number gotten from my form and image is the image being uploaded gotten from the form also. The thing is it worked the other day but now it don't is it a change to the server ( I dont run the server) or did I mess up my code since then? I really need a code that will do this two time over once for a small image being put into a folder called small and once for a folder called large both images being uploaded and being changed to $pnum.ext so they will both be displayed when being called out by the product number. but I can work on that after I get this one working. line 51 is $copied = copy($_FILES['image']['tmp_name'], $newname); Hi everybody. I use flash 8 and actionscript 2.0. I am trying to create a small program that needs communication between php / HTML and flash. I have found ( after much frustration and having wasted days on this ) that no matter what - if i make a change to my program and re publish the HTMl AND SWF files after I have deleted the old HTML and swf files , even then when i run the NEW PUBLISHED html / php file, the movie that runs is the old one. I have tried all that I know, like checking paths and stuff to ensure that everything is ok. I am unable to shed the chached old swf file and so the old movie continues to run. Is there any one who has encountered anything like this? Please help me. This is driving me nuts. Thanks loads in anticipation of a reply from the nerds on this ! I have written code so that when something from a MySQL field equals 0, then PHP will take no action, and if the field equals anything else, then 'echo "foo"'. The problem I am having is that when PHP echo's nothing (echo ""), its still creating the effect of a HTML <BR>. Screen shots: 1. When the MySQL table contains something else than 0 (echo "foo"). http://i51.tinypic.com/2n7oxo1.png 2. When the table contains 0 (echo ""). http://i53.tinypic.com/2h5jg4k.png 3. What it should look like if the table were to contain 0 (echo ""). Note that their is no <BR> effect. http://i51.tinypic.com/2jdtaf.png Code: $query = "select sizes from products where id='$id'"; $result = mysql_query($query); $data = mysql_fetch_array($result); if ($data['sizes'] == 0) {echo "";} else {echo "Small - ".$data['sizes'];} Is it possible to make it so if a MySQL field result equals 0, then PHP will not produce the HTML <BR> effect when it echo's nothing (echo "")? Hi, I have some code which displays my blog post in a foreach loop, and I want to add some social sharing code(FB like button, share on Twitter etc.), but the problem is the way I have my code now, creates 3 instances of the sharing buttons, but if you like one post, all three are liked and any thing you do affects all of the blog post. How can I fix this? <?php include ("includes/includes.php"); $blogPosts = GetBlogPosts(); foreach ($blogPosts as $post) { echo "<div class='post'>"; echo "<h2>" . $post->title . "</h2>"; echo "<p class='postnote'>" . $post->post . "</p"; echo "<span class='footer'>Posted By: " . $post->author . "</span>"; echo "<span class='footer'>Posted On: " . $post->datePosted . "</span>"; echo "<span class='footer'>Tags: " . $post->tags . "</span>"; echo ' <div class="addthis_toolbox addthis_default_style "> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a class="addthis_counter addthis_pill_style"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=webguync"></script>'; echo "</div>"; } ?> I have the following code in html: <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "http://VARIABLEVALUE.mysite.com" } //--> </script> <title>Redirecting ...</title> </head> <body onLoad="setTimeout('delayer()', 1000)"> <script type="text/javascript"> var sc_project=71304545; var sc_invisible=1; var sc_security="9c433fretre"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript> <div class="statcounter"><a title="vBulletin statistics" href="http://statcounter.com/vbulletin/" target="_blank"><img class="statcounter" src="http://c.statcounter.com/71304545/0/9c433fretre/1/" alt="vBulletin statistics" ></a></div></noscript> </body> </html> Is a basic html webpage with a timer redirect script and a stascounter code. I know a bit about html and javascript, but almost nothing about php. My question is: How a can convert this html code into a php file, in order to send a variable value using GET Method and display this variable value inside the javascript code where says VARIABLEVALUE. Thanks in adavance for your help. hey gurus, i am a newbie php coder.. i am learning by example. what i am trying to do is write a piece of code which will alter 3 tables (user, bonus_credit, bonus_credit_usage) ---------------------------------------------------------------- the table structure that will be used is as follows: user.bonus_credit user.ID bonus_credit.bonusCode bonus_credit.qty bonus_credit.value bonus_credit_usage.bonusCode bonus_credit_usage.usedBy ---------------------------------------------------------------- so lets say, in bonus_credit i have the following bonusCode = 'facebook' (this is the code they have to type to redeem the bonus qty = '10' ( number of times the bonusCode can be redeemed, but same person can't redeem it more than once) value = '5' (this is the amount of bonus_credit for each qty) Now, I need to write a code that check to see if the code has been redeemed in the bonus_credit_usage table and if the user.ID exists in this table as bonus_code_usage.usedBy, then give an error that its already been used and if it hasn't been used, then subtract 1 from qty, add ID to usedBy and then add the value to the bonus_credit ----------------------- i have started the steps just to create a simple textbox and entering a numeric value to bonus_credit, and that works.. but now i have to use JOIN and IF and ELSE.. which is a little too advanced for me.. so i'd appreciate a guide as i write the code. if(isset($_REQUEST['btnBonus'])) { $bonus_credit = addslashes($_REQUEST['bonusCode']); $query = "update user set bonus_credit=bonus_credit+'".$bonus_credit."' where id='".$_SESSION['SESS_USERID']."'"; echo "<script>window.location='myreferrals.php?msgs=2';</script>"; mysql_query($query) or die(mysql_error()); } Advance thank you. Can you help please. The error..... Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\wamp\www\test_dabase.php on line 24 code. Code: [Select] <?php //database connection. $DB = mysql_connect("localhost","root") or die(mysql_error()); if($DB){ //database name. $DB_NAME="mysql"; //select database and name. $CON=mysql_select_db($DB_NAME,$DB)or die(mysql_error()."\nPlease change database name"); // if connection. }if($CON){ //show tables. $mysql_show="SHOW TABLES"; //select show and show. $mysql_select2="mysql_query(".$mysql_show.") or die(mysql_error())"; } //if allowed to show. if($mysql_select2){ //while it and while($data=mysql_fetch_assoc($mysql_select2)){ //show it. echo $data; } } ?> Hi, I need to insert some code into my current form code which will check to see if a username exist and if so will display an echo message. If it does not exist will post the form (assuming everything else is filled in correctly). I have tried some code in a few places but it doesn't work correctly as I get the username message exist no matter what. I think I am inserting the code into the wrong area, so need assistance as to how to incorporate the username check code. $sql="select * from Profile where username = '$username'; $result = mysql_query( $sql, $conn ) or die( "ERR: SQL 1" ); if(mysql_num_rows($result)!=0) { process form } else { echo "That username already exist!"; } the current code of the form <?PHP //session_start(); require_once "formvalidator.php"; $show_form=true; if (!isset($_POST['Submit'])) { $human_number1 = rand(1, 12); $human_number2 = rand(1, 38); $human_answer = $human_number1 + $human_number2; $_SESSION['check_answer'] = $human_answer; } if(isset($_POST['Submit'])) { if (!isset($_SESSION['check_answer'])) { echo "<p>Error: Answer session not set</p>"; } if($_POST['math'] != $_SESSION['check_answer']) { echo "<p>You did not pass the human check.</p>"; exit(); } $validator = new FormValidator(); $validator->addValidation("FirstName","req","Please fill in FirstName"); $validator->addValidation("LastName","req","Please fill in LastName"); $validator->addValidation("UserName","req","Please fill in UserName"); $validator->addValidation("Password","req","Please fill in a Password"); $validator->addValidation("Password2","req","Please re-enter your password"); $validator->addValidation("Password2","eqelmnt=Password","Your passwords do not match!"); $validator->addValidation("email","email","The input for Email should be a valid email value"); $validator->addValidation("email","req","Please fill in Email"); $validator->addValidation("Zip","req","Please fill in your Zip Code"); $validator->addValidation("Security","req","Please fill in your Security Question"); $validator->addValidation("Security2","req","Please fill in your Security Answer"); if($validator->ValidateForm()) { $con = mysql_connect("localhost","uname","pw") or die('Could not connect: ' . mysql_error()); mysql_select_db("beatthis_beatthis") or die(mysql_error()); $FirstName=mysql_real_escape_string($_POST['FirstName']); //This value has to be the same as in the HTML form file $LastName=mysql_real_escape_string($_POST['LastName']); //This value has to be the same as in the HTML form file $UserName=mysql_real_escape_string($_POST['UserName']); //This value has to be the same as in the HTML form file $Password= md5($_POST['Password']); //This value has to be the same as in the HTML form file $Password2= md5($_POST['Password2']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $Zip=mysql_real_escape_string($_POST['Zip']); //This value has to be the same as in the HTML form file $Birthday=mysql_real_escape_string($_POST['Birthday']); //This value has to be the same as in the HTML form file $Security=mysql_real_escape_string($_POST['Security']); //This value has to be the same as in the HTML form file $Security2=mysql_real_escape_string($_POST['Security2']); //This value has to be the same as in the HTML form file $sql="INSERT INTO Profile (`FirstName`,`LastName`,`Username`,`Password`,`Password2`,`email`,`Zip`,`Birthday`,`Security`,`Security2`) VALUES ('$FirstName','$LastName','$UserName','$Password','$Password2','$email','$Zip','$Birthday','$Security','$Security2')"; //echo $sql; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ mail('email@gmail.com','A profile has been submitted!',$FirstName.' has submitted their profile',$body); echo "<h3>Your profile information has been submitted successfully.</h3>"; } mysql_close($con); $show_form=false; } else { echo "<h3 class='ErrorTitle'>Validation Errors:</h3>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p class='errors'>$inpname : $inp_err</p>\n"; } } } if(true == $show_form) { ?> |