PHP - Trying To Force A Null Value
I'm trying to force a NULL value into the database with a hidden value and I can't seem to get it to work.
Any suggestions? <input type="hidden" name="inactive" value=""/> I also tried here too: $sql="UPDATE product SET inactive='NULL' WHERE id = '$item_id'"; Similar TutorialsI am trying to update the database with isset to set the value of the variable to either null or the value entered by the user. Currently, if no value has been entered null is being set as a string causing the date field to populate with zeros. How do I code it so that it populates or sets the value as null and not as string null?
Here's my code: (yes I know sql injections it's still in development )
<?php Anyone know how to force URL with SSL with www.
<rewrite> <rules> <rule name="Redirect to HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions><add input="{HTTPS}" pattern="^OFF$" /> </conditions> <action type="Redirect" url="https://www.site.com/{R:0}" redirectType="SeeOther" /> </rule> </rules> </rewrite>Please check the sample. Is there a way so when someone loads your website that it forces them to load it in a different browser? Is there any way to have php filter out negitive numbers where it counts it as zero instead? so the math im doing in a string can never go negitive been looking online for a hour cant seem to find anything that does this. i want to make a simple forced lower case form but i got stuck on it
to begin with i want to everything user's write and submit convert to lowercase
am i using the right code? i'm not sure about using preg_match in this situation but i dont know what else to do don't be harsh with me i'm noob <?php if(isset($_GET['user'])&&!empty($_GET['user'])) { $user = $_GET['user']; if (preg_match('$englishUpperAlphabet'//English alphabet Upper case array//',$user)){ $user = mb_strtolower($user); echo $user; } else{ echo 'none'; }} ?> <form action="t.php" action="GET"> name: <input type="text" name="user" > <br> <input type="submit" value="submit" > </form> hello dear php-experts on my notebook an Akoya P 6512 15" AMD Athlon X2 P320, 2,10 GHz, 4 GB that runs OpenSuse 13.1 i want to prepare the new installation of opensuse 13.1 but i cannot boot from a my DVD with the openSuse 13.2 b. my cd with the Gparted i tried out to enter the boot menu with f 2 - and subesquently editing the boot-device f 10 and switching the boot device nothing works - i have no glue what i can do now ? note : i run the following BIOS American Megatrends version 02.61 i need your help now - should i do a bios ubdate or what? many thanks for any and all help I am not a programmer, but I'm a webmaster facing a problem. I have a website and people are hotlinking to my .swf files. I do not want to stop all hotlinking though, instead is what I want to do, and want to know if it's possible to do, is this: Can I get it so that people that hotlink to flash files, get an ad before the flash loads, without editing the "real" .swf? For example: 1. I post the actual .swf file to my site. 2. Then someone embeds a direct link to that .swf file on their site or blog, etc. 3. My server, when serving .swf files realizes when the .swf file isn't coming from my domain. 4. It makes the direct .swf embed be an embed to a wrapper (I think is what it would be called) type of flash file that has an ad and a start button. 5. The real .swf file is loaded on the external domain once the start button is clicked in the "wrapper". Few questions: 1. So again, my question is this, is something like this possible, so I can gain some money from those sites ALREADY hotlinking to the .swf files on my server? 2. If this isn't possible to get on already previous hotlinked .swf files, is something like the example mentioned above possible from a new start, so that when people link to an .swf file on my site, they think they're getting the file, but in reality they're getting the wrapper that displays the ad first, and then it calls the real .swf file? 3.I am not currently looking for a programmer to do this work, but I am interested in a rough estimate so I can make plans on how I should proceed for my current problem. Thanks for any input you can provide me with on this subject. Sorry if this is more about flash programming than php programming, I don't know how it would be programmed. <?php $totalcreditstd = $row_rsCreditPurchaseMoney['SUM(quantity)']; $totalcreditsdollar = $totalcreditstd * $Mutliplier; echo $totalcreditsdollar; ?> I'm using the above calculation to display a total amount. Problem is that if the calculation total is 7.5 I want it to show up as 7.50 I want to force the second number. How can I do that? Thanks. Hi, I want to force download an asf (audio) file, i have found a script, but it is not for asf but pdf, i was searching for mime types, but not sure what asf classifies? <?php // your file to upload $file = '2007_SalaryReport.pdf'; header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-type: application/pdf"); // tell file size header('Content-length: '.filesize($file)); // set file name header('Content-disposition: attachment; filename='.basename($file)); readfile($file); // Exit script. So that no useless data is output-ed. exit; ?> i found this page http://www.utoronto.ca/web/htmldocs/book/book-3ed/appb/mimetype.html#audi so sould it be audio/x-wav? Thanks, Ted Not sure at all if this is the right place for this post, but it seemed the most applicable spot. Mods, please move this thread if it is more appropriate elsewhere.
OK - We've got a client that's using - as far as I can tell - exclusively IE11 and has been running into an issue where IE is apparently deleting the contents of the 'Compatibility View Settings' when the browser is closed and/or the browsing history is cleared. According to the research I've done, this was a design decision by Microsoft when they updated IE to only display the 'broken page' icon when the browser thinks the page is broken (regardless IE's actual ability to correctly parse the page) and is fairly well documented in several different places on the Interwebs.
So, I know the issue, and I know that adding an "X-UA-Compatible" meta-tag in the target page's HTML should take care of the problem. The issue I'm having is this - we're redoing the site. Unfortunately, we're not redoing the pages that are causing the current problem, and the client has talked with someone who made mention of (rough quote here) 'a small bit of code that could be added to the link' that would force IE to render in compatibility mode.
I'm assuming the client's source is talking about the meta-tag in the link target page, and I haven't found anything in my Google searches to discount that theory, but I thought I'd ask here before I spoke with them about it in case I'm wrong.
Is there a flag that I can simply append to the URL that IE will parse and force a specific release-compatible view? Or really any way to force IE to render a webpage to a certain version that doesn't entail messing up the display to every other browser ever made or modifying the rendered page's source HTML?
I am working on a simple authentication system and something has came to light regarding the access token and potential brute force. For the access token there is an expiry date/time where the client will need to send a refresh token to get a new access token. However, what is stopping an attempt to run a brute force attack against an endpoint and firing lots of random values for the access token? I know it will be a guessing game but potentially if you have a few million users all with valid tokens then there is a possibility that it could guess it after a few days/weeks of trying? I wrote a very simple web form that allows my user to view text files from within their Internet browser. I implemented a feature whereby the text files returned by the search are compressed into a ZIP. Here's my code Code: [Select] function getFiles() { $result = null; $ZIPresult = null; if (empty($_POST['DBRIDs'])) { return null; } $mydir = MYDIR; $dir = opendir($mydir); $DBRIDs = $_POST['DBRIDs']; $getfilename = mysql_query("select filename from search_table where rid in (" . $DBRIDs . ")") or die(mysql_error()); while ($row = mysql_fetch_array($getfilename)) { $filename = $row['filename']; $result .= '<tr><td><a href="' . basename($mydir) . '/' . $filename . '" target="_blank">' . $filename . '</a></td></tr>'; $ZIPresult .= basename($mydir) . '/' . $filename; } if ($result) { $result = "<table><tbody><tr><td>Search Results.</td></tr> $result</table>"; shell_exec("zip -9 SearchResult.zip ". $ZIPresult ." > /dev/null "); $fileName = 'SearchResult.zip'; header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Transfer-Encoding: binary"); header('Content-type: application/zip'); header("Content-length: " . filesize($fileName)); header('Content-Disposition: attachment; filename="' . $fileName . '"'); readfile($fileName); } return $result; } It works great If I download the ZIP file from the server using FTP (for example) but I force the download from the page header, the ZIP is corrupted. What am I missing? Thanks for your input. **PS: The new ZipArchive() library/class is not available on our production environment so I chose to use the Unix utility ZIP instead.** This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=352264.0 I'm trying to block access to a particular page if the visitor is not from a specific country (using Maxmind Geoip Country database), but not quite sure how to code this properly: I tried this and many variations of this inside the head tags, bud doesn't work. Any suggestions on the best way to go about this? Code: [Select] <?php require_once("geoip.inc"); $gi = geoip_open("/home/username/GeoIP.dat",GEOIP_STANDARD); $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); geoip_close($gi); if($country_code !== 'US') header("HTTP/1.0 404 Not Found"); exit; ?> Hi there, I have updated a webpage and it appears that some users are still seeing the older version of the page. Is there a way I can force the user's version of the page to display the latest content on the page? I have see I can add some meta tags which control the cache, but my site relies quite heavily on cookies, so I guess clearing the cache would reset/have an effect on the cookies? Does anyone have any ideas on how I can make users always see the latest content? Thanks! Hello, I have the following code to force download mp3 file. the code is working fine but its only downloading 799 bytes. I am new in php and not able to figure out the problem. please help me to sort it out. thanks. Code: [Select] <?php include "dbconnect.php"; $link=dbconnect(); $cat=$_GET['catagory']; $id=$_GET['id']; $query=("select *from $cat where id='$id'"); $result=mysql_query($query); $row=mysql_fetch_array($result); $file = $row["link"]; header ("Content-type: octet/stream"); header("Content-Disposition: attachment; filename=\"".basename($file)."\";" ); header("Content-Length: ".filesize($file)); readfile($file); exit; ?> Hi, I have just created an algorithm and could this be the greatest algorithm invented for calculating square roots? Perhaps the answer is yes with 100% accuracy unlike some algorithms that round the last digit up. Below is the algorithm I have created and I used php. Also this algorithm can easily be imported into any language with any bitrate and is very scalable unlike some of the standard built in square root algorithms for some interpreters (all of the ones tested so far). Now below is the code with it in both the form of a class and the form of a function. You may notice that the function name is funny but it is tatically named that way so that the string length of the function name is the same as the sqrt() function so you don't get qwerky results when comparing the two. <?php class sqrt { public $value; function __construct($in) { $tmp = (int) $in; $tmpp = ($tmp/2); for ($i=1;($i*$i)<=$tmp;$i*=2) {} $i/=2; for (;($i*$i)<=$tmp;$i++) {} $i--; $k=$i; $i++; if (($i*$i)>$tmp || ($i*$i)<$tmp) { for ($j=1;($i*$i)>=$tmp;$j/=2,$i=($j+$k)) {} $v=strlen((string)$j); $m=1/pow(10,$v); for (;($i*$i)<=$tmp;$j+=$m,$i=($j+$k)) {} $j-=($m); $i=$j+$k; if (($i*$i)>$tmp || ($i*$i)<$tmp) { //$w = (strlen((string)pow(2,32))+1); //$w = same number as below $w = 11; //32 bit $q=$m; for ($n=$v+1;$n<$w;$n++) { $m=1/pow(10,$n); $p=pow(10,(($n-$v)+1)); for ($o=0;$o<$p && ($i*$i)<=$tmp;$j+=$m,$i=($j+$k),$o++) {} $j-=$m; $i=($j+$k); } } } echo $i; $this->value = $i; return $this->value; } } function mysq($in) { $tmp = (int) $in; $tmpp = ($tmp/2); for ($i=1;($i*$i)<=$tmp;$i*=2) {} $i/=2; for (;($i*$i)<=$tmp;$i++) {} $i--; $k=$i; $i++; if (($i*$i)>$tmp || ($i*$i)<$tmp) { for ($j=1;($i*$i)>=$tmp;$j/=2,$i=($j+$k)) {} $v=strlen((string)$j); $m=1/pow(10,$v); for (;($i*$i)<=$tmp;$j+=$m,$i=($j+$k)) {} $j-=($m); $i=$j+$k; if (($i*$i)>$tmp || ($i*$i)<$tmp) { //$w = (strlen((string)pow(2,32))+1); //$w = same number as below $w = 11; //32 bit $q=$m; for ($n=$v+1;$n<$w;$n++) { $m=1/pow(10,$n); $p=pow(10,(($n-$v)+1)); for ($o=0;$o<$p && ($i*$i)<=$tmp;$j+=$m,$i=($j+$k),$o++) {} $j-=$m; $i=($j+$k); } } } return $i; } $s = microtime(true); mysq(128); $e = microtime(true); $a=($e-$s); unset($e,$s); sleep(1); $s = microtime(true); sqrt(128); $e = microtime(true); echo 'mysq time &#160;&#160;='.$a.'<br>'; echo 'mysq result='.mysq(128).'<br>'; echo 'sqrt time&#160;&#160;='.($e-$s).'<br>'; echo 'sqrt result='.sqrt(128).'<br>'; echo 'The mysq function is '.bcdiv(substr(($e-$s),0,11),$a,0).' times faster for this calculation.<br>'; what would be the best way to automate/force session destroy and cookie erase i have a facebook iframe, with facebook login which gets the activation token now the user is not logged out from the login script after he logs out of facebook. any ideas how to force cookie timeout without a logout button? im playing with Code: [Select] <?php session_start(); //Global User Object Var //loggedInUser can be used globally if constructed if (isset($_SESSION['userCakeUser'])) { $obj = casttoclass('stdClass', $_SESSION['userCakeUser']); $_SESSION['userCakeUser'] = $obj; $_SESSION['start'] = time(); // taking now logged in time $_SESSION['expire'] = $_SESSION['start'] + (1 * 60) ; // ending a session in 1 minute } if(isset($_SESSION["userCakeUser"]) && is_object($_SESSION["userCakeUser"])) { $loggedInUser = $_SESSION["userCakeUser"]; } ?> I have an application that was written back in PHP4 days and has ceased development ever since. PHP 4 is basically gone, i can't get it to install on any of my machines now and what i use on my windows boxes (XAMPP) doesn't include PHP4 anymore. When i set everything up, i get ~50 of these: Deprecated: Assigning the return value of new by reference is deprecated in.... and on every line it looks like: $var =& _____ or $var = &something... yada-yada and removing the & symbol removes the error message. Using editplus i removed all the "=&" and "= &" and just replaced the & with space, i had read on google PHP5 doesn't need it anymore so that should've worked. But as my luck would have it, the server errors out with 500 code until i replace all the &'s back, and then the errors show up yet again. Is there anyway to force php5 to run this program despite having php4 things in it? im using this code: PHP Code: [Select] Code: [Select] <?php set_time_limit(0); $file = 'test.mp3'; header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"$file\""); header('Content-Type: audio-x/mp3'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Expires: 0'); readfile($file); ?> when downloading i cant see the progress bar. thanks. |