PHP - Can't Figure Out Why Is_numeric Isn't Working
I have a link
echo '<p>View All Items listed for <a href="item.php?mem-items='.$mem_id.'">"'.$name.'"</a></p>'; That goes to a file http://localhost/folder/item.php?mem-items=26 with 26 being an actual member id number I use the GET function like this if (isset($_GET['mem-items']) && is_numeric($_GET['$mem-items'])) { $mem_items = $_GET['mem-items']; } My problem is $mem_items isn't assigned a variable, but when I take the "is_numeric($_GET['$mem-items'])" out, it works like a charm. I use this same format on the same file for "if (isset($_GET['item']) && is_numeric($_GET['item']))" AND it works great. Can anyone see what's wrong. Thanks Similar Tutorialshello all, i can't get this to work; i'm able to echo both accts entered into the form via the _get but can't pull both balances using the $from_acct and $to_acct only the first query working do I have it formated wrong <?php //check for submit $submit = $_GET['submit']; //end looking for submit //set varibles if submit is present if (!$submit) { echo "Sorry Mate I don't see you have submitted anything for me to process"; } else { //make the connecting and set some varibles from _get $from_acct = $_GET['from_acct']; $to_acct = $_GET['to_acct']; $amount = $_GET['amount']; $connect = mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db('users') or die ("no such database exisit"); $query = mysql_query("SELECT * from members WHERE bankaccount=$from_acct") or die ("Could not locate to account"); $query2 = mysql_query("SELECT * from members WHERE bankaccount=$to_acct") or die ("Could not locate to account"); while ($result = mysql_fetch_assoc($query) && $result2 = mysql_fetch_assoc($query2)) { $fromb = $result['balance']; $tob = $result2['balance']; } //make a check to see if the account that is sending has the money to send if ($fromb<$amount) { echo "Mate you don't have enough cash to transfer " .$amount. "to this account<br />"; echo "Your Current Balance available for transfer is " .$fromb; } else { $newbalancefrom = $fromb - $amount; $newbalanceto = $tob + $amount; //make the transfer $transfer = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblanceto' WHERE bankaccount='$to_acct'") or die ("could not write to profile"); $transfer2 = mysql_query("UPDATE 'users' . 'members' SET 'balance' = '$newblancefrom' WHERE bankaccount='$from_acct'") or die ("Could Not Write to From Account"); if ($transfer) { echo "Transfer Complete Thanks!"; } else { echo "There was a error in the transfer process please try again"; } } } echo $fromb . "<br />"; echo $tob . "<br />"; echo $from_acct . "<br />"; echo $to_acct . "<br />"; ?> <h2>Peer to Peer Transfer</h2><br><br> <form action="testtrans.php" method="get"> Amount to Transfer: <input type="text" size="8" name="amount"><br> From Account: <input type="text" size="15" name="from_acct"> To Account: <input type="text" size="15" name="to_acct" /><br /> <input type="submit" name="submit" value="transfer" /> </form> if ($template->load($maintemplatefile,$values)) { //load every php file in the plugin folder //Handle invalid page Requests } else { echo '404 File Not Found'; //exit; } //print page code echo $template->html(); } I call the above code it prints out the template file but it does not recursively replace the <TEMPLATE_LOADTEMPLATE_$1> that is in the file even though it properly parses both the $tag and $value variables going to the $this->replace($tag,$value); line. Any idea why this does not work? <?php class Template { var $code=''; function load($file,$values) { if (file_exists($file)) { //get template directory $dir=substr($file,0,strrpos($file,'/')) . '/'; //get template $this->code=file_get_contents($file); //check if any recurseve templates to add $tags=$this->tags(); //process all internal template tags $newValues=array_slice($values,1); foreach ($tags as $tag) { //handle inserting new template file if (substr($tag,0,13)=='LOADTEMPLATE_') { $file=substr($tag,13); if ($file[0]=='$') { $file=$values[(substr($file,1)-1)]; } $temp=new Template; $filename=$dir . $file . '.xhtml'; if ($temp->load($filename,$newValues)) { $value=$temp->html(); } else { $value='File Not Found'; } $this->replace($tag,$value); } } return true; } else { return false; } } function tags() { preg_match_all('/<TEMPLATE_[^<]+?>/', $this->code, $tags); $tags=$tags[0]; foreach ($tags as $key=>$value) { $tags[$key]=substr($value,10,-1); } return array_unique($tags); } function replace($tag,$value) { $this->code = ereg_replace('<TEMPLATE_' . $tag . '>',$value . '',$this->code); } function replaceSection($tag,$value) { $replace='~<TEMPLATE_' . $tag . '>[\s\S]*?</TEMPLATE_' . $tag . '>~'; $this->code = preg_replace($replace,$value . '',$this->code); } function compress() { $this->code = ereg_replace("\n",'',$this->code); $this->code = ereg_replace(" ",' ',$this->code); $this->code = ereg_replace("\r",'',$this->code); } function html() { //remove <TEMPLATE_*> & </TEMPLATE_*> tags then return html. return preg_replace('/(<\/?)TEMPLATE_[^<]+?>/','',$this->code); } } ?> All code listed is available for use under GNU public license. Hi guys Probably a simple but trying to figure out why I cant get this while loop to work (at least I think its the loop) Query works as it returns 1 row, but not all of them. Any help would be great! $sql = "SELECT * FROM requests ORDER BY leave_after DESC"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { echo '<div id="resultholder">'; echo "<p>Request ID:" . $row['id'] . ", User ID: " . $row['user_id'] . ", Departing From: " . $row['departing'] . ", Going To: " . $row['destination'] . " , Leaving After: " . $row['leave_after'] . " , but Arriving Befo " . $row['arrive_before'] ."</p></div>"; echo '</div>'; } } } Thanks! I've tried a few different methods, but I can't get this damn function to work. Can someone show me where I've gone wrong? Here's my code & form. I'm still baffled why it doesn't work! :lol: url is update-content.php?id=12 <?php include("../include/session.php"); if(!$session->logged_in) { header('Location: ../login.php'); die; } require_once('../include/functions.php'); function content($id) { $id = $_GET['id']; $connection = db_connect(); $query = sprintf("select * from content where id = '$id'", mysql_real_escape_string($id) ); $result = mysql_query($query); $number_of_posts = mysql_num_rows($result); if ($number_of_posts == 0) { return false; } $row = mysql_fetch_array($result); return $row; } function update($param) { // Get the content id from url to output into the editor $id = $_GET['id']; $connect = db_connect(); $page = mysql_real_escape_string($_POST['page']); $page_id = mysql_real_escape_string($_POST['page_id']); $title = mysql_real_escape_string($_POST['title']); $text = mysql_real_escape_string($_POST['text']); $query = ("UPDATE content SET page = '$page' page_id = '$page_id' title = '$title' text = '$text' WHERE id = '$id' "); $result = mysql_query($query); if (!$result) { return false; } else { return true; } } ?> <?php // Send form data to mysql if(isset($_POST['text'])) { $result = update($_POST); if($result === true) { echo 'Success!'; die(); } } ?> And the form.. <form form name="editor" id="editor" method="post" action="update-content.php"> <p><br /> <b>Assign to page</b><br /> <input name="page" id="page" size="60" maxlength="500" value="<?php $page = content($id); echo stripslashes($page['page']); ?>" /> <br /> <br /> <b>Page id</b> <input name="page_id" id="page_id" size="4" maxlength="4" value="<?php $page_id = content($id); echo stripslashes($page_id['page_id']); ?>" /> <br /> <br /> <b>Title</b> <span class="smalltext">(Just a short name this piece of content)</span><br /> <input name="title" id="title" size="60" maxlength="200" value="<?php $title = content($id); echo stripslashes($title['title']); ?>" /> <br /> <br /> <br /> <strong>Content</strong> <span class="smalltext">(paste html in here)</span><br /> <textarea name="text" id="text" cols="75" rows="15"><?php $text = content($id); echo stripslashes($text['text']); ?></textarea> <?php //turn the text area into CK Editor echo $ckeditor_ini; ?> <br /> <input type="image" src="../images/button_submit.gif" alt="submit" name="submit" value="submit" /> <a href="index.php"><img src="../images/button_cancel.gif" alt="Cancel" width="120" height="26" border="0" /> </form> Wordpress gave me the following error when uploading the this themeforest theme. failed opening '/srv/htdocs/wp-content/themes/QuickFixWebiste(Wordpress)/../../../wp-admin/includes/class-walker-nav-menu-edit.php' for inclusion (include_path='.:/usr/local/php7.2/lib/php') in /srv/htdocs/wp-content/themes/QuickFixWebiste(Wordpress)/library/core/admin/edit-menu-walker.php Can anyone tell me how to resolve this? The source code in the edit-menu-walker.php on lines 1-4 is: <?php if (!class_exists('Walker_Nav_Menu_Edit')){ include_once(get_template_directory() . '/../../../wp-admin/includes/class-walker-nav-menu-edit.php'); }
Taken from http://php.net/manual/en/function.is-numeric.php <?php $tests = array( "42", 1337, "1e4", "not numeric", Array(), 9.1 ); foreach ($tests as $element) { if (is_numeric($element)) { echo "'{$element}' is numeric", PHP_EOL; } else { echo "'{$element}' is NOT numeric", PHP_EOL; } } ?> Outputs: Quote '42' is numeric '1337' is numeric '1e4' is numeric 'not numeric' is NOT numeric 'Array' is NOT numeric '9.1' is numeric WHY does 1e4 validate as TRUE using is_numeric? Code: [Select] <FORM METHOD=POST ACTION=""> <p>Breeder or Business Name<br /> <input type = "text" name = "breedername" size= "25" maxlength = "50" /> </p> <p>Breeder Telephone<br /> <input type = "text" name = "breedertelephone" size= "25" maxlength = "50" /> </p> <p>Breeder Location<br /> <input type = "text" name = "breederlocation" size= "25" maxlength = "50" /> </p> <p>Breeder Desription<br /> <input type = "text" name = "breederdescription" size= "25" maxlength = "50" /> </p> <p>Leave blank<br /> <input type = "text" name = "breederverify" size= "5" maxlength = "5" /><br /><br /> </p> <input type="submit" value="Submit" name='submit' /> <br /> <br /> </form> <?php if (is_string($breederverify)) { <-- If $breederverify is set , then echo "Please leave the lowest box empty!" echo "Please leave the lowest box empty!"; } else { <-- else if $breederverify is unsigned/null execute this block. $con = mysql_connect("localhost","xxxxxxxxxx","xxxxxxxxxx"); mysql_select_db("cichlid",$con); $breedername = $_POST['breedername']; $breedertelephone = $_POST['breedertelephone']; $breederlocation = $_POST ['breederlocation']; $breederdescription = $_POST ['breederdescription']; $breederverify = $_POST ['breederverify']; $sql = "INSERT INTO breedersinfo SET breederNAME = '$breedername' , breederTELEPHONE = '$breedertelephone' , breederLOCATION = '$breederlocation' , breederDESCRIPTION = '$breederdescription'"; if(!mysql_query($sql,$con)) { die('ERROR:Could not connect ' . mysql_error ()); } echo ""; mysql_close ($con) ; } ?> All i am trying to accomplish is a form field that will only update records if the last $breederverify = $_POST ['breederverify']; is null/unasigned . I was thinking in order to do this i could use is_numeric , or is_string function to check $var ,to see what it's state is. Any help or advice would be appreciated , provided this is even possible. Cheers guys . hey all; i created a script that just allows a user to record an IP address and it presents them in a table.. issue: each record draws its own row and a colum for an image (for deleting).. I can't igure out how I can delete the one row when they click on image(little x) to delete... issue2: it's showing the error message when you bring up the screen telling them they didn't enter anything even prior to them hitting submit... issue3: it's allowing me to enter the same IP again code: <?php session_start(); if (!isset($_SESSION['username'])) { echo "Sorry you must be logged in to view this page<BR>"; echo "Please <a href='index.php'>GO BACK</a> and try again"; exit(); } else { if ($_SESSION['username']) { $username = $_SESSION['username']; $userid = $_SESSION['userid']; } } //script v1.0 ipdatabase.php - create a list of IP addresses that the user has added to their list to remember. can add or remove IPs ?> <style type="text/css"> <!-- .style1 {color: #FFFFFF} --> </style> <table align="center" width="550" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000"> <!--DWLayoutTable--> <tr> <td height="106" colspan="3" valign="top"><img src="images/myvpc.png" width="550" height="106"></td> </tr> <tr> <td width="16" height="57"> </td> <td width="516" valign="top"><div align="center" class="style1"> <p>IP DATABASE</p> <p align="left">add or remove IP address you have encountered in the game thus far for later use!</p> </div></td> <td width="18"> </td> </tr> <tr> <td height="100"> </td> <td valign="top"> <form action="ipaddressadd.php" method="POST"> <p> </p> <p><span class="style1">IP ADDRESS</span>: <input type="text" name="ipaddress" size="16"> <input type="submit" name="submit" value="submit"> </p> </form></td> <td> </td> </tr> <tr> <td height="17"></td> <td valign="top"><img src="images/filler.jpg" width="516" height="19"></td> <td></td> </tr> <tr> <td height="296"></td> <td valign="top"> <?php $submit = $_POST['submit']; if ($submit) { $ipaddress = ip2long($_POST['ipaddress']); } //script to add IP to database include('connectdb.php'); mysql_select_db('heaven_users') or die (mysql_error()); if (isset($ipaddress,$submit)) { mysql_query("INSERT INTO ipdatabase (userid,ipaddress) VALUE ('$userid','$ipaddress')") or die ("Could Not write to database, Please try again"); } else echo "<center><font color='#ff0000'>You didn't add anything mate!</font></center>"; echo "<br />"; echo "<table align='center' border='1'><tr align='center'><th><font color='#ffffff'>SAVED IPADDRESS</font></th></tr><tr>"; $query = mysql_query("SELECT * FROM ipdatabase WHERE userid = '$userid'"); while ($result = mysql_fetch_assoc($query)) { $ip = long2ip($result['ipaddress']); echo "<tr align=\"center\"><td><font color='#ffffff'>".$ip."</font></td><td><a href='deleteip.php'><img border='0' src='images/delete.png'></a></td></tr>"; } echo "</table>"; ?> </td> <td></td> </tr> </table> i was wondering how i would go about making a single page that would have sections on it and if you click a section the page reloads and shows the information that is within that section? i got my code to show both the section and its information at the same time but cannot figure out how to do the above. please help. thank you -Adam The page that I'm working on is a quiz results page. In this section of code I am simply printing the question, then each answer choice is printed depending on a few if statements. Let's say the answer choice in this first statement was "Baseball." The four possibilities depending on the student answer I want a Baseball - You Got This Right or Baseball - Correct Answer or Baseball - Your Answer or Baseball So if the student gets a question wrong one choice should say "Correct Answer" next to it and one other would have "Your Answer" next to it. Pretty simple and straightforward. I can get the correct results from everything but the second ifelse statement (Baseball - Your Answer). No matter what i do I can't get this to work. Here is the code below and some clarifications: $StudAns = Student's answer $Choices = The particular answer choice being evaluated $CorrectAnswer = obvious Code: [Select] $StudAns = array($QChoices['Q1Choice'], $QChoices['Q2Choice'], $QChoices['Q3Choice']); $ContentsQuery = mysql_query("SELECT Question, Choice1, Choice2, Choice3, Correct_Answer FROM Module_1_Quiz") or die(mysql_error()); while ($Contents = mysql_fetch_array($ContentsQuery)) { $i =0; $Choices = array($Contents['Choice1'], $Contents['Choice2'], $Contents['Choice3']); $CorrectAnswer = $Contents['Correct_Answer']; echo "<span id='answers'><table width = '600' border='0' align='center' id='answers' bgcolor='#FFFFCC'><tr><td>"; echo $Contents['Question']; echo "</td></tr>"; echo "<tr><td><ol type = 'a'><li>"; // Checks what should be printed for the first answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the second answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li><li>"; $i++; // Checks what should be printed for the third answer option if ($Choices[$i] == $CorrectAnswer && $StudAns[$i] == $CorrectAnswer) { echo $Choices[$i]; echo " - You Got This Right!"; } elseif ($Choices[$i] == $CorrectAnswer && $StudAns[$i] != $CorrectAnswer) { echo $Choices[$i]; echo " - Correct Answer"; } elseif ($StudAns[$i] != $CorrectAnswer && $CorrectAnswer[$i] != $Choices[$i]) { echo $Choices[$i]; echo " - Your answer"; } else { echo $Choices[$i]; } echo "</li></ol></table></span>"; } Thanks everyone! guys is it possible to somehow compare something like these two together and make a choice depending on the out come SystemKeyv1.0 and PasswordCrackerv2.0 PasswordCrackerv2.0 is grater than SystemKeyv1.0 can these be compared somehow? thank for advise guys; Cheers I'm terrible at designing websites (that's pretty much out of the question), but I would like to work on my php skills. I just can't figure out anything I can write that isn't extremely hard.. ideas? Hi, good pm masters! So i have this code Code: [Select] <td><img src="images/layout/<?php echo base64_decode($_GET['layout']); ?>" width="50%" height="50%" /></td> $_GET['layout'] is encoded that's y i have a decode there, the image name will then be combined to the src like this -> image/layout/1.jpg.. when i view the source the src is correct but it doest show the image.. cant seem to find whats wrong.. my folder structure is sandbox>images>layout>file.jpg the php file (where the code above is) inside the sandbox. sorry if am i missing something sooo eaasy.. i was doin alot of coding this morning until now so i don't know what to think anymore.. I am trying to redirect users depending on their coupon code input I am using the following script in the form created in dreamweaver: Code: [Select] <form action="CodeUserredirect.php" method="post" enctype="multipart/form-data" name="" id=""> <input type="hidden" name="redirect" value="CodeUserredirect.php" /> <p class="style4">Redeem your Gift Certificate Savings for Special Orders he </p> <p><span class="style78">Enter Coupon code</span> <input name="CouponCode" type="text" id="CouponCode" size="9"> <input type="submit" name="CheckCode" id="CheckCode" value="Check Code"> <br/> <br/> </p> </form> and I am using the following code in my php file: <?php$coupon_code = $_POST['couponcodenumber'];if ($coupon_code = $some_other_value) { $redirected_address = 'Location: specialordersDiscountForm.php'; header ($redirected_address); exit();} else { $redirected_address = 'Location: specialorderwrongcode.php'; header ($redirected_address); exit();}?> () Not sure where the issue is in these coding but it is not working to redirect users depending on their coupon input as intended. Can anyone supply me with a working code or explain what the issue is? thanks! i have an array called $imageArray like this Array ( [0] => 'Dashka'_Darren_Sheehan_1.jpg [1] => 'Dashka'_Darren_Sheehan_10.jpg [2] => 'Dashka'_Darren_Sheehan_2.jpg [3] => 'Dashka'_Darren_Sheehan_3.jpg [4] => 'Dashka'_Darren_Sheehan_4.jpg [5] => 'Dashka'_Darren_Sheehan_5.jpg [6] => 'Dashka'_Darren_Sheehan_6.jpg [7] => 'Dashka'_Darren_Sheehan_7.jpg [8] => 'Dashka'_Darren_Sheehan_8.jpg [9] => 'Dashka'_Darren_Sheehan_9.jpg [10] => . [11] => .. [12] => Aaron_Kidney_1.jpg [13] => Aaron_Kidney_10.jpg [14] => Aaron_Kidney_11.jpg [15] => Aaron_Kidney_12.jpg [16] => Aaron_Kidney_13.jpg [17] => Aaron_Kidney_14.jpg [18] => Aaron_Kidney_15.jpg [19] => Aaron_Kidney_16.jpg [20] => Aaron_Kidney_17.jpg [21] => Aaron_Kidney_18.jpg and i also have another array called $_names Array ( [0] => 'Dashka'_Darren_Sheehan [1] => Beefit_Gyms [2] => Aaron_Kidney [3] => Dean_Mitchell [4] => Colin_O_Neill [5] => Keith_McManus ) if a name in array $_names exists in the $imageArray i want to insert the images for that person into one column of a table like this <tr> <?php foreach ($names as $name): ?><th><?php htmlout($name); ?></th><?php endforeach; ?> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_1.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_1.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td><img src="../images/'Dashka'_Darren_Sheehan_2.jpg" width="204"/></td> <td><img src="../images/Aaron_Kidney_2.jpg" width="204"/></td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> can anyone help me write the logic for this?? I cant figure it out... Hi im still learning php and have been running through the tutorials on making a user authentication system but im getting an error on one line but ive got the same code else where and its fine... Code: [Select] // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } Im getting the error on the if statment but no matter what i try it still tells me theres an error... Heres the full function code: Code: [Select] function account_namevalid() { // parameter for use with strspan $span_str = "abcdefghijklmnopqrstuvwxyz" . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"; // Must have at least one character if (strspn($_POST['user_name'],$span_str) == 0) { return false; } // Must contain all legal characters if (strspn($_POST['user_name'],$span_str) != srnlen($name)) { return false; } // Min and Max length if ($strlen($_POST['user_name']) < 5) { return false; } if strlen($_POST['user_name']) > 25 { return false; } // Illegal names if (eregi("^((root)|(bin)|(deamon)|(adm)|(lp)|(sync)|(shutdown)|(halt)|(mail)|(news)|(uucp)|(operator)|(games)|(mysql)| (httpd)|(nobody)|(dummy)|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(download)))$", $_POST['user_name'])) { return false; } if (eregi("^(anoncvs_)", $_POST['user_name'])) { return false; } return true; } Any help or info would be greatfull... Cheers Chris So I'm sitting at my desk scratching my head on how to do a task where I pull information form a database (that i know how to do) but then i need to see if two variables equal a string and if they do count out how many times that two variables equal there two string checks and out put the counted number ? this is what I have thought of but dose not to work because I cant figure out a way to code it? $dbPull = mysql_fetch_array($result) if( $dbPull['Foo'] == 'string1' && $bdPull['Bar'] == 'string2') this is were I get lost I'm looking for (how many times in the DB dose String2 show up in the array were the above, IF statement is true ) any ideas would be most appreciated Ok, so there are two functions, one encrypts data, the other one must decrypt. But I do not know how to implement it to decrypt. I need to know how to use the second function (number_decrypt). I need it so I enter the encrypted string into a text field and it outputs the decypted string. I dont need the html, I just dont understand how to implement it. Can someone look at this for me and possibly tell me how I could achieve this? Heres the code: function number_encrypt($plain) { mt_srand ((double) microtime() * 1000000); $password = ''; for ($i=0; $i<10; $i++) { $password .= rand(1,1000); } $salt = substr(md5($password), 0, 2); $password = md5($salt . $plain) . ':' . $salt; return $password; } function number_decrypt($encrypted,$plain) { $stack = explode(':', $encrypted); if (sizeof($stack) != 2) return false; if (md5($stack[1] . $plain) == $stack[0]) { return true; } return false; } Thanks! Okay, the function appears to work just fine, except it doesn't add to the database. I don't have any errors, so I'm not quite sure what is going on. I've got an echo on the $id and $item_id, and both were pulling correctly. Just not being added to the table `sale`... Anyone help? Thanks in advance! function addshopinv($id) { error_reporting(E_ALL); ini_set('display_errors', 1); if (isset($_POST["submit"])) { extract($_POST); $errors = 0; $errorlist = ""; if ($name == "") { $errors++; $errorlist .= "Name is required.<br />"; } else if ($errors == 0) { $dbh=dbconnect() or die ("Userlist read error: " . mysql_error()."<br>"); mysql_select_db("XXX"); $query = mysql_query("SELECT id FROM items WHERE name='$name'"); while ($result = mysql_fetch_array($query)){ $item_id = $result['id']; echo $id; $query1 = mysql_query("INSERT INTO sale SET shop_id='$id', item_id='$item_id"); } admindisplay("Inventory Item Added.","Add New Inventory Item"); } else { admindisplay("<b>Errors:</b><br /><div style=\"color:red;\">$errorlist</div><br />Please go back and try again.", "Add New Item to Shop"); } } |