PHP - Php Notice: A Non Well Formed Numeric Value Encountered
Hi,
My errorlog keep spamming the following errormsg: "PHP Notice: A non well formed numeric value encountered on line 365". This is the code it refers to: Code: [Select] for ($yr = $year, $age = -1; mktime(0, 0, 0, $month, $day, (int)$yr) < $today; $yr++, $age++); It's supposed to calculate the owner of the page's age. The full code is: Code: [Select] list($year,$month,$day) = explode("-", $birthday); $tempVar=list($year,$month,$day) = explode("-", $birthday); $today = time(); for ($yr = $year, $age = -1; mktime(0, 0, 0, $month, $day, (int)$yr) < $today; $yr++ Similar TutorialsHi, After making an update, I have received this notice: Notice: A non well formed numeric value encountered in -... -on different page on line 128 : <?php $identifier = round(microtime() * 10000000); ?> on line 402 : <?php $identifier = round(microtime() * 10000000); ?> on line 2: <?php $identifier = round(microtime() * 10000000); ?>
How can I fix it? Thanks so much Federica
Morning !
I've tried a number of things but not able to sort out the error ..anyone see why I am getting the non well formed numeric error?
TIA
Is there any way to disable the "A non-numeric value encountered" warning in the php.ini file? I don't get that warning on my Apache server but I do when I use the same code on my web host's server. I never got the warning until I uploaded a two line php.ini file to my web host so that I could keep my sessions longer than the default 24 minutes. This is the same online program related to my earlier post about too many inputs. I wanted to try sessions for a 24 hr. period but I'm getting tons of errors for any field that is not used which can be in the hundreds. If I delete my php.ini file from my web host & just let things default to whatever they are using then I don't get those errors, I have a huge application(multi-year) where I do the normal $varX= $var1 + $var2. I get Warning: A non-numeric value encountered because var1 or var 2 are string. I know the right thing will be to intval(), but I just cant go over so much of the application. I read to just disable warning, but I think thats worst because I will not be able to see new warnings. Is there any php.ini solution were php can work as before on math operations? I guess I can ini_set on all the old files and dont do it on the new ones). If there is another accepted solution, please let me know Thank you
Hey, So what im trying to do is put my database variables into a session array. So this is what im trying to accomplish... $_SESSION['Name_of_Row'] = $value This is the script I wrote: Code: [Select] Function setupSession(){ session_start(); $query = "SELECT * FROM users WHERE u_id ='{$this->u_id}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); foreach($row as $key => $value){ if(!empty($value)){ $_SESSION[$key] = $value; } } } When that runs I get the following warning. Can anyone tell me what this means and how to fix it? Error: Notice: Unknown: Skipping numeric key 0 in Unknown on line 0 hi, I need help really badly for my PHP-Postcard Script. Basically it sends the card out but the URL does not work, I get the following error message: The URL is not valid and cannot be loaded It also states that Notice: Undefined index: www.voluntary.awardspace.co.uk in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 Notice: Undefined index: Postcard.php in /home/www/voluntary.awardspace.co.uk/Postcard.php on line 25 See Code below: <?php session_start(); //check error log ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); // CHANGE PARAMETERS HERE BEGIN $senderName = " Holidays From Home "; // Eg.: John's Postcards $senderEmail = "chris01@voluntary.awardspace.co.uk"; // Eg.: john@postcard.com // Change only if you have problems with urls $postcardURL = "http://".$_SERVER["www.voluntary.awardspace.co.uk"].$_SERVER["Postcard.php"]; // CHANGE PARAMETERS HERE END $result = 0; $msg = ""; $msg1 = ""; $pic = ""; function displayPhotos() { global $pic; $columns = 5; $act = 0; $act1 = 0; // Open the actual directory if($handle = opendir("thumbs")) { // Read all file from the actual directory while($file = readdir($handle)) { if(!is_dir($file)) { if(isset($pic[1])) { if($pic[1] == $act1){$sel = "checked";} else{$sel = "unchecked";} } if($act == 0){echo "<tr>";} echo "<td align='center'><img src='thumbs/$file' alt='postcard'/><br/><input type='radio' name='selimg' value='$file,$act1' $sel/></td>"; $act++; $act1++; if($act == $columns){$act = 0;echo "</tr>";} } } echo "</tr>"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro Postcard</title> <link href= "style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="style1" id="caption"> <div align="left" class="style1"></div> </div> <?php //makes sure form is correctly filled in if(!empty($_POST["submit"])) { if(empty($_POST["selimg"])){$msg = "Please select an image from above!";$result = 3;} else{$pic = explode(",",$_POST["selimg"]);} if(empty($_POST["email"]) && empty($result)){$msg1 = "You must enter an email address!";$result = 3;} $secCode = empty($_POST["secCode"]) ? "" : strtolower($_POST["secCode"]); if($secCode == $_SESSION["securityCode"] && $result != 3) { $filename = date("YmdGis"); $f = fopen("messages/".$filename.".txt","w+"); fwrite($f,$pic[0]."\n"); fwrite($f,$_POST['email']."\n"); fwrite($f,stripslashes($_POST["message"])."\n"); fclose($f); // Compose the mail $from = "From: $senderName <$senderEmail>\r\n"; $replay = "Reply-To: $senderEmail\r\n"; $params = "MIME-Version: 1.0\r\n"; $params .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $mailtext = "You have just received a Virtual Postcard!\r\n\r\n You can pick up your postcard at the following web address:\r\n $postcardURL?show=$filename\r\n\r\n We hope you enjoy your postcard, and if you do, please take a moment to send a few yourself!\r\n\r\n Regards,\r\n Holidays From Home\r\n $postcardURL"; // Send email @mail($_POST["email"],"You've received a postcard",$mailtext,$from.$replay.$params); echo "<center> Your postcard was sent successfully!<br /><br /> <img src='images/$pic[0]' alt='postcard' /><br /><br /><br />".stripslashes($_POST["message"]). "</center>"; $result = 1; } else{if($result != 3){$result = 2;}} } if(!empty($_GET["show"])) { $file = $_GET["show"]; $content = file("messages/$file.txt"); $pic = $content[0]; unset($content[0]); unset($content[1]); foreach($content as $value){$main .= $value;} echo "<center> Your postcard!<br /><br /> <img src='images/$pic' alt='postcard' /><br /><br /><br />$main </center>"; } if((empty($result) || $result == 2 || $result == 3) && empty($_GET["show"])) { echo "<form action='#' method='post'> <table align='center'>"; displayPhotos(); echo "</table> <div style='color:#f00;font-size:16px;'>$msg</div> <h2>Fill in the Form and then click on Send Card!!</h2> <table width='100%'> <tr><td>Send to (email address):</td><td><div style='color:#f00;font-size:16px;'>$msg1</div><input type='text' name='email' size='30' value='".$_POST["email"]."' /></td></tr> <tr><td>Message:</td><td><textarea name='message' rows='10' cols='40'>".stripslashes($_POST["message"])."</textarea></td></tr> <tr><td colspan='2'>".($result == 2 ? "<p style='color:#f00;font-size:16px;'>Sorry the security code is invalid! Please try it again!</span></p>" : " ")."</tr> <tr> <td>Security code: <input class='text' name='secCode' type='text' size='10' /> </td><td><img src='securityCode.php' alt='security code' border='1' /></td> </tr> <tr><td colspan='2'> </tr> <tr><td colspan='2' align='left'><input type='submit' value='Send card!' name='submit'/></td></tr> </table> </form>"; } ?> Absolutely any help would be much appreciated. I want ot know is there a way round this problem? Here is the http://voluntary.awardspace.co.uk/Postcard.php I am absolutely desperate to solve this burning issue Hi all trying to help a friend with a script his installing
but keep getting two errors
Severity: Warning
and
the code being run is
<?php $sql="SELECT * FROM `adminlogin` WHERE role='admin'"; $qry=mysqli_query($sql); $data=mysqli_fetch_array($qry); ?> not sure what I'm doing wrong any help would be appreciated
full page source is
<header id="header-navbar"> <div class="container" > <a style="background-color: #2a3133" href="<?php echo base_url();?>admin/dashboard" id="logo" class="navbar-brand"> <img src="<?php echo base_url();?>upload/taxi_logo.png" alt="" class="normal-logo logo-white" width="100%" height="100%"/> <!-- <img src="img/logo-black.png" alt="" class="normal-logo logo-black"/>--> <!-- <img src="img/logo-small.png" alt="" class="small-logo hidden-xs hidden-sm hidden"/>--> </a> <div class="clearfix"> <button class="navbar-toggle" data-target=".navbar-ex1-collapse" data-toggle="collapse" type="button"> <span class="sr-only">Toggle navigation</span> <span class="fa fa-bars"></span> </button> <div class="nav-no-collapse navbar-left pull-left hidden-sm hidden-xs"> <ul class="nav navbar-nav pull-left"> <li> <a class="btn" id="make-small-nav"> <i class="fa fa-bars"></i> </a> </li> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- <i class="fa fa-bell"></i>--> <!-- <span class="count">8</span>--> <!-- </a>--> <!-- <ul class="dropdown-menu notifications-list">--> <!-- <li class="pointer">--> <!-- <div class="pointer-inner">--> <!-- <div class="arrow"></div>--> <!-- </div>--> <!-- </li>--> <!-- <li class="item-header">You have 6 new notifications</li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-comment"></i>--> <!-- <span class="content">New comment on ‘Awesome P...</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-plus"></i>--> <!-- <span class="content">New user registration</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-envelope"></i>--> <!-- <span class="content">New Message from George</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-shopping-cart"></i>--> <!-- <span class="content">New purchase</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-eye"></i>--> <!-- <span class="content">New order</span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item-footer">--> <!-- <a href="#">--> <!-- View all notifications--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- <i class="fa fa-envelope-o"></i>--> <!-- <span class="count">16</span>--> <!-- </a>--> <!-- <ul class="dropdown-menu notifications-list messages-list">--> <!-- <li class="pointer">--> <!-- <div class="pointer-inner">--> <!-- <div class="arrow"></div>--> <!-- </div>--> <!-- </li>--> <!-- <li class="item first-item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-1.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- George Clooney--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-2.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- Emma Watson--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <img src="img/samples/messages-photo-3.png" alt=""/>--> <!-- <span class="content">--> <!-- <span class="content-headline">--> <!-- Robert Downey Jr.--> <!-- </span>--> <!-- <span class="content-text">--> <!-- Look, just because I don't be givin' no man a foot massage don't make it--> <!-- right for Marsellus to throw...--> <!-- </span>--> <!-- </span>--> <!-- <span class="time"><i class="fa fa-clock-o"></i>13 min.</span>--> <!-- </a>--> <!-- </li>--> <!-- <li class="item-footer">--> <!-- <a href="#">--> <!-- View all messages--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- New Item--> <!-- <i class="fa fa-caret-down"></i>--> <!-- </a>--> <!-- <ul class="dropdown-menu">--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-archive"></i>--> <!-- New Product--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-shopping-cart"></i>--> <!-- New Order--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-sitemap"></i>--> <!-- New Category--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- <i class="fa fa-file-text"></i>--> <!-- New Page--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <li class="dropdown hidden-xs">--> <!-- <a class="btn dropdown-toggle" data-toggle="dropdown">--> <!-- English--> <!-- <i class="fa fa-caret-down"></i>--> <!-- </a>--> <!-- <ul class="dropdown-menu">--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- Spanish--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- German--> <!-- </a>--> <!-- </li>--> <!-- <li class="item">--> <!-- <a href="#">--> <!-- Italian--> <!-- </a>--> <!-- </li>--> <!-- </ul>--> <!-- </li>--> <!-- <span class="conveythis notranslate" translate="no"><a href="http://translation-services-usa.com/spanish.php" title="spanish translation services" class="conveythis-image conveythis-drop translate1">spanish translation services</a></span><script src="http://s1.conveythis.com/e4/javascript/e.js?conveythis_src=en"></script>--> </ul> </div> <div class="nav-no-collapse pull-right" id="header-nav"> <ul class="nav navbar-nav pull-right"> <li class="mobile-search"> <a class="btn"> <i class="fa fa-search"></i> </a> <div class="drowdown-search"> <form role="search"> <div class="form-group"> <input type="text" id="example1" class="form-control" placeholder="Search..."> <i class="fa fa-search nav-search-icon"></i> </div> </form> </div> </li> <?php $sql="SELECT * FROM `adminlogin` WHERE role='admin'"; $qry=mysqli_query($sql); $data=mysqli_fetch_array($qry); ?> <li class="dropdown profile-dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img src="<?php echo base_url().$data['image']; ?>" alt=""/> <span class="hidden-xs"><?php echo $data['username'];?></span> <b class="caret"></b> </a> <ul class="dropdown-menu dropdown-menu-right"> <li><a href="profile"><i class="fa fa-user"></i>Profile</a></li> <li><a href="password_change"><i class="fa fa-cog"></i>Change Password</a></li> <!-- <li><a href="#"><i class="fa fa-envelope-o"></i>Messages</a></li>--> <li><a href="logout"><i class="fa fa-power-off"></i>Logout</a></li> </ul> </li> <li class="hidden-xxs"> <a class="btn" href="logout"> <i class="fa fa-power-off"></i> </a> </li> </ul> </div> </div> </div> </header>
I am getting this error on my sales cart page. I am editting a PHP Point of sale program. Cant work out why this is not working. It should display the amount of points the item is worth. Help please Heres the error im getting: A PHP Error was encountered Severity: Notice Message: Undefined index: points Filename: sales/register.php Line Number: 69 Heres the code: <div class='warning_message' style='padding:7px;'><?php echo $this->lang->line('sales_no_items_in_cart'); ?></div> </tr></tr> <?php } else { foreach($cart as $item_id=>$item) { echo form_open("sales/edit_item/$item_id"); ?> <tr> <td><?php echo anchor("sales/delete_item/$item_id",'['.$this->lang->line('common_delete').']');?></td> <td><?php echo $item['name']; ?></td> !!!THIS IS LINE 69 !!! <td><?php echo $item['points']; ?></td> <?php if ($items_module_allowed) { ?> <td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'6'));?></td> <?php } else { ?> <td><?php echo $item['price']; ?></td> <?php echo form_hidden('price',$item['price']); ?> <?php } ?> <td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));?></td> <td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3'));?></td> <td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td> <td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td> </tr> </form> Any ideas? I have three files: Quote /index.php /include/index.php /include/ajax.php the /index.php page is the landing page, which includes the file /include/index.php once the page loads, I make ajax calls to /include/ajax.php here is what the files basically looks like: index.php <html><body><? include('include/index.php'); ?></body></html> include/index.php <? session_start() unset($_SESSION['team']); $_SESSION['team'] = '9'; include/ajax.php <? session_start() $_SESSION['team'] = $_SESSION['team'] . ',9'; Pretty simple right? However, here is what is happening, every time I make a call ajax call to /include/ajax.php, the code in /include/index.php also gets executed and team is reset to 9! I am using jquery to make the ajax call: Code: [Select] $("input:radio").live('click', function() { $.ajax( { url:'include/ajax.php', success: function (data) { alert('done'); } }); }); and when I view the value after each ajax call, it is set to just 9. This is not any other issue, other than the code in include/index.php being executed each time the ajax function is called. Why in the world is the code in include/index.php being execute?! Under what circumstance would such a thing occur? ok what in the world is going on here... I have a simple javascript code to switch out the text between a div there are 4 rotations the text that is being switched is populated from my DB using php. now the weird part. in my DB i'm using longtext now If the text in the db is all one paragraph everything works fine but if there is any type of line break or new paragraph the script wont rotate at all. any ideas? I use a simple machines forum and want to combine a table I have and a smf table and I need the dates in a numberic format(like smf uses). Sooo ... how do I get the time in a format like this 1336392447 Thanks Looking for ideas and advise on this one. I want to take a 10 digit number and 1234567890 and format it like 132-456-7890 what would be my best bet as choice of methods to do this? Is there an easy way to find a numeric value in a string if I don't know what the string will contain? For example I want '52' out of: mystring52 Hopefully there is already a simple function to do this? I'm thinking there may not be as the string having more than one group of numbers may confuse matters. I'm just dealing with abcdef123 or similar in this case though. Hi, I have a page that lists the names of the Artists in one column, and the title of their song in the next column. I've included a sort section that allows users to view the artist (with the corresponding title) that starts with whatever letter they press. I've now come to a point where I need to add in a check for numbers. (View attached image to understand what we're talking about) So if the artist name starts with any number between 0-9, it will be shown in order on the page once a user clicks on "#". I've tried doing it various ways, but can't seem to get it just right. Here is the code (I took out all my attempts to get the numeric sort working): <?php session_start(); include_once('inc/connect.php'); if (isset($_SESSION['username'])){ $loginstatus = "logout"; } else{ $loginstatus = "login"; } if(!isset($_SESSION['sort_counter'])) {$_SESSION['sort_counter'] = 1;} if(($_SESSION['sort_counter']%2) == 0){ //test even value $sortcount = "DESC"; }else{ //odd value $sortcount = ""; } $result = mysql_query("SELECT * FROM sheets ORDER BY artist"); $sheetscount = mysql_num_rows($result); $sortletteris = $_GET['letter']; $downloadclick = $_GET['downloadclick']; $show = $_GET['show']; $today = date("Y-m-d"); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="styles/style.css" /> </head> <body bgcolor="#343331"> <!-- Header --> <div id="header"> <div id="headerleft"></div> <div id="headermiddle"><a href="index.php"><img src="img/logo.png"></a></div> <div id="headerright"> </div> </div> <!-- Content Top --> <div id="contenttop"> <div id="links"> <!-- 92x30 --> </div> </div> <!-- Content Middle --> <div id="contentmiddle"> <div id="content"> <div id="sort"> <?php echo "<center>".$sheetscount." Sheets Available<br />"; echo "<a href='newlyadded.php'>New Sheets</a><span> | </span><a href='request.php'>Request a Sheet</a></center>"; $letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; echo "<center><div id='letters'>"; $i = 0; while ($i<26){ $sortletter = $letters[$i]; echo "<a href='index.php?letter=".$i."'>".$letters[$i]." </a>"; $i += 1; } echo " <a href='index.php'>All</a></div></center>"; if (($sortletteris)!=""){ // The letter that was clicked is set to this variable $mysortletter = $letters[$sortletteris]; //echo $mysortletter; // lname LIKE '$letter%' $result = mysql_query("SELECT * FROM sheets WHERE artist REGEXP '^[$mysortletter]' ORDER BY artist $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } elseif (($sortletteris)==""){ $result = mysql_query("SELECT * FROM sheets ORDER BY artist $sortcount"); $_SESSION['sort_counter'] = $_SESSION['sort_counter'] + 1; //increment after every run } $greenboxleft = "greenboxleft"; $greenboxright = "greenboxright"; $grayboxleft = "grayboxleft"; $grayboxright = "grayboxright"; $colorvalue = 0; echo "<br /><table width='600px' align='center' style='border-collapse:separate; border-spacing:0px;'><th style='background-color: #cccccc; border-bottom-style: solid; border-color: #6aa504;'>Artist</th><th style='background-color: #cccccc; border-bottom-style: solid; border-color: #6aa504;'>Title</th>"; while($row = mysql_fetch_array($result)) { if(($colorvalue%2)==0){ $styleleft = $greenboxleft; $styleright = $greenboxright; } else{ $styleleft = $grayboxleft; $styleright = $grayboxright; } echo "<tr>"; echo "<td align='center' width='250' id='$styleleft'><div id='songsboxleft'>". ucwords($row['artist']). "</div></td>"; echo "<td align='center' width='250' id='$styleright'><div id='songsboxright'><a target='_blank' name='downloadclick' href='".$row['url']."'>" .ucwords($row['title']). "</a></div></td>"; echo "</tr>"; $colorvalue++; } echo "</table>"; ?> </div> </div> </div> <!-- Content Bottom --> <div id="contentbottom"> </div> </body> </html> I have a text firld to enter amount af a book,But i need to check whether the data entering is numeric only eg:70.98 etc. how can i achieve this. my code is echo"<table><tr><td></td><td>Amount in USD</td><td></td><td><input type='text' name='amnt' id='amnt' /> </td><td></td></tr></table>"; Hey Guys...I am trying to secure my php file and have been reading a lot regarding sql injection. I still dont understand clearly how to prevent sql injection through numeric data input, since from what I understood mysql_real_escape_string() does nothing about it only prevents attacks on string input. Here's an example: if ($action == "checkId") { //retreive data from flash $user_id=mysql_real_escape_string($_POST['Id']); $result = mysql_query("SELECT user_id from users WHERE user_id = '$user_id'"); if (mysql_num_rows($result) > 0) { echo "status1=exists"; } else { echo "status1=id doesnt exist"; } } I would like to create a function like this: foreach($_POST as $post) { $postvars[$key] = htmlentities($post); //XSS prevention $postvars[$key] = mysql_real_escape_string($post); //Sql String Prevention } But then again...How do I check on the numeric POST's ? how do I validate them through this function? Any suggestions and/or ideas? Thanks a lot in advance! Cheers. Anyone know how to cast arabic numeric input to (int) ? Or how to convert arabic numerals to english numerals? I created an auction website, inputting english numbers seems to work. However when I switch languages to Arabic, it doesn't work. By casting any arabic numeral input to (int) It keeps returning 0. ١٢٣٤٥٦٧٨٩ 123456789 Hi. I want to build a SQL string based on my form fields so when I have a new field in the db, I can just add a new form field and the sql update will automatically work. For example I have:
<input type=text name=t_something> <input type=text name=d_something> <input type=text name=n_something>(post submission) $data = array(); foreach ($_REQUEST AS $key=>$val) { if (substr($key, 0, 2) == "t_") $data[substr($key, 2, strlen($key)-2)] = $val; if (substr($key, 0, 2) == "n_") $data[substr($key, 2, strlen($key)-2)] = (trim($val)==""?"0":$val); if (substr($key, 0, 2) == "d_") $data[substr($key, 2, strlen($key)-2)] = (trim($val)==""?"NULL":date("Y-m-d", strtotime($val)); } $data["posted"] = "NOW()"; $sql = "INSERT INTO table ("; $cnt = 0; foreach ($data AS $key=>$val) { $cnt++; $sql .= $key . (($cnt < count($data))?", ":""); } This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359102.0 Hi, I have a database with numbers/dates etc stored. I am creating a multilingual site, in both English and Burmese/Myanmar. Burmese/Myanmar has a different alphabet - a bit like Chinese/Thai. The database is set up nicely to allow text translations, but I am having a problem with numbers. How would I go about printing a number/date in Burmese script from a datebase stored as numeric values - i.e.int?? Database etc. is all utf8. Thanks. |