PHP - Mysql Insert. Cannot Find Why The Insert Is Not Happening.
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; Similar TutorialsHello, ive got the right output from the code below, only my mysql query doesnt seem to be working as it should. Im not too great with mysql so please any help or suggestions would be great. I have tried the code but when I check my database nothing has been inserted. !?! Code: [Select] <?php include('db.php'); include('func.php'); ?><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Chained Select Boxes using PHP, MySQL and jQuery</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); function finishAjax(id, response) { $('#wait_1').hide(); $('#'+id).html(unescape(response)); $('#'+id).fadeIn(); } </script> </head> <body> <p> <form action="" method="post"> Name: <input type="text" name="Name" /><br /> Phone: <input type="text" name="Phone" /><br /> Email: <input type="text" name="Email" /><br /> Postcode: <input type="text" name="Postcode" /><br /> Web Address: <input type="text" name="Website" /><br /><br /> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $tier_two = $_POST['Subtype']; echo "You selected "; echo $drop." & ".$tier_two; } $Name = $_POST["Name"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $Postcode = $_POST["Postcode"]; $Website = $_POST["Website"]; echo "<br>"; echo $Name; echo "<br>"; echo $Website; mysql_query ("INSERT INTO business (Name, Type, Subtype, Phone, Email, Postcode, Web Address) VALUES ('$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website')"); ?> Im not sure it makes a difference but, I am adding data into each column of my database with the exception of the 1st column named 'ID' which is set to auto_increment. 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'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'; well this is truely embarrising...i have a insert statement which works within phpmyadmin but when using mysqli_query it returns a error.
INSERT INTO users (username, timestamp) VALUES ('test', UTC_TIMESTAMP())Unknown column 'timestamp' in 'field list' i've been playing about with this for a few hours now ...tried changing the column name (timestamp), adding ` around column names as well as table name. the column exists which is the strangest part, and ive even checked there is no space after the column name in the db. whats going on please? I don't understand where the empty value is. I've substituted the variables for text and still have the same problem. Code: Code: [Select] $sql = "INSERT INTO courses (course#, name, subject, semester, ap)VALUES('$courseNum', '$courseName', '$subject', '$semester', '$ap')"; Error: 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 '' at line 1 Hi guys I have a registration form working fine, my database is as below: userid username password repeatpassword I have added another column which is "name", users can update their profile once they have logged in so I have created updateprofile.php and when I login-->go to update profile and insert my name nothing adds to mysql name column this is my code below: <?php include ("global.php"); //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; //welcome messaage echo "Welcome, " .$_SESSION['username']."!<p>"; if ($_POST['register']) { //get form data $name = addslashes(strip_tags($_POST['name'])); $update = mysql_query("INSERT INTO users (name) VALUES ('$_POST[name]') WHERE username='$username'"); } ?> <form action='updateprofile.php' method='POST'> Company Name:<br /> <input type='text' name='name'><p /> <input type='submit' name='register' value='Register'> </form> can you please tell me where in this code is wrong? Im new in php so please excuse me if I have silly mistakes. thanks in advance I need help badly! What I want to do is insert into database the value from the selected radio group buttons.. All of them. There are 10 radio groups total (they can be less, but not more). Thanks! Code: [Select] <?php require_once('Connections/strana.php'); mysql_select_db($database_strana, $strana); ?> <link href="css/styles.css" rel="stylesheet" type="text/css" /> <table width="100%" height="100%" style="margin-left:auto;margin-right:auto;" border="0"> <tr> <td align="center"> <form action="" method="post" enctype="multipart/form-data" name="form1"> <table> <?php $tema = mysql_query("SELECT * from prasanja where tip=2")or die(mysql_error()); function odgovor1($string) { $string1 = explode("/", $string); echo $string1[0]; } function odgovor2($string) { $string1 = explode("/", $string); echo $string1[1]; } while ($row=mysql_fetch_array($tema)) { $id=$row['prasanje_id']; $prasanje=$row['prasanje_tekst']; $tekst=$row['odgovor']; ?> <tr> <td> </td> </tr> <tr> <td class="formaP"> <?php echo $prasanje?> </td> </tr> <tr> <td class="formaO"> <p> <label> <input type="radio" name="Group<?php echo $id?>" value="<?php odgovor1($tekst) ?>" /> <?php odgovor1($tekst) ?></label> <br /> <label> <input type="radio" name="Group<?php echo $id?>" value="<?php odgovor2($tekst) ?>" /> <?php odgovor2($tekst) ?></label> <br /> </p></td> </tr> <tr> <td> <br /> </td> </tr> <?php } ?> </table> <input align="left"type="submit" name="submit" value="Внеси" > </form> </td> </tr> </table> prasanje = question tekst/odgovor = answer The answer table: id - primary question_id - the questions ID whose answer is selected in the radio group user_id - cookie takes care of this answer - the value from radio group date - automatic I have this code: <?php $con = mysql_connect("localhost","hhh","hhh"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("hhh", $con); // -------------------- // Avatar insert check // -------------------- session_start(); $name = $_POST[name]; $group = $_POST[group]; $age = $_POST[age]; $usernameid = $_SESSION[id]; $result = mysql_query("SELECT * FROM avatars WHERE name='$_POST[name]'"); $num = mysql_numrows($result); if ($num == 0) { mysql_query("INSERT INTO avatars (id, usernameid, name, group, age, xp) VALUES ('', '$usernameid', '$name', '$group', '$age', '0')"); header( 'Location: me/' ) ; } else echo 'Sorry, please pick a new name'; ?> And it does everything but put the data into the datebase. If I add a session befor and after '$request' they both run, but the sql doesn't. No error returns, if just redirects to the other page. Any help? how can i make this code to insert a single, multiple and update rows in the database. The code only insert new rows in the database. Code: [Select] if (($handle = fopen('inventorylist.csv', "r")) !== FALSE) { while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) { $num = count($data); $sql="INSERT into inventory(itemNumber,itemDesc,quantityHand,category,Whse) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]')"; mysql_query($sql) or die(mysql_error()); } fclose($handle); } I have an old site written for PHP 5.4 and under and trying (very trying) to get it to work with PHP 7x without much luck. Due to all the changes in 7 my code is one big error message, but one thing at a time. I cannot get the follow code to work at all, even though it worked in PHP 5. Error:
QUERY ERROR: 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 'viewuser.php?u=666' id='member'>THE PREDATOR [666] was added to the hit' at line 1 I have tried at least 20+ different ways of doing this but just can't get the right syntax to get it inserted into MySQL, the code below is just the latest version. If I echo the a href line out, it works perfect. I am sure it is something ridiculously simple, but I have been 4 hours and counting on this now. Thanks gangevent_add_2($gangdata['gangID'], "<a href='viewuser.php?u=".$r['userid']."' ".$csscode[$r['userlevel']-1].">".$r['username']."</a> [".$r['userid']."] was added to your hitlist"); function gangevent_add_2($gang, $text) { global $db; $csscode; $db->query("UPDATE users SET gangevent = gangevent + 1 WHERE gang={$gang}"); $db->query("INSERT INTO gangevents VALUES('','$gang', UNIX_TIMESTAMP(),'$text')"); }
Hi I have a XML file as follows: <?xml version="1.0"?> <inspection_form> <inspection_type> <inspection_area_tlb>yard_and_lot</inspection_area_tlb> <inspection_area>Yard and Lot</inspection_area> <items> <item> <item_name>PID Signage/unauthorized sign on pole</item_name> <item_value>0</item_value> </item> <item> <item_name>Landscape well maintained</item_name> <item_value>0</item_value> </item> </items> </inspection_type> <inspection_type> <inspection_area_tlb>pump_island</inspection_area_tlb> <inspection_area>Pump Island and Canopies</inspection_area> <items> <item> <item_name>pumps clean and free of dirt</item_name> <item_value>0</item_value> </item> <item> <item_name>Approved trash cans/clean</item_name> <item_value>0</item_value> </item> </items> </inspection_type> </inspection_form> I want to insert into DB as follows: inspection_area_tlb inspection_area item_name item_value yard_and_lot yard and Lot PID Signage/unauthorized sign on pole 0 yard_and_lot yard and Lot Landscape well maintained 0 pump_island Pump Island and Canopies pumps clean and free of dirt 0 pump_island Pump Island and Canopies Approved trash cans/clean 0 I have written some php code. But every item node as insert for every 'inspection_type'. This is my code $filename="sample.xml"; if(filesize($filename)>0) { $oDOM = new DOMDocument(); $oDOM->loadXML(file_get_contents($filename)); foreach ($oDOM->getElementsByTagName('inspection_type') as $oBookNode) { foreach ($oDOM->getElementsByTagName('item') as $itmNode) { $sSQL = sprintf( "INSERT INTO inspections_master_tablename_import (INSPECTION_TYPE_DB_C_NAME, INSPECTION_TYPE_C_NAME, INSPECTION_TYPE_ITEM_C_NAME,INSPECTION_TYPE_ITEM_VALUE_C_NAME) VALUES ('%s', '%s', '%s', '%s')", mysql_real_escape_string($oBookNode->getElementsByTagName('inspection_area_tlb')->item(0)->nodeValue), mysql_real_escape_string($oBookNode->getElementsByTagName('inspection_area')->item(0)->nodeValue), mysql_real_escape_string($itmNode->getElementsByTagName('item_name')->item(0)->nodeValue), mysql_real_escape_string($itmNode->getElementsByTagName('item_value')->item(0)->nodeValue) ); $rResult = mysql_query($sSQL); if(mysql_errno() > 0) { printf( '<h4 style="color: red;">Query Error:</h4> <p>(%s) - %s</p> <p>Query: %s</p> <hr />', mysql_errno(), mysql_error(), $sSQL ); } } } } Can anyone help me pls. guys, im having a problem here thats making me crazy im making a system and i want to insert the current date in the mysql. I have the field called 'data' in the DB, but when i make the code to insert all the other fields, including the 'data', its work perfectly... unless that damn date! $query = "INSERT INTO news (id, titulo, mensagem, data) VALUES (NULL, '$titulo', '$mensagem', 'date(\"d/m/Y\")')"; whats wrong with that? its stores in DB as '0000-00-00'. I have a problem where I am getting these errors after a form has been submitted from join.html Here are the errors: Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'scswccla'@'localhost' (using password: NO) in /home/scswccla/public_html/insert.php on line 9 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/scswccla/public_html/insert.php on line 9 Here is the insert.php file http://pastebin.com/EVtgidQC And the join.html file - http://pastebin.com/hqDtGLe5 How would I fix those errors - I got the code from http://forum.hey0.net/showthread.php?tid=2509 The form is at scswc.com/join.html if you want to look at it. I really want to get this working so if you need any more info to help fix it just ask thanks! Hi,
I created a form that inserts first - last name, address, and email address into a mysql databse table.
The record inserts correctly - No problems here.
The problem is I only want to insert the data if the email and address doesn't exist.
I set it up for just the email right now to try to get this to work but have failed.
When the form is submitted and the record exists it inserts the record anyway and sends the email which it's not suppose to do.
The form is suppose to after submitting -
1. validate
2. insert only if the record doesn't exist
3. send the email.
Here's the code
<?php $to = "email@email.com"; if(isset($_POST['submit'])) { // VALIDATION if(empty($_POST['firstName'])) { $errorfirstName .= "First Name Required"; } if(empty($_POST['lastName'])) { $errorfirstName .= "Last Name Required"; } if(empty($error)) # No error go ahead and email it. { $to = "$to"; $subject = 'the form'; $msg .="<html><head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <title>The Form</title> </head> <body> <table> <tr> <td>Email sent for confirmation</td> </tr> </table> </body> </html>"; $mail($to, $subject, $headers, $msg); if(!$result) { $error = "<div id='errors'>There was an unknown error </div>"; } else { include('connection.php'); $firstName = mysqli_real_escape_string($con, $_POST['firstName']); $lastName = mysqli_real_escape_string($con, $_POST['lastName']); $address = mysqli_real_escape_string($con, $_POST['address']); $email = mysqli_real_escape_string($con, $_POST['email']); $email = $_POST['email']; $sql = "SELECT * FROM table WHERE `email` = '{$email}'"; $result = mysql_query($sql); if ( mysql_num_rows ( $result ) > 0 ) { $error = "Email Exists."; } else { $error = "Email does not exist. Insert it!!!"; $sql="INSERT INTO table (firstName, lastName, address, email) VALUES ('$_POST[firstName]','$_POST[lastName]','$_POST[address]', '$_POST[email]')"; } if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con) { } } } } ?> <!-- Form --> <html> <head></head> <body> <section> <form method="POST" action="theform" name="for" onsubmit="return validateForm(this)"> <?php if(!empty($error)) { echo "$error"; } ?> This where the inputs would go not going to include them because not having an issue with the form </form> </section> </body> </html> Edited by barkly, 26 October 2014 - 06:54 PM. I am attempting something similar to the following: Code: [Select] mysql_query("UPDATE table SET name='$name' WHERE id=$id"); if (mysql_affected_rows()==0) { mysql_query("INSERT INTO table (id, name) VALUES ('$name',$id); } If the $id row does not exists in the table, mysql_affected_rows() returns 0 and a new $id row gets inserted but if the $id row already exists and UPDATE changes nothing, mysql_affected_rows() still returns 0 and gives an 'duplicate id' error as expected. I know I could use a SELECT to test for the existance of the $id row. In Perl there is an '0E0', 'zero but true', condition to handle this. Is there an equivilant in PHP? hello can anyone help me how to insert GET variable into mysql <?php $page_title = 'Personal Wellness'; include ('template/header.inc'); include_once('config.php'); $id = $_GET['id']; if(isset($_POST['submit'])) //if submit was pressed { if(strlen($_POST['height'])<1) //if there was no height { print "You did not enter a height."; } else if(strlen($_POST['weight'])<1) //no weight { print "You did not enter a weight."; } else if(strlen($_POST['bodyfat'])<1) //no bodyfat { print "You did not enter a Body Fat Range"; } else if (strlen ($_POST['bodywater'])<1) //no bodywater { print "You did not enter a Body Water Range"; } else if( strlen($_POST['musclemass'])<1) //no musclemass { print "You did not enter a Muscle Mass"; } else if (strlen ($_POST['physiqueratt'])<1) //no physiqueratt { print "You did not enter a Physique Ratings"; } else if (strlen ($_POST['bonemass'])<1) //no bonemass { print "You did not enter a Bone Mass"; } else if (strlen ($_POST['bmr'])<1) //no bmr { print "You did not enter a BMR"; } else if (strlen ($_POST['basalmetabolic'])<1) //no basalmetabolic { print "You did not enter a Basal Metabolic Age"; } else if (strlen ($_POST['visceralfat'])<1) //no visceralfat { print "You did not enter a Visceral Fat"; } else if(strlen($_POST['registrationmonth'] && $_POST['registrationday'] && $_POST['registrationyear'])<1) // no date { print "You did not enter a date of birth"; } else //all fields met { $id=$_GET['id']; $height=$_POST['height']; $weight=$_POST['weight']; $bodyfat=$_POST['bodyfat']; $bodywater=$_POST['bodywater']; $musclemass=$_POST['musclemass']; $physiqueratt=$_POST['physiqueratt']; $bonemass=$_POST['bonemass']; $bmr=$_POST['bmr']; $basalmetabolic=$_POST['basalmetabolic']; $visceralfat=$_POST['visceralfat']; $date=$_POST['registrationyear'] . '-' . $_POST['registrationmonth'] . '-' . $_POST['registrationday']; $insertadmin="INSERT into personalwelness (m_id,height,weight,body_fat,body_water,muscle_mas s,physique_ratt,bone_mass,bmr,basal_metabolic,visc eral_fat,evaluation_date) values ('$id','$height','$weight','$bodyfat','$bodywater','$mus clemass','$physiqueratt','$bonemass','$bmr','$basa lmetabolic','$visceralfat','$date')"; //registering admin in databae echo $insertadmin; $insertadmin2=mysql_query($insertadmin) or die("Could not insert admin"); print "Personal Wellness Successfully Submitted"; } } ?> <form method="post" class="form" action="<?php echo $_SERVER['PHP_SELF'];?>"> <fieldset><legend>Enter Personal Wellness Information in the form below:</legend> <table width="80%" border="0"> <tr> <td width="16%">Height(CM)</td> <td width="2%">:</td> <td width="82%"><label for="height"></label> <input type="text" name="height" id="height" value="<?php if (isset($_POST['height'])) echo $_POST['height'];?>" /></td> </tr> <tr> <td>Weight(KG)</td> <td>:</td> <td><label for="weight"></label> <input type="text" name="weight" id="weight" value="<?php if (isset($_POST['weight'])) echo $_POST['weight'];?>" /></td> </tr> <tr> <td >Body Fat Range</td> <td>:</td> <td><label for="body fat"></label> <input type="text" name="bodyfat" id="bodyfat" value="<?php if (isset($_POST['bodyfat'])) echo $_POST['bodyfat'];?>" ></td> </tr> <tr> <td>Body Water Range(%)</td> <td>:</td> <td><label for="bodywater"></label> <input type="text" name="bodywater" id="bodywater" value="<?php if (isset($_POST['bodywater'])) echo $_POST['bodywater'];?>"/></td> </tr> <tr> <td>Muscle Mass</td> <td>:</td> <td><label for="musclemass"></label> <input type="text" name="musclemass" id="musclemass" value="<?php if (isset($_POST['musclemass'])) echo $_POST['musclemass'];?>"></td> </tr> <tr> <td>Physique Ratings</td> <td>:</td> <td><label for="physiqueratt"></label> <input type="text" name="physiqueratt" id="physiqueratt" value="<?php if (isset($_POST['physiqueratt'])) echo $_POST['physiqueratt'];?>"></td> </tr> <tr> <td>Bone Mass</td> <td>:</td> <td><label for="bonemass"></label> <input type="text" name="bonemass" id="bonemass" value="<?php if (isset($_POST['bonemass'])) echo $_POST['bonemass'];?>" /></td> </tr> <tr> <td>BMR</td> <td>:</td> <td><label for="bmr"></label> <input type="text" name="bmr" id="bmr" value="<?php if (isset($_POST['bmr'])) echo $_POST['bmr'];?>"/></td> </tr> <tr> <td>Basal Metabolic Age</td> <td>:</td> <td><label for="basalmetabolic"></label> <input type="text" name="basalmetabolic" id="basalmetabolic" value="<?php if (isset($_POST['basalmetabolic'])) echo $_POST['basalmetabolic'];?>"></td> </tr> <tr> <td>Visceral Fat</td> <td>:</td> <td><label for="visceralfat"></label> <input type="text" name="visceralfat" id="visceralfat" value="<?php if (isset($_POST['visceralfat'])) echo $_POST['visceralfat'];?>"></td> </tr> <tr> <td>Evaluation Date</td> <td>:</td> <td> <?php echo date_picker("registration")?></td> </tr> </table> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /> </div> </form> <?php function date_picker($name, $startyear=NULL, $endyear=NULL) { if($startyear==NULL) $startyear = date("Y")-100; if($endyear==NULL) $endyear=date("Y")+50; $months=array('','January','February','March','Apr il','May', 'June','July','August', 'September','October','November','December'); // Month dropdown $html="<select name=\"".$name."month\">"; for($i=1;$i<=12;$i++) { $html.="<option value='$i'>$months[$i]</option>"; } $html.="</select> "; // Day dropdown $html.="<select name=\"".$name."day\">"; for($i=1;$i<=31;$i++) { $html.="<option $selected value='$i'>$i</option>"; } $html.="</select> "; // Year dropdown $html.="<select name=\"".$name."year\">"; for($i=$startyear;$i<=$endyear;$i++) { $html.="<option value='$i'>$i</option>"; } $html.="</select> "; return $html; } ?> <?php include ('template/footer.inc'); ?> Hey guys, this is my first post here(not going to be the last one, Im sure), im trying to insert in mysql from session array, i don't know where is my error, I leave the code below, if someone can help me please . Hello every body,, i want to create a new database (auto generate duty assigned using form) in PHP and mysql..
i have four input fields:-
Name, Subject, Class & weekly lectures
now i want to insert name,subject & class into database, when i insert number of weekly lecture in field four..
insert automaticlly in database multiple time which i write in field four (weekly lecture)
database: table structure i have already is:::
id-name-subject-class-period-monday-tuesday-wednesday-thursday-friday-saturday
anybody please help me to create this database or just insert query ....
Im trying to insert some values automatically into a table once the form loads, but Im getting an error. Here is the code Code: [Select] <?php $aid = $_GET['aid']; $sd = $_GET['sd']; ?> <style> #message {margin:20px; padding:20px; display:block; background:#cccccc; color:#cc0000;} </style> <div id="message">Your notification has been submitted.</div> <div style="text-align:center "> <?php $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="INSERT INTO broken_links (articleid, article) VALUES ('$aid', '$sp')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Submitted"; mysql_close($con) ?> <table border="0" cellpadding="3" cellspacing="3" style="margin:0 auto;" > <input type="submit" id="Login" value=" Thank you. Please press to close " onclick="tb_remove()"></td> </tr> </table> </div> Any help will be appreciated |