PHP - Unable To Get Insert To Work Correctly?
MySQL version 5.1.73-cll
I can't seem to get the inventory table to insert the information I have stared in an array any help would be appreciated!!
<?php $username = $_SESSION['username']; ini_set('display_errors',1); error_reporting(E_ALL); //include "php/db/db_config.php"; include "php/db/db_config.php"; include "php/db/item_connect.php"; $id = $items_id['id']; $player = $account_info['player_id']; //Update database $sql = mysqli_query($my_database,"INSERT INTO inventory ( player_id, username, id ) VALUES('$player', '$username', '$id')"); //echo values of item id echo "<div class=\"loot\">"; echo "<b>Required Level:" . $items_id['requ_level'] . "</b><br />"; echo "<b>Name:" . $items_id['name'] . "</b><br />"; echo "<b>Min Str:" . $items_id['min_str'] . "<br />"; echo "<b>Min Int:" . $items_id['min_int'] . "<br />"; echo "<b>Min Dex:" . $items_id['min_dex'] . "<br />"; echo "<b>Type:" . $items_id['type']. "<br />"; echo "<b>Min Physical Dmg:" . $items_id['min_dmg'] . "<br />"; echo "<b>Max Physical Dmg:" . $items_id['max_dmg'] . "<br />"; echo "<b>Min Magic Dmg:" . $items_id['mag_attk_min'] . "<br />"; echo "<b>Max Magic Dmg:" . $items_id['mag_attk_max'] . "<br />"; echo "<b>Phys Defense:" . $items_id['phy_def'] . "<br />"; echo "<b>Magical Defense:" . $items_id['mag_def'] . "<br />"; echo "</div>"; ?>I get no errors or notices and the info fields show up as being populated. Similar TutorialsHello....I am using ajax,jquery with php to insert data in db.....but the script is not working. form.html: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> label{ display:block; } </style> <script type="text/javascript" src="jquery-1.5.min.js"> </script> <script type="text/javascript"> $(function() { $('#submit').click(function(){ $('#container').append('<img src="ajax-loader.gif" id="loading" alt="image" />'); var name=$('#name').val(); var email=$('#email').val(); var d=$('#d').val(); var m=$('#m').val(); var y=$('#y').val(); var add=$('#add').val(); var phone=$('#phone').val(); $.ajax({ url: 'process.php', type: 'POST', data: 'name=' + name + '&email=' + email + '&d=' + d + '&m=' + m + '&y=' + y + '&add=' + add + '&phone=' + phone, success: function(result){ $('#response').remove(); $('#container').append('<p id="response">' + result + '</p>'); $('#loading').fadeOut(500,function(){ $(this).remove(); }); } }); return false; }); }); </script> </head> <body> <h2>User Registeration</h2> <form action="process.php" method="POST"> <div id="container"> Name:<br> <input type="text" name="name" id="name" /><br> Email:<br> <input type="text" name="email" id="email" /><br> Date Of Birth:<br> <input type="text" id="d" name="d" size="2" /> <input type="text" id="m" name="m" size="2" /> <input type="text" id="y" name="y" size="4" /><br> Address:<br> <input type="text" id="add" name="add" /><br> Phone:<br> <input type="text" id="phone" name="phone" /><br> <input type="submit" name="submit" id="submit" value="GO!" /> </div> </form> </body> </html> process.php My db id named "jquery" and table is "tab" Code: [Select] <?php $conns=mysql_connect("localhost","root",""); if(!$conns) echo "error in connection"; mysql_select_db("jquery", $conns); $name=$_POST['name']; $email=$_POST['email']; $m=$_POST['m']; $d=$_POST['d']; $y=$_POST['y']; $add=$_POST['add']; $phone=$_POST['phone']; echo $name,"<br>"; echo $email,"<br>"; echo $m, "<br>"; echo $d,"<br>"; echo $y,"<br>"; echo $add, "<br>"; echo $phone,"<br>"; $query="INSERT INTO tab (name,email,d,m,y,add,phone) VALUES ('$name',$email','$d','$m','$y','$add','$phone')"; if(!mysql_query($query,$conns)) echo "Error"; else echo "DATA inserted"; ?> The output shown is: pulkit pulkit@gmail.com 1 26 1991 lucknow 987576787 Error For some values i entered. Hello all, I hope you are doing great.I am using phpmyadmin for the first time.So I created a table called guestbook with 4 attributes: id,name,email,message..Then I created a php file with the following code (saved in htdoc in Xampp folder)and html form which would take the data from the user and insert into the database which could later be retrieved.So far I have just written the insertion code which successfully creates the form but when I click on submit button it opens the same php file with the code and no insertion is made in the database..here is my code..please help me urgently..i have my project deadline very soon. php file called guest.php: <?php $user="root"; $password=""; $database="Guestbook"; $name=$_POST['name']; $email=$_POST['email']; $body=$_POST['body']; $connect("localhost",$user,$password); mysql($connect); @mysql_select_db($database)or die("unable to select db"); $query = mysql_query("INSERT INTO Guestbook(id,name,email,body) VALUES('','$name','$email','$body')"); if(!$query) { echo mysql_errno().':'.mysql_error(); } mysql_close(); ?> html file called new.html: <html> <head> <title>Guestbook</title> </head> <body> <form method="post" action="guest.php" > Name:<input type="text" name="name" size="30"/><br/> Email: <input type="text" name="email" size="30"/><br/> <p>Text:<br/> <textarea name="message" rows="15" cols="60"></textarea></p> <br/> <input type="submit" value="Submit"/> <input type="reset" value="Clear"/> </form> </body> </html> Hello everyone !!! I am sorry if my vocabulary is not exact because english is not my first language. Also i am a newbie at PHP. I am doing this project for myself and if it work might be able to use it at work. But i am doing this to learn. I have been stuck on this problem for 2 weeks and i can t figure it out on my own. Ihave spend many hours searching forums but no success. Oh yeah i almost forgot some part of code are from me, some are scripts from internet i adapted. I have a form with a dropdown menu and when i submit the form the value selected in the dropdown would be inserted in a table. The problem i have is that whatever the value i select it always inserts the last value of the dropdown in the table??? The form is made with the dropdown as an include. It is populated with values from an another table. Here is the code for the dropdown list: Code: [Select] <form> <select name="nom_pcu_form" method="post"> <?php $SQL = "SELECT * FROM pcu ORDER BY nom_pcu"; $res = mysql_query($SQL); while($val=mysql_fetch_array($res)) { $nom=$val["nom_pcu"]; $prenom=$val["prenom_pcu"]; $nom_complet = $prenom . $nom; echo "<option>".$val["nom_pcu"].", ".$val["prenom_pcu"]."</option>\n"; $nom_pcu_form="".$val["nom_pcu"].", ".$val["prenom_pcu"].""; } ?> </select> </form> Here is the part of the form wich calls the dropdown: Code: [Select] <form name="form2" method="post" action="Grille ecoute Permanent.php"> <p>Nom : <?php include 'liste_deroulante_pcu.php' ;?> <p>no carte appel <input name="no_carte_appel" type="text" id="no_carte_appel"> </p> <?php echo date("Y/m/d"); ?> </form> And this is the part where it is inserted in the table: Code: [Select] <?php if($_POST['doSubmit'] == 'Create') mysql_query("INSERT INTO grille_ecoute_pcu_permanent (`user_name`,`nom_pcu`,`no_carte_appel`,`question_1`,`question_2`,`question_3`,`question_4`, `question_5`,`question_6`,`question_7`,`question_8`,`question_9`,`question_10`,`question_11`,`question_12`,`question_13`,`question_14`,`question_15`, `question_16`,`question_17`,`question_18`,`question_19`,`question_20`,`question_21`,`question_22`,`question_23`,`question_24`,`question_25`,`question_26`, `question_27`,`question_28`,`question_29`) VALUES ('$user_name','$nom_pcu_form','$no_carte_appel','$question_1','$question_2','$question_3','$question_4','$question_5','$question_6', '$question_7','$question_8','$question_9','$question_10','$question_11','$question_12','$question_13','$question_14','$question_15','$question_16','$question_17', '$question_18','$question_19','$question_20','$question_21','$question_22','$question_23','$question_24','$question_25','$question_26','$question_27','$question_28', '$question_29') ") or die(mysql_error()); Note:$user_name and all $question are inserted correctly in the table. $nom_pcu_form is the dropdown and it only records the last value of the dropdown even if it s not the value selected. $no_carte_appel are not recorded at all thanks for your time I've got PHP setup on Ubuntu with MySQL. I've got sendmail installed but for some reason I can't get mail() to work. Does anyone have good guidelines for getting this setup properly? Here's my website page with the Contact Form: http://www.3dmark3t.com/contact.html Now the problem is if you don't fill out any info it will have an error message with all the things but not the selection. when I get the email it shows if the user has selected something out of the selection box but it doesn't have an error message and it still goes through even if you don't select something. could someone please help me with my PHP form validation. PHP: Code: [Select] <?php if(isset($_POST['email'])) { // CHANGE THE TWO LINES BELOW $email_to = "user@domain.com"; $email_subject = "3DMark3t Contact:"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { if(isset($_POST['formGender']) ) { $errorMessage = ""; $var3dmodels = $_POST['3DModels']; $vargraphic_design = $_POST['Graphic Design']; $varweb_design = $_POST['Web Design']; $vartutorials = $_POST['Tutorials']; $varreport = $_POST['Report']; $varrequests = $_POST['Requests']; } died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $formGender = $_POST['formGender']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(!isset($_POST['formGender'])) { $errorMessage .= "<li>You forgot to select your Gender!</li>"; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "3DMark3t Contact:"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Select One: ".clean_string($formGender)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- place your own success html below --> Thank you for contacting us. We will be in touch with you very soon. <meta http-equiv="refresh" content="3; URL=http://www.3dmark3t.com" /> <?php } die(); ?> HTML: Code: [Select] <html> <head> </head> <body> <form name="htmlform" method="post" action="php/html_form_send.php"> <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="select">Select One *</label> </td> <td valign="top"> <select name="formGender"> <option value="">Select...</option> <option value="3DModels">3DModels</option> <option value="Graphic Design">Graphic Design</option> <option value="Web Design">Web Design</option> <option value="Tutorials">Tutorials</option> <option value="Report">Report</option> <option value="Requests">Requests</option> </select> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments *</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="32.5" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> </body> </html> I am using PHP 5.5 on windows 8 and I am trying to localize my website to multiple languages while everything is OK on remote host , the gettext function does not work correctly in my localhost. I have implemented the whole tutorial of http://www.sitepoint...applications-1/ step by step but it seems setlocale(LC_ALL, "en_US") fails and I don't know how to correct or install "en_US" in my system. when I use "en-US" instead of "en_US" the sellocale function does not return FALSE but again the gettext function return the original string.
Problem - http://runehints.com/calculators/mining?rsname=gaogier&action=calculator So far all is correct, once you click calculate the problems start. If I do a little math, level 67 is the target, with 548028 xp, minus the current xp of 533469 that = 14559 14559 / 50 xp per coal = x amount of coal which is 291.18 coal. Now, my calculator is saying, 33173 is the answer. Which it clearly is not the case. The URL I get, http://runehints.com/calculators/mining?rsname=gaogier&action=calculate&cxp=533469&lvl=2192114 if you change the last part (2192114) to 548028 it nearly works out to be right, as it shows 291 coal. http://runehints.com/calculators/mining?rsname=gaogier&action=calculate&cxp=533469&lvl=548028 I plan to get this script rewritten over the next couple of months, is it worth fixing it? I mean can you spot the error? <?php preg_match('~calculators\/([a-zA-Z]+)~', $_SERVER['REQUEST_URI'], $which); $which = $which[1]; ?> <div id="contenttitle"><?php echo ucfirst($which); ?> Calculator</div> <div class="news"> <?php preg_match('~(agility|attack|combat|cooking|crafting|defence|farming|firemaking|fishing|fletching|herblore|hitpoints|magic|mining|prayer|ranged|runecrafting|slayer|strength|summoning|thieving|woodcutting)~', $_SERVER['REQUEST_URI'], $url); $uri = $url[1]; if (empty($uri)) { echo '<table class="guide"> <tr class="trtitle"> <th class="main">Skill Name</th> <tr> <tr> <td><a href="/calculators/agility">Agility</a></td> <tr> <tr> <td><a href="/calculators/attack">Attack</a></td> <tr> <tr> <td><a href="/calculators/cooking">Cooking</a></td> <tr> <tr> <td><a href="/calculators/crafting">Crafting</a></td> <tr> <tr> <td><a href="/calculators/defence">Defence</a></td> <tr> <tr> <td><a href="/calculators/farming">Farming</a></td> <tr> <tr> <td><a href="/calculators/fishing">Fishing</a></td> <tr> <tr> <td><a href="/calculators/fletching">Fletching</a></td> <tr> <tr> <td><a href="/calculators/herblore">Herblore</a></td> <tr> <tr> <td><a href="/calculators/hitpoints">Hitpoints</a></td> <tr> <tr> <td><a href="/calculators/magic">Magic</a></td> <tr> <tr> <td><a href="/calculators/mining">Mining</a></td> <tr> <tr> <td><a href="/calculators/prayer">Prayer</a></td> <tr> <tr> <td><a href="/calculators/ranged">Ranged</a></td> <tr> <tr> <td><a href="/calculators/runecrafting">Runecrafting</a></td> <tr> <tr> <td><a href="/calculators/slayer">Slayer</a></td> <tr> <tr> <td><a href="/calculators/strength">Strength</a></td> <tr> <tr> <td><a href="/calculators/summoning">Summoning</a></td> <tr> <tr> <td><a href="/calculators/thieving">Thieving</a></td> <tr> <tr> <td><a href="/calculators/woodcutting">Woodcutting</a></td> <tr> </table>'; } else { # All Calculator - calculate.php # Orignally created on 28 December 2004 remade using RS Hiscores on 9 June 2005 # Created by Joseph Jeffery of DSIBaN Designs //This page functions as every calculator //set page headers $lvl = 0; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; /** * Return current xp for specific skill */ function return_exp($name, $skill) { $url = "http://hiscore.runescape.com/index_lite.ws?player=" . strtolower(str_replace(' ', '_', $name)); if (($page = @file_get_contents($url)) === false) { echo "User $name was not found in the highscores for $skill"; return false; } if(strpos($page, "<html>")) { trigger_error('Unable to parse RuneScape highscore page', E_USER_WARNING); echo "<h1>DUMP</h1>"; } $catagories = split(' ', $page); //Find proper index for skill switch($skill) { case "attack": $ind = 1; break; case "defence": $ind = 2; break; case "strength": $ind = 3; break; case "constitution": $ind = 4; break; case "ranged": $ind = 5; break; case "prayer": $ind = 6; break; case "magic": $ind = 7; break; case "cooking": $ind = 8; break; case "woodcutting": $ind = 9; break; case "fletching": $ind = 10; break; case "fishing": $ind = 11; break; case "firemaking": $ind = 12; break; case "crafting": $ind = 13; break; case "smithing": $ind = 14; break; case "mining": $ind = 15; break; case "herblore": $ind = 16; break; case "agility": $ind = 16; break; case "thieving": $ind = 17; break; case "slayer": $ind = 18; break; case "farming": $ind = 20; break; case "runecrafting": $ind = 21; break; case "hunter": $ind = 22; break; case "construction": $ind = 23; break; case "summoning": $ind = 24; break; case "dungeoneering": $ind = 25; break; } $skill_info = split(",", $catagories[$ind]); $skill_exp = $skill_info[2]; return $skill_exp; } function enter_name(){ $skill = $_GET['skill']; $mem = $_GET['members']; $_GET['action'] = 'calculator'; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; echo '<form action="" method="get"> <p>Runescape name: <input type="text" name="rsname" class="text" value="' . $rsn . '" /> <input type="hidden" name="action" value="calculator" /></p> <input type="submit" class="text" value="Grab XP" onMouseOver="this.style.cursor=\'hand\';"/> </form><br /> '; } function calculator(){ preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skill); $skill = $skill[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; if($rsn != "") { $xp = return_exp($rsn, $skill); } $mem = $_GET['members']; if ($xp > 13034430){ echo 'You\'re already level 99!'; } ?> <form action="" method="get"> <table border="0" class="calcinput"> <input type="hidden" name="rsname" value="<?php echo $rsn; ?>"> <input type="hidden" name="action" value="calculate" /> <tr><td>Current Xp:</td><td> <input type="text" name="cxp" class="text" value="<?php if ($xp != "0") { echo $xp; } ?>" /></td></tr> <tr><td>Current Level:</td><td><input type="text" class="text" value="<?php echo getLevel($xp); ?>" /></td></tr> <tr><td>Desired Level:</td><td> <SELECT name="lvl" class="text"><?php genDropDown($xp); ?> </select> <?php if ($mem == "yes"){ echo '<tr><td>Show members items?:</td><td> <input name="showmembers" type="checkbox" disabled="true" value="yes" checked></td></tr> '; }else{ echo '<tr><td>Hide members items?:</td><td> <input name="showmembers" type="checkbox" value="no"></td></tr> '; } ?> <tr><td><input type="submit" class="text" value="Calculate" onMouseOver="this.style.cursor='hand';"/></td><td> <input type="reset" class="text" value="Reset" onMouseOver="this.style.cursor='hand';"/></td></tr> </table> <?php } /*Calculate level based on experience function getLevel($xp) { $a = 0; for($i = 0; $i < 100; $i++) { if($a / 4 > $xp) { return $i; } $a += floor($i + 300 * pow(2, ($i / 7))); } } */ function getLevel($exp){ $levels = array(1 => 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466, 247866, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953, 605032, 668051, 737627, 814445, 899256, 992895, 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1968068, 2192818, 2421087, 2673114, 2951373, 3258594, 3597729, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7994614, 8771558, 9684577, 10692629, 11805606, 13034431); $l = count($levels); while ($levels[$l] > $exp) $l--; return $l; } //Generate dropdowns based on xp function genDropDown($xp) { //Gather experience $a = 0; for($i = 0; $i < 100; $i++) { if($a / 4 > $xp) { if($lvl == 0) { $lvl = $i; } echo "<option value=\"$a\">Level $i - " . floor($a / 4) . " xp</option>"; } $a += floor($i + 300 * pow(2, ($i / 7))); } } function calculate(){ preg_match('~&lvl=(.*)~', $_SERVER['REQUEST_URI'], $lvl); $lvl = $lvl[1]; preg_match('~&cxp=(.*)&lvl~', $_SERVER['REQUEST_URI'], $cxp); $cxp = $cxp[1]; preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skills); $skills = $skills[1]; preg_match('~&action=(.*)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; $lev = $_POST['lev']; $xpn = $lvl - $cxp; if ($xpn == ""){ $xpn = $_GET['xpn']; } if ($lev == ""){ $lev = $_GET['lev']; } $show = $_GET['showmembers']; if ($show == "0"){ $show = $_POST['showmembers']; } switch($skills) { case 'firemaking': $skill = "fire"; $item = "Log"; break; case 'runecrafting': $skill = "rune"; $item = "Rune"; break; case 'ranging': $skill = "range"; $item = "Monster"; break; case 'herblore': $skill = "herb"; $item = "Herb/Potion"; break; case 'fishing': $skill = "fish"; $item = "Fish"; break; case 'cooking': $skill = "cook"; $item = "Food"; break; case 'woodcutting': $skill = "wood"; $item = "Log"; break; case 'agility': $skill = "agility"; $item = "Course"; break; case 'slayer': $skill = "slayer"; $item = "monster"; break; case 'farming': $skill = "farming"; $item = "Seed/Action"; break; case 'fletching': $skill = "fletching"; $item = "Item"; break; case 'magic': $skill = "magic"; $item = "Spell"; break; case 'mining': $skill = "mining"; $item = "Ore"; break; case 'smithing': $skill = "smithing"; $item = "Bar"; break; case 'thieving': $skill = "thieving"; $item = "Chest/Stall/Pickpocket"; break; case 'fighting': $skill = "fighting"; $item = "Monster"; break; case 'crafting': $skill = "crafting"; $item = "Item"; break; case 'prayer': $skill = "prayer"; $item = "Bones"; break; default: $skill = $skill[1]; $item = "Item"; } $mem = $_GET['members']; echo' <table border="0.5" cellspacing="1" cellpadding="2" align="center" bgcolor="#857553"> <tr><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Level needed</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=item&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">'.$item.'</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Experience given</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=xp&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Number of times</a></td><td class="tableheader"><a style="color: #EED8B4" href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=members&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers='.$show.'">Members?</a></td>'; require_once ('includes/connect.php');//connect to db $by = $_GET['orderby']; if ($mem == "no"){ if ($show == "no"){ $mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=no">Click here to show members items</a>'; $n_query = 'SELECT * FROM `'.$skill.'calc` WHERE `members`="0" ORDER BY `'.$by.'` ASC'; }else{ $mess = '<a href="'.$_SERVER['PHP_SELF'].'?action=calculate&skill='.$skill.'&orderby=level&xpn='.$xpn.'&lev='.$lev.'&members='.$mem.'&showmembers=yes">Click here to hide members items</a>'; $n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC'; } }else{ $n_query = 'SELECT * FROM `'.$skill.'calc` ORDER BY `'.$by.'` ASC'; } $n_result = mysql_query ($n_query); while ($n_row = mysql_fetch_assoc($n_result)) { $level = $n_row['level']; $course = $n_row['item']; $xpg = $n_row['xp']; $tot1 = $xpn / $xpg; $tot = sprintf('%.0f', $tot1); $members1 = $n_row['members']; if ($members1 == "1"){ $members = "Yes"; $bg2 = "#808080"; }else{ $members = "No"; $bg2 = "#FF8C00"; } if ($lev < $level){ $bg = "#049f2c"; }else{ $bg = "#006600"; } echo '<tr><td class="calc" bgcolor="'.$bg.'"onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg.'">'.$level.'</td><td>'.$course.'</td><td>'.$xpg.'</td><td>'.$tot.'</td><td class="calc" bgcolor="'.$bg2.'" onMouseOver="this.style.backgroundColor=\'#71828A\'" onMouseOut=this.style.backgroundColor="'.$bg2.'">'.$members.'</td>'; } echo' </table><br /> '; echo $lev; } preg_match('~rsname=(.*)&action~', $_SERVER['REQUEST_URI'], $rsnam); $rsn = $rsnam[1]; preg_match('~calculators\/(.*)\?rsname~', $_SERVER['REQUEST_URI'], $skill); $skill = $skill[1]; preg_match('~&action=([a-zA-Z0-9]+)~', $_SERVER['REQUEST_URI'], $action); $_GET['action'] = $action[1]; switch($_GET['action']) { case 'calculate': enter_name(); calculate(); break; case 'calculator': enter_name(); calculator(); break; case 'enter_name': enter_name(); calculator(); break; default: enter_name(); } } ?> </div> Hi Team, I have a php page where I have taken the same userid and linked in the next page and also used show/hide function. I am able to see that the userid is linking but when i submit the data is not getting insert and also no error Please help below is the Tower.php file. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP2</title> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1005px; height:578px; z-index:1; left: 157px; top: 1px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 35px; top: 35px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:243px; height:106px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:824px; height:271px; z-index:2; left: 44px; top: 237px; } .style4 { font-size: xx-large; font-style: italic; font-weight: bold; color: #FF9933; } #Layer8 { position:absolute; width:800px; height:139px; z-index:2; left: 31px; top: 67px; } #Layer9 { position:absolute; width:610px; height:30px; z-index:2; left: 34px; top: 70px; } #Layer10 { position:absolute; width:611px; height:25px; z-index:2; left: 33px; top: 110px; } #Layer11 { position:absolute; width:614px; height:30px; z-index:2; left: 33px; top: 152px; } #Layer12 { position:absolute; width:615px; height:29px; z-index:2; left: 32px; top: 193px; } #Layer13 { position:absolute; width:187px; height:35px; z-index:2; left: 318px; top: 239px; } --> </style> </head> <body> <div id="Layer1"> <form id="form5" name="form5" method="link" action="Insert.php"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="65" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <div align="center"><span class="style4">SELECT THE TOWER BELOW </span> <div id="Layer13"> <input type="hidden" name="empid" value="<?php echo $_GET['id']; ?>" size="20"> <input type="hidden" name="date" value="<?php echo date("Y-m-d H:i:s"); ?>" > <input type="submit" name="B1" value="Start !" /> </div> <div id="Layer12"> <div align="left"> <input name="rad1" type="radio" value="RF" id="rad1" /> <label >RF</label> </div> </div> <div id="Layer11"> <div align="left"> <input name="rad1" type="radio" value="ISAP" id="rad1" /> <label >ISAP</label> </div> </div> <div id="Layer10"> <div align="left"> <input name="rad1" type="radio" value="GSD" id="rad1" checked="checked" /> <label >GSD</label> </div> </div> <div id="Layer9"> <div align="left"> <input name="rad1" type="radio" id="rad1" value="CSD" /> <label>CSD</label> </p> </div> </div> <br /> </div> </div> </form> </div> </body> </html> Below is the insert.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>BHP DATA SUMBIT</title> <?php include ("count.php"); ?> <?php if(isset($_GET['action'])) { $action = $_GET['action']; if ($action = 'yes') { include ("Connection.php"); $PName = $_POST['rad11']; $Date = date("Y-m-d H:i:s"); $empidno = $_POST['idd']; $qsdate = $_POST['testinput']; $cb1 = $_POST['chkbox1']; $cb2 = $_POST['chkbox2']; $cb3 = $_POST['chkbox3']; $cb4 = $_POST['chkbox4']; $cb5 = $_POST['chkbox5']; $Com = $_POST['textfield2']; $dd1 = $_POST['textfield']; $dd2 = $_POST['select']; $dd3 = $_POST['select2']; $dd4 = $_POST['textfield4']; $dd5 = $_POST['textfield3']; $dd6 = $_POST['select3']; $sev = $_POST['radio1']; $olddate = $_POST['odate']; $pname = $_POST['radiobutton']; $query="INSERT INTO bhp ticketinformation (`userid`, `processname`, `begindate`, `dateposted`, `CALL`, `EMAIL`, `NEW`, `EXISTING`, `Piroty`, `MTICKET`, `Services`, `group1`, `group2`, `Icall`, `Tcreatedtime`, `comment`) VALUES ( '$empidno' , '$pname' , '$olddate' , '$Date' , '$cb1' , '$cb2' , '$cb3' , '$cb4' , '$sev' , '$dd1' , '$dd2' , '$dd3' , '$dd4' , '$dd5' , '$dd6' , '$Com')"; mysql_query($query); Header('location:tower.php?id=' . $empidno); } } ?> <head> <style type="text/css"> <!-- #Layer1 { position:absolute; width:1023px; height:592px; z-index:1; left: 167px; top: 2px; background-color: #993399; } #Layer2 { position:absolute; width:939px; height:114px; z-index:1; left: 59px; top: 3px; } #Layer3 { position:absolute; width:451px; height:169px; z-index:2; left: 270px; top: 296px; } #Layer4 { position:absolute; width:608px; height:68px; z-index:2; left: 273px; top: 10px; } #Layer5 { position:absolute; left:82px; top:188px; width:973px; height:52px; z-index:2; } #Layer6 { position:absolute; width:238px; height:69px; z-index:2; left: 68px; top: 43px; } .style1 { font-size: xx-large; font-style: italic; } .style2 {font-size: 52px} #Layer7 { position:absolute; width:979px; height:209px; z-index:2; left: 32px; top: 181px; } #Layer8 { position:absolute; width:194px; height:36px; z-index:1; left: 25px; top: 15px; } #Layer9 { position:absolute; width:178px; height:37px; z-index:2; left: 249px; top: 13px; } #Layer10 { position:absolute; width:193px; height:34px; z-index:3; left: 443px; top: 13px; } #Layer11 { position:absolute; width:204px; height:32px; z-index:4; left: 670px; top: 15px; } #Layer12 { position:absolute; width:195px; height:40px; z-index:5; left: 28px; top: 73px; } #Layer13 { position:absolute; width:182px; height:38px; z-index:6; left: 250px; top: 76px; } #Layer14 { position:absolute; width:197px; height:36px; z-index:7; left: 446px; top: 77px; } #Layer15 { position:absolute; width:214px; height:35px; z-index:8; left: 670px; top: 77px; } #Layer16 { position:absolute; width:315px; height:45px; z-index:9; left: 16px; top: 144px; } #Layer17 { position:absolute; width:343px; height:43px; z-index:10; left: 339px; top: 145px; } #Layer18 { position:absolute; width:258px; height:48px; z-index:11; left: 708px; top: 146px; } #Layer19 { position:absolute; width:321px; height:60px; z-index:3; left: 59px; top: 419px; } #Layer20 { position:absolute; width:197px; height:41px; z-index:1; left: 27px; top: 6px; } #Layer21 { position:absolute; width:193px; height:36px; z-index:2; left: 249px; top: 7px; } #Layer22 { position:absolute; width:207px; height:38px; z-index:3; left: 453px; top: 7px; } #Layer23 { position:absolute; width:237px; height:36px; z-index:4; left: 677px; top: 9px; } #Layer24 { position:absolute; width:245px; height:45px; z-index:5; left: 399px; top: 2px; } #Layer25 { position:absolute; width:99px; height:31px; z-index:6; left: 288px; top: 121px; } #Layer26 { position:absolute; width:87px; height:29px; z-index:7; left: 439px; top: 123px; } --> </style> <script language="JavaScript" > function showInfo() { var elem = document.getElementById('verify'); if(document.testform.select3.value == "verify" || document.testform.select3.value == "verify1" ) { elem.style.display="inline"; } else { elem.style.display="none"; } } </script> <script language="JavaScript"> function validator() { if(document.testform.Checkbox1.checked == false && document.testform.Checkbox2.checked == false && document.testform.Checkbox3.checked == false && document.testform.Checkbox4.checked == false) { alert ('You did not choose any of the checkboxes!'); return false; } if (document.testform.textfield.value =="") { alert("Enter Max Ticket No"); return false; } if (document.testform.select.value == "" || document.testform.select.value == "SELECT SERVICE DROP DOWN") { alert ('Select the SELECT SERVICE DROP DOWN'); return false; } if (document.testform.select2.value == "" || document.testform.select2.value == "SELECT RG GROUP") { alert ('SELECT RG GROUP'); return false; } if (document.testform.select3.value == "" || document.testform.select3.value == "SELECT GROUPS") { alert ('SELECT GROUPS'); return false; } if (document.testform.textfield2.value =="") { alert("Comments Feild is Empty.If there are no Comment then type NA(Not Applicable)"); return false; } if (document.testform.Checkbox1.checked == false) document.getElementById("chkbox1").value = ""; else document.getElementById("chkbox1").value = "EMAIL"; if (document.testform.Checkbox2.checked == false) document.getElementById("chkbox2").value = ""; else document.getElementById("chkbox2").value = "NEW"; if (document.testform.Checkbox3.checked == false) document.getElementById("chkbox3").value = ""; else document.getElementById("chkbox3").value = "EXISTING"; if (document.testform.Checkbox4.checked == false) document.getElementById("chkbox4").value = ""; else document.getElementById("chkbox4").value = "CALL"; alert('Record has been posted in the portal'); } </script> </head> <body> <div id="Layer1"> <div id="Layer2"> <div id="Layer6"><img src="AZimages/BHP-Billiton-logo.jpg" width="235" height="67" alt="BHP" /></div> <h1 align="center"> </h1> <div class="style1" id="Layer4"> <h1 align="center" class="style2">BHP DATA TRACKER </h1> </div> </div> <div id="Layer7"> <form method="POST" action="Insert.php?action=yes&&id=<?php echo $_GET['empid']; ?>" name="testform" onSubmit="return validator();"> <div id="Layer8"> <input type="checkbox" id="Checkbox4" name="checkbox4" value="CALL" /> CALL</label> </div> <div id="Layer9"> <label> <input type="checkbox" id="Checkbox1" name="checkbox1" value="EMAIL" /> EMAIL</label> </div> <div id="Layer10"> <label> <input type="checkbox" id="Checkbox2" name="checkbox2" value="NEW" /> NEW</label> </div> <div id="Layer11"> <label> <input type="checkbox" id="Checkbox3" name="checkbox3" value="EXISTING" /> EXISTING</label> </div> <div id="Layer12"> <label> <input name="radio1" type="radio" id="radio1" value="P1" checked="checked" /> P1</label> </div> <div id="Layer13"> <label> <input name="radio1" type="radio" id="radio1" value="P2" /> P2</label> </div> <div id="Layer14"> <label> <input name="radio1" type="radio" id="radio1" value="P3" /> P3</label> </div> <div id="Layer15"> <label> <input name="radio1" type="radio" id="radio1" value="P4" /> P4</label> </div> <div id="Layer16"> <label>MAXIMUM TICKET <input type="text" name="textfield" /> </label> </div> <div id="Layer17"> <label>SERVICE DROP DOWN <select name="select" style="width: 162px; height: 23px"> <option>SELECT SERVICE DROP DOWN</option> <option>OTHER(FW)</option> <option>1 MESSAGE</option> <option>1 MOBILITY</option> <option>1 VOICE</option> <option>1 SAP</option> <option>1 PORTAL</option> <option>1 COLLAB</option> <option>1 GSAP</option> <option>1 SECURITY</option> <option>1 WAN</option> <option>S DOMAIN</option> <option>1 AUTH</option> <option>1 DOCM</option> <option>1 REMOTE</option> </select> </label> </div> <div id="Layer18"> <label>RG GROUP <select name="select2" style="width: 162px; height: 23px"> <option>SELECT RG GROUP</option> <option>I-AM-AU-AM-HWT</option> <option>I-EUS-IN-CSC-DSK-CSD</option> <option>I-EUS-IN-CSC-DSK-GSD</option> <option>I-EUS-GB-DCS-BHPVICFW</option> <option>I-ITS-AU-HW</option> <option>I-SRM-AU-IAM-LAMU</option> <option>I-ITS-AU-SW</option> <option>C-BHP-AU-CSC-LSD-NONBRG</option> <option>C-BHP-AU-ACN-AQM</option> </select> </label> </div> </div> <div id="Layer19"> <label>SELECT GROUPS <select name="select3" onchange="showInfo()" style="width: 162px; height: 23px"> <option value="none" >SELECT GROUPS</option> <option value="verify">TP</option> <option value="verify1">OA</option> <option>OC</option> <option>OTHERS</option> </select> </label> <div id="verify" style="display:none;"> <br/><br/> <label>INCOMING CALL/EMAIL TIME <input type="text" name="textfield4" /> </label> <br/><br/> <label>MAXIMO TICKET CREATED TIME <input type="text" name="textfield3" /> </label> </div> <div id="Layer24"> <label>COMMENTS <input type="text" name="textfield2" /> </label> </div> <div id="Layer26"> <input name="Reset" type="reset" id="Reset" value="Reset" /> </div> <div id="Layer25"> <input type="submit" name="Submit" value="Submit" /> <input type="hidden" name="chkbox1" id="chkbox1" /> <input type="hidden" name="chkbox2" id="chkbox2" /> <input type="hidden" name="chkbox3" id="chkbox3" /> <input type="hidden" name="chkbox4" id="chkbox4" /> <input type="hidden" name="chkbox5" id="chkbox5" /> <input type="hidden" name="rad11" id="rad11" value="<?php echo $_GET['rad1']; ?>" /> <input type="hidden" name="idd" id="idd" value="<?php echo $_GET['empid']; ?>" /> <input type="hidden" name="odate" id="odate" value="<?php echo $_GET['date']; ?>" /> </form> </div> </div> </div> </body> </html> THANKS IN ADVANCED I don't understand why won't my INSERT work. Nothing gets inputted to the database.Why ? Code Code: [Select] $sql = "INSERT INTO payout (member_id, binary, tds, service, total, dues, amount_paid) VALUES ('".$memid."', '".$binary."', '".$tds."', '".$service."', '".$total."', '".$dues."', '".$amount_paid."')"; $execsql = mysql_query($sql); SQL table Code: [Select] CREATE TABLE IF NOT EXISTS `payout` ( `member_id` int(8) NOT NULL, `binary` int(10) NOT NULL, `tds` decimal(7,2) NOT NULL, `service` decimal(7,2) NOT NULL, `total` int(10) NOT NULL, `dues` int(10) NOT NULL, `amount_paid` int(10) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; My while loop to do the process to every member_id won't work.Its only printing one member_id thats done.Also my INSERT statement wont insert even that 1 member_id. Can someone please point my mistake. Code: [Select] <?php include 'config.php'; function tree_gather($node) { $sql = "SELECT lchild,rchild FROM tree WHERE parent = '$node'"; $execsql = mysql_query($sql); $array = mysql_fetch_array($execsql); if(!empty($array['lchild']) || !empty($array['rchild'])) { if(!empty($array['lchild'])) $child[] = $array['lchild']; if(!empty($array['rchild'])) $child[] = $array['rchild']; if(!empty($array['lchild'])) $lchild = tree_gather($array['lchild']); if(!empty($array['rchild'])) $rchild = tree_gather($array['rchild']); if(!empty($lchild) && !empty($rchild)) { $merge_both = array_merge($lchild, $rchild); $child = array_merge($child, $merge_both); } elseif(!empty($lchild) && empty($rchild)) $child = array_merge($child, $lchild); elseif(!empty($rchild) && empty($lchild)) $child = array_merge($child, $rchild); } return $child; } $sql = mysql_query("SELECT member_id FROM member"); while($array = mysql_fetch_array($sql)) { $memid = $array['member_id']; $pair = tree_gather($memid) ; $remove = mysql_query("SELECT lchild,rchild FROM tree WHERE parent ='".$memid."'"); $remove_array = mysql_fetch_array($remove); if(!empty($remove_array['lchild']) || !empty($remove_array['rchild'])) { $count = count($pair); for($i = 0 ; $i < $count ; $i++) { if($pair[$i] != $remove_array['lchild'] && $pair[$i] !=$remove_array['rchild']) { $trimmed[] = $pair[$i]; } else { $two_one[] = $pair[$i]; } } } $add = mysql_query("SELECT lchild,rchild FROM tree WHERE parent='".$remove_array['lchild']."'"); $add_array = mysql_fetch_array($add); if(!empty($add_array['lchild']) || !empty($add_array['rchild'])) { $count = count($trimmed); for($i=0;$i < $count ; $i++) { if(!empty($add_array['lchild'])) { if($add_array['lchild'] == $trimmed[$i]) { $two_one[] = $add_array['lchild']; unset($trimmed[$i]); $done = 1; break; } } if(!empty($add_array['rchild']) && $done !=1) { if($add_array['rchild'] == $trimmed[$i]) { $two_one[] = $trimmed[i]; unset($trimmed[$i]); $done = 1; break; } } } } if($done != 1) { $add = mysql_query("SELECT lchild,rchild FROM tree WHERE parent='".$remove_array['rchild']."'"); $add_array = mysql_fetch_array($add); if(!empty($add_array['lchild']) || !empty($add_array['rchild'])) { $count = count($trimmed); for($i=0;$i < $count ; $i++) { if(!empty($add_array['lchild'])) { if($add_array['lchild'] == $trimmed[$i]) { $two_one[] = $add_array['lchild']; unset($trimmed[$i]); $done = 1; break; } } if(!empty($add_array['rchild']) && $done !=1) { if($add_array['rchild'] == $trimmed[$i]) { $two_one[] = $trimmed[i]; unset($trimmed[$i]); $done = 1; break; } } } } } $select_child = mysql_query("SELECT rchild,lchild FROM tree WHERE parent='".$memid."'"); $select_array = mysql_fetch_array($select_child); if(!empty($select_array['rchild'])) $rchild = tree_gather($select_array['rchild']); $rchild[] = $select_array['rchild']; if(!empty($select_array['lchild'])) $lchild = tree_gather($select_array['lchild']); $lchild[] = $select_array['lchild']; if(!empty($rchild)) { $right_count = count($rchild); } if(!empty($lchild)) { $left_count = count($lchild); } if($right_count < $left_count) { $pair_num = $right_count; } elseif($right_count == $left_count) { $pair_num = $right_count - 1; } else { $pair_num = $left_count; } if(count($two_one) == 3) { $dues_adjust = 100; if($pair_num >= 1) { $dues_adjust = $dues + 100; $calcom = 200 * $pair_num; $tds = 20.60 * $pair_num; $service = 9.40 * $pair_num; $paid = $calcom - $dues_adjust; $insert = mysql_query("INSERT INTO `payout` (member_id, binary, tds, service, total, dues, amount_paid, dues_adjust, pairs) VALUES ('".$memid."', '".$calcom."', '".$tds."', '".$service."', '".$calcom."', '0', '".$paid."', '".$dues_adjust."', '".$pair_num."')"); unset($pair); echo "<br />".$memid." Done"; } } } ?> Hi Guys, in code below i dont see any reason why it doesnt add anything into my mysql, can u please tell me where is wrong? <?php session_start(); include ("includes/db.php"); include ("includes/function.php"); //authentication if (loggedin()==FALSE) { Header("Location: login.php"); exit(); } //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; echo "Welcome, " .$_SESSION['username']."!<p>"; //get details from user table to be passed to page(text fields) $getdetails=mysql_query("SELECT * FROM users WHERE username='$username'"); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $first_name=$row['first_name']; $last_name=$row['last_name']; $email=$row['email']; } /////////////////////////////////////// //****************************// //post starts here if (isset($_POST['next']) && $_POST['next']) { $myfirstname = addslashes(strip_tags($_POST['firstname'])); $mylastname = addslashes(strip_tags($_POST['lastname'])); $myemail = addslashes(strip_tags($_POST['email'])); $mybookingdate = addslashes(strip_tags($_POST['datetime'])); $mytime = addslashes(strip_tags($_POST['time'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumber'])); $ride_id=1; //check if booking exists $checkbooking=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND seat_no='$myseatnumber'"); if (mysql_num_rows($checkbooking)>=1) { echo "Seat No $myseatnumber For $mybookingdate at $mytime has been already taken, Please try a different seat, time or date"; } else { $addbooking=mysql_query("INSERT INTO booking (ride_id, users_id, time, date, seat_no) VALUES ('$ride_id','$users_id','$mytime','$mybookingdate','$myseatnumber'"); } } ?> <html> <head> <link type="text/css" href="css/smoothness/jquery-ui-1.8.6.custom.css" rel="stylesheet" /> <script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="includes/jquery-ui-1.8.6.custom.min.js"></script> <script type="text/javascript"> $(function() { $('#datetime').datepicker({ dateFormat: 'dd.mm.yy' }); }); </script> </head> <body> <form name="booking" method="post" action=""> <p>First Name:<br /> <input type="text" name='firstname' value="<? echo "$first_name";?>"> <p>Last Name:<br /> <input type="text" name='lastname' value="<? echo "$last_name";?>"> <p>Email:<br /> <input type="text" name='email' value="<? echo "$email";?>"> <p>Choose a Date:<br /> <input type="text" name='datetime' id="datetime"> </p> <p> Select a Time:<br/> <select name='time'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> </p> <p> Select Seat Number:<br/> <select name='seatnumber'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> <input type='submit' name='next' value='Next Step'> </form> <p> </body> </html> Hi coders,
i have a js to add multiple input and its depend to a user how many input should he want to add. and my problem is, it work insert data in a first line of rows but the rest of rows are not save.
any idea, what should i add to make it work.
js
<script> $(document).ready(function(){ $('#add').click(function(){ var inp = $('#box'); var i = $('input').size() + 1; $('<div id="box' + i +'"><input type="text" id="name" class="name" name="code[]' + i +'" placeholder="Input '+i+'"/><img src="remove.png" width="32" height="32" border="0" align="top" class="add" id="remove" /> </div>').appendTo(inp); i++; }); $('body').on('click','#remove',function(){ $(this).parent('div').remove(); }); }); </script>html <div id="box"> <input name = "code[]" type="text" id="name" class="name" placeholder="Input 1"> <img src="add.png" width="32" height="32" border="0" align="top" class="add" id="add" /> </div>php $rf = $_POST['regform']; $b = $_POST['branch']; $d = $_POST['date']; $c = $_POST['code']; $u = $_POST['user']; for($i = 0; $i<count($c); $i++) { $a_query = mysql_query("INSERT INTO code_number(ts_number,branch_id,yy,code,username) VALUES('$rf','$b','$d','$c[$i]','$u')"); } return $a_query; Code: [Select] <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = $_POST['username']; $password = $_POST['password']; $name = $_POST['name']; $server_type = $_POST['type']; $description = $_POST['description']; if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings! All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < 8) { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = $db->prepare("SELECT username,name FROM servers WHERE username = ? OR name = ? LIMIT 1"); $check1->execute(array($username, $name)); if($check1->rowCount() > 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; $insertQuery = $db->prepare("INSERT INTO servers (id, username, password, name, type, description, ip, votes, beta) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); $insertQuery->execute(array(null, $username, $password, $name, $server_type, $description, $ip, 0, 1)); if($insertQuery->errorInfo() > 0) { echo "Sorry, there was the following error:"; print_r($insertQuery->errorInfo()); } else { echo "Server has been succesfully created!"; } } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> Whats wrong with that page? :/ I have created a registration page to access my website. After the user registrate himself should appear an alert saying that the registration was OK and a redirect to main.php page... however for some reason if I create an insert statement the alert and the redirect don't appear... If I remove the insert the alert and the redirect works... why? This is part of the code of my 3 files: registration.php (ajax call) $('#submit').click(function() {var username2 = $('#uname2').val(); var password2 = $('#psw2').val(); $.ajax({ url: 'ajax/response.php', type: 'GET', data: {username2 : username2, password2: password2}, success: function(data) { if(data === 'correct') { alert("Username and Password have been created!"); //don' work with the insert location.replace("main.php"); //don' work with the insert } else { alert("Username or password are not correct... please register yourself!"); } } }); }); response.php (answer to ajax call) if(isset($_GET['username2']) && isset($_GET['password2'])) {$username2 = $_GET['username2']; $password2 = $_GET['password2']; if (checkUser($pdo, $username2) === true) { echo 'duplicate'; } else { insertUserPwd($pdo, $username2, $password2); //including this line the redirect and the alert doesn't work... the insert is OK echo 'correct'; } } data_access.php (the function works but doesn't permit alert and redirect to appear) function insertUserPwd(PDO $pdo, $usr, $pwd){ $data = [ 'id' => '', 'user' => $usr, 'password' => $pwd ]; $sql = "INSERT INTO users (id, user, password) VALUES (:id, :user, :password)"; $stmt= $pdo->prepare($sql); $stmt->execute($data); } Can someone help me to fix the code? If you also have any feedback on my code, please do tell me. I wish to improve my coding base. Basically when you fill out the register form, it will check for data, then execute the insert query. But for some reason, the query will NOT insert into the database. In the following code below, I left out the field ID. Doesn't work with it anyways, and I'm not sure it makes a difference. Code: Code: [Select] mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); Full code: Code: [Select] <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $name = mysql_real_escape_string($_POST['name']); $server_type = mysql_real_escape_string($_POST['type']); $description = mysql_real_escape_string($_POST['description']); if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings!<br/>All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40' name='description'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < 8) { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = mysql_query("SELECT username,name FROM servers WHERE username = '$username' OR name = '$name' LIMIT 1"); if(mysql_num_rows($check1) < 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); echo "Server has been succesfully created!"; } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> I'm missing something here. I have a form, and when the submit is pressed, the relevant post data inserts into table one, then I want the last insert id to insert along with other form data into a second table. The first table's still inserting fine, but I can't get that second one to do anything. It leapfrogs over the query and doesn't give an error. EDIT: I forgot to add an error: I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage, why VALUES ('14', '', '123', '','1234', '', '')' at line 1 query:INSERT INTO tbl_donar (donar_fname, donar_name, donar_address, donar_address2, donar_city, donar_state, donar_zip, donar_email, donar_phone, donar_fax, donar_company) VALUES ('test 14', 'asdfa', 'asdf', 'adf','asdf', '', '', '', '123', '', '') Code: [Select] if (empty($errors)) { require_once ('dbconnectionfile.php'); $query = "INSERT INTO tbl_donar (donar_fname, donar_name, donar_address, donar_address2, donar_city, donar_state, donar_zip, donar_email, donar_phone, donar_fax, donar_company) VALUES ('$description12', '$sn', '$description4', '$cne','$description5', '$description6', '$description7', '$description8', '$description9', '$description10', '$description11')"; $result = @mysql_query ($query); if ($result) { $who_donated=mysql_insert_id(); $query2 = "INSERT INTO tbl_donation (donor_id, donor_expyear, donor_cvv, donor_cardtype, donor_authorization, amount, usage, why) VALUES ('$who_donated', '$donate2', '$donate3', '$donate4','$donate5', '$donate6', '$donate7')"; $result2 = @mysql_query ($query2); if ($result2) {echo "Info was added to both tables! yay!";} echo "table one filled. Table two was not."; echo $who_donated; //header ("Location: http://www.twigzy.com/add_plant.php?var1=$plant_id"); exit(); } else { echo 'system error. No donation added'; Can anyone tell me why this is not INSERTing? My array data is coming out just fine.. I've tried everything I can think of and cannot get anything to insert.. Ahhhh! <?php $query = "SELECT RegionID, City FROM geo_cities WHERE RegionID='135'"; $results = mysqli_query($cxn, $query); $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($row = mysqli_fetch_array($results)) { $insert_city_query = "INSERT INTO all_illinois SET state_id=$row[RegionID], city_name=$row[City] WHERE id = null" or mysqli_error(); $insert = mysqli_query($cxn, $insert_city_query); if (!$insert) { echo "INSERT is NOT working!"; exit(); } echo $row['City'] . "<br />"; echo "<pre>"; echo print_r($row); echo "</pre>"; } //while ($rows = mysqli_fetch_array($results)) } //if (mysqli_num_rows($results)) else { echo "No results to get!"; } ?> Here is my all_illinois INSERT table structu CREATE TABLE IF NOT EXISTS `all_illinois` ( `state_id` varchar(255) NOT NULL, `city_name` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Here is my source table geo_cities structu CREATE TABLE IF NOT EXISTS `1` ( `CityId` varchar(255) NOT NULL, `CountryID` varchar(255) NOT NULL, `RegionID` varchar(255) NOT NULL, `City` varchar(255) NOT NULL, `Latitude` varchar(255) NOT NULL, `Longitude` varchar(255) NOT NULL, `TimeZone` varchar(255) NOT NULL, `DmaId` varchar(255) NOT NULL, `Code` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Hello, I'm having a bit of a problem here, all help to this issues would be much appreciated I am trying to use text boxes to insert numbers into the database based on what is inputed. If I have a string, like this for example: $variable = 09385493; And I want to insert it into the database like this: mysql_query("INSERT INTO integers(number) VALUES ('$variable')"); When checking the integers table in my database, looking at the number field, the $variable that was inserted is outputted as 9385493 Notice the number zero was taken out of the front of the number. If the number is double 0's (009385493), both of those zero's would disappear, too. Thanks I get the unable to jump to row zero mysql error. Code: [Select] function is_admin($uid, $cid) { $uid = (int)$uid; $cid = (int)$cid; $sql = "SELECT `users`.`id` AS `uid`, `companies`.`companyid` AS `cid`, `companies`.`adminid` AS `aid` FROM `companies` LEFT JOIN `users` ON `users`.`id` = companies.adminid WHERE `users`.`id` = {$uid} AND `companies`.`companyid` = {$cid}"; $user = mysql_query($sql); return (mysql_result($user, 0) == '1') ? true : false; } Hello, I've never really used the update command before for mysql and I'm attempting to use it and struggling a little bit. I'm trying to use mysqli prepared statements.. here's the code that I have thus far: if($query = $database->connection->prepare("UPDATE videos SET comments=?, views=?, uploader=? WHERE title = ?")) { $query->bind_param('iiss', $comments, $views, $uploader, $title); $query->execute(); $result = $query->affected_rows; $query->close(); } For some reason I cannot get this working. I have created a modification page for the administrators to be able change any of the values and wanting to update the database to reflect the changes. When using the MySQL UPDATE command do all of the values have to get changed or modified, or am I able to pass back some of the same values? Like with the above code.. if I only wanted to update the views, would I still be able to just pass in the same values for comments and uploader and it would just replace the values? |