Form Data Not Stored In Database ?
This is the code for a Returns form where I am trying to implement these validations:
1. Check if fields aint empty
2. Check if SESSION_username = username from Customer table and get customer ID
use that Customer ID to look up Orders table and find if the ORDER NO. that has been entered is = an order no. in the Orders table
i.e. see if the oder no. entered was actually an order placed by the user b4
* Customer table has cust id and username. Order table has only cust ID. returns table will store username from Session so that it can display each user's individual returns. Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Form Data Not Stored In DataBase
I was trying setting up these scripts following instructions in a book from 2003, so I thought maybe some of the code might be outdated. Basically this is what Is supposed to happen: 1.- Display a form, enter details into fields and click submit. 2.- After having clicked on submit you're redirected to another page that will display the entered values and store them in the MySQL DB specified. Now what happens is that no errors are displayed after clicking on the submit button in the form, but neither are the entered values. In PHPMyAdmin I can see that the Db is still empty. I created a total of 3 files that reside in the same folder: The form, that when clicking on submit is redirected to the next file: Code:
Can Php And Mysql Process Stored Form Data Created Offline?
A customer of mine has given me a task that has me stumped... My customer meets with his new clients away from his office with a laptop. At his office he is running a redhat server, apache, php, mysql....the usual stuff. His laptop has windows xp. When he meets with the new client, he wants to fill in a from and have the data stored on his laptop. After returning to the office he would like to upload via his web app (php/mysql based) the new client data into his database. Basically: fill in form offline ---> return to office and connect to web app ---> upload and review stored form data ---> process new client data into database Where do I begin? How do your create the form? How would you process the form? What's the simplest way to process the data into the database? I'm sure I'm missing a few questions here.
Entering Data From A Form To A Mysql Database
I'm trying to enter data from a form with the fields name and email into a mysql database called newsletter, as you guess it's a newsletter sign up. this what I have at the moment: Code:
Insert Data From Form To MySQL Database
I have run createTable.php and everything is created. Now I want to run insertData.php. I want the user to enter stuff in the form & everything must be fill in before they click the submit button. It will call submitData() & all the information was enter will insert into the database. PHP Code:
Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:
Templates Stored In Database
I have a form where a user can enter different feild, for simplicities sake, say a 'To:', 'From' and 'Message' feild. The can select a 'template' from the databse, each one has different layouts, images etc, and is sotred as HTML code in the mySql. My question is how do I insert the vairables into the correct places in the template? I realise if it was hard-coded I could use something like: echo "To:". $to. "<br><br>". $message. "<br><br>From:". $from; etc, although this is simplified alot and the ones int databse contain images, tables, css etc. I don't really want to hardcode them using IF statements as I want it to be easy to add new 'templates'.
Displaying Image Stored In Database
The user can browse and upload an image and the image is stored successfully in a seperate binary table (with userid and bin_data, filesize, filename, filetype). The photo is displayed properly when I point my broswer to a script called fileshow.php: PHP Code:
Database-stored Webpage-content?
more and more pages seem to be extracted entirely from a database. Not only dynamic information, like search-engines, but also (semi-)static content, (just text/information) Does anybody know a good tutorial on: how to set up the needed effective structure for these database-driven websites?
Photos Stored In Database Or As Files
I have a question to you. I would like to create photo gallery. I wonder if I should store photos (uploaded by users) in database $data = file_get_contents($_FILES['photo']['tmp_name']); $data = mysql_real_escape_string($data); // Preparing data to be used in MySQL query mysql_query("INSERT INTO {$table} SET ext='$ext', title='$title', data='$data'"); $msg = 'Success: image uploaded' or I should store uploaded photo files as files in the server folder? Few years ago in my previous work I worked in MS Access application, and in my opinion storing photos in this database are not so good, becuase uploaded photo files stored in MS Access application, enlarged the database a few times. That`s why storing such files in database is not so relevant and the better way was to saved these files in the specified folder. What about Mysql?
Viewing Images Stored In A Database
I've written this script which is supposed to take an image uploaded by a user and put it in to a database, then at a later date be able to extract the image from the database and display the image to the user. The problem is that whenever I try to display the image, all I get is an error message that the image contains errors. Can anyone tell me where or why these errors might be coming up? Here is my script (I'm pretty sure it's all there):
Using Variable Names Stored In Database Fields.
I'm working on a project where I need to store a CGI query in a database field. The query contains variables which will be substitued at runtime (e.g., today's date, key to select upon, etc), and may be pointed to different URLs depending upon the table key. The variable substitution works fine when hardcoding into the script, e.g.: $var1='data1' $var2='data2' $a="http://www.webserver.com/query.cgi?a=$var1&b=$var2"; $fd=fopen($a,"r"); ... However, the substitution fails when the query is pulled from a database record, e.g. //Only one record returned for testing purposes. // //location field (varchar) is: //"http://www.webserver.com/query.cgi?a=$var1&b=$var2" $var1='data1' $var2='data2' $dbconn=yadda yada; $dbquery=pg_query($dbconn,"select key,location from schema.table"); $row=pg_fetch_assoc($dbquery); $fd=fopen($row['location'],"r"); ... In this case, the variable substitution doesn't occur in the query (i.e., $var1 remains the string $var1, instead of changing into the value of say, ༿-23-2004'). I've tried different variations, and treating as a variable variable (with $$row['url'] and ${$row['url']}.
Limiting Number Of Records Stored In Database
Is there a way I can limit the number of records that are stored in a database? I am using a PHP guestbook script for personal use and only want to save say the last 100 messages.
Problem Decrypting Data Stored In MySQL Using Mcrypt
I'm trying to implement encryption on certain data fields in my MySQL database and I'm experiencing ongoing problems. I seem to be able to encrypt the data without issues, but can't figure out how to decrypt the data. My field in my test table, in which I'm storing the encrypted data, is a TEXT type field. The code I'm using, from the PHP help file, is:
Show Stored Value For Form Field Type=file
I have a file-uploading form to uploads a .jpg file and stores its name in a table in my db as co_bannerfile. I'm trying to now write an update form so the user can update their .jpg file. I've successfully written a query to retrieve the stored file's name. How can I display the stored file's name so the user can see its name within the input TYPE="file" field and then decide to update it or not? The following doesn't display the stored file name. What do I have wrong? Code:
Posting Form Data And Also Allow To Download Form Data
i have a client that whats to post form data to a database but he also wants users of the script to download it aswell how will i got about doing this i thought about it that i could make it save it into a txt file then echo the download link is there any ideas? because to post it to a txt file it would be posting 2 places is there a way to do this? Code:
Session Data Stored But New Session Everytime!
I am running out of time with a problem I have running PHP 5.04 and Apache 2.0 and really need help :(. I have a page that stores a variable in session but each time I reload that page the session seems to be re-created and is an empty array. I have checked the session file and the variable is being stored against the session id, but I dont know why PHP is not picking up the session after I reload.. I have tried the usual suspects of register_long_arrays etc but no luck.. slowly winding down to a quick death before our old server is taken out of commission and all our sites will be served from here, but at this rate its not gonna happen.
Comparing Database Data And New Data
I am trying to create a PHP script that reads in a file, parses it for the data I want and compares it to the data I have in a database. The data is points and ranking information for a Folding@Home Team. Every week someone creates a news item with points gained by each team member for that week and other info. This is done manually and takes a lot of time. I hope for my script to automate as much of it as possible. The script was to run as follows: Download and parse latest statistics into 2D array Compare usernames in array to usernames held in Database Any new usernames and their respective points/rank to be added to database Compare points in 2D array of each user to those held in database. Output username and points gained I thought I had a working script until I actually tested it on real data, and realised I missed something rather obvious - the order of usernames from the parsed file is not going to be the same order as in my database - due to people moving up and down the ranks. So i can't just get a recordset from the db and run a simple loop to compare it to the parsed data. I am not sure how to go about comparing the database information with the parsed data that works around the fact the data could be in any order. The only thing i can think of is: foreach item in $parsed_data_array query database for $parsed_data_array=>username if(number of results == 0) build new insert query for current username else continue I don't know if this works [haven't tested yet] but I can't help feel it is a little DB intensive. There could be up to 200 queries being sent to the database. This can be minimized by adding extra criteria, like ignoring inactive users of course. Is this a viable solution or is there a much better way of doing this?
Comparing Form Data To Mysql Data
Im interested in building a script that would take form data, a variable like an address, and compare it with a known address in a mysql table (called addresses), then if there is a match log the address information in a separate table called (addresslog), and return the visitor to a certain page. If there is no match between the address entered in the form and known addresses then the information is still logged into the addresslog database but the visitor will be sent to a different page. I'm still new to this, and am working through the logic and the syntax, but I believe I'm close. It's still not working, I have all of the proper tables, maybe I'm way off with the coding so I thought I would seek out some expert advice. Here's the entire script with as much explanation as I could give. PHP Code:
Getting Data From Database
I created a databae that i added greek text in it and when i try to get the data to echo in a table i get ?.Any help? I also set the collation of the table and the field to greek_general
Getting Data From Database
I have a database with a table named members with columns - id, member name, age etc.. Is there a way I can get the member name from the table members and store it in a variable $name without looping?
Getting Data From Database
I have a script to select data from a database and put it into a new url which the user gets automaticaly directed to that specific page. The problem is that its not getting the data to put into the new url. Code:
Checkbox Data In The Database
I want to display the checkboxes taken from the database from table “const_skills”, but the checkboxes and its values do not appear ($html_skills). Can anyone figure this out. Below is the codes that I’ve been using. Thanks in advance. <?php include "dbinfo.php3"; function get_checkbox_labels($table_name) { /* make an array */ $arr = array(); /* construct the query */ $query = "SELECT * FROM $table_name"; /* execute the query */ $qid = mysql_query($query); /* each row in the result set will be packaged as an object and put in an array */ while($row= mysql_fetch_object($qid)) { $array[count($arr)] = $row; } return $arr; } /* Prints a nicely formatted table of checkbox choices. $arr is an array of objects that contain the choices $num is the number of elements wide we display in the table $width is the value of the width parameter to the table tag $name is the name of the checkbox array $checked is an array of element names that should be checked */ function make_checkbox_html($arr, $num, $width, $name, $checked) { /* create string to hold out html */ $str = ""; /* make it */ $str .= "<table width="$width" border="0">n"; $str .= "<tr>n"; /* determine if we will have to close add a closing tr tag at the end of our table */ if (count($arr) % $num != 0) { $closingTR = true; } $i = 1; if (isset($checked)) { /* if we passed in an array of the checkboxes we want to be displayed as checked */ reset($arr); while (list(, $ele)=each($arr)) { $str .= "<td><input type="checkbox" name="$name" value="$ele->id""; reset($checked); while (list(, $entry)=each($checked)) { if ($entry == $ele->id) { $str .= "checked"; continue; } } $str .= ">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>n<tr>"; } else { $str .= "</td>n"; } $i++; } } else { /* we just want to print the checkboxes. none will have checks */ reset($arr); while (list(, $ele)=each($arr)) { $str .= "<td><input type="checkbox" name="$name" value="$ele->id">"; $str .= "$ele->value"; if ($i % $num == 0) { $str .= "</tr>n<tr>"; } else { $str .= "</td>n"; } $i++; } } /* tack on a closing tr tag if necessary */ if ($closingTR == true) { $str .= "</tr></table>n"; } else { $str .= "</table>n"; } return $str; } /* get the checkbox labels */ $skills = get_checkbox_labels("const_skills"); /* create the html code for a formatted set of checkboxes */ $html_skills = make_checkbox_html($skills, 3, 400, "skills[]",$checked); ?> <html> <body bgcolor="#ffffff" text="#000000" id=all> <br> <form name="skills" method="POST" action="insertskills.php3"> Check off your web development skills: <? echo "$html_skills"; ?> <br> <br> <input type="submit" value="Submit"> </form> </body> </html>
Modify Data In A Database?
I am using PHP to add data to a MySQL database in an HTML form. Does anyone have any code to display all the records and click on one to modify it and update the data?
Inserting Some Data Into Database..
The code I have at the moment creates directories (mkdir) and copys files into them. This seems to work, but I need the variables "$mypath" and "$newfile5" to be inserted into my database. But it won't. It enters the other data such as name and description and creates the folder. Code:
Sending Data To My Database
I have ms access database (im know mysql is better but please bare with me) and within it is a product list. That product list is called and displayed on my product page. After the price of an item has been echo'ed out i have a small text field where the user of the system is required to type the product id ($ProductId) on all the items they wish to select and then proceed to click submit. Once the submit button has been pressed i want to send all of the data typed into the little text fields into a single cell separated by commas in the database. I have some basic code that doesn't correctly do what i want it to. If more than 3 products are listed on a page and i type the product id for any items not in an order E.g. Product 1 <----i want this one Product 2 Product 3 Product 4 Product 5 <-----I wantthis one I just get ',,,' sent tothe database however if i type product id like this: Product 1 <----i want this one Product 2 <----I want this one as well Product 3 <----i want this one too Product 4 Product 5 I get 1,2,3 sent into the database. Code:
Retriving Data From A Database
I have code that lists a number of people from a data and stores it array // select people from first table who are part of group 1 $query= "SELECT personID FROM people WHERE groupID = 1"; $result = mysql_query($query); $numrows = mysql_num_rows($result); while ($row = mysql_fetch_array($result) { $personid = $row["personID"];} The problem is I do not know how many records it will return. I then need to enter all these people into another table. // add people to second table who are part of group 1 $people = 0; while ($people != $numrows) { $query2 = "INSERT INTO people2 (peopleID, groupID) VALUES ('$personid', '1')"; $queryaddperson = mysql_query($query2) or die(mysql_error()); $people++;} Rather than add every single person who is part of group 1 it just keeps adding the first person over and over again to the people2 table.
Got Data From Database But Doesn't Show
I get data from a database and I need to put in a table. the table dynamically adds rows depending on the results from the database. So my rows are getting created but their's nothing in their. What can be the problem here? Code:
Truncated Data From Textarea Box To Database
I have a simple form with a textarea box. The user is supposed to cut/paste text from documents into the textarea box, which is then added using php as a record to a MySQL column of data type mediumtext. The problem - the text keeps getting truncated at about 1800 characters (sometimes more, sometimes less).
Extracting Data From Database Using Three Strings
I am a complete newbie. I have been working on a self-learning project that will ask users for three strings (i.e. name,dob and number. If details are correct, will vector to a new page and display all their other information unique to their name,dob and number. The second page will then display their school,work,address, etc. which is editable. They will then click the submit button at the bottom to save the displayed data (or any changes they made to it) in the database from where it was initially extracted from. Here is the php for the first page which asks the name,dob and number:
Data Not Posting To My Database Php/mysql
I am having a problem postion data from my form into my database. My users visit my site and fill out a form which is suppose to go into my mysql. I check phpMyAdmin to see if the data got there but nothing. Below is my Code. could someone help me out. Code:
How Do You Send Data To A Database Via Checkboxes?
I am using PHP to send and retrieve data from a MySQL database via HTML forms. I am using text boxes and everything is fine. If I have a page with checkboxes on, and the users check them and click on the submit button, how does this show up in the database? Nothing seems to show up for me.
Data Format In Application Or Database?
I have found that by far the easiest way to store dates in my LAMP application is in a text string in the database in Unixtime format. First of all, what would be the most efficient data type to store this as? Secondly, in terms of translating into a human readable format, is it quicker to format the date in the application using date() or in the database in the select query?
How To Display Data From Database In Different Web Pages?
When we get data from database by use mssql_query(),suppose the data is very large ,it has many rows, and we want display the data in different web pages like many search engines do, my question is how to do that using the same result without call mssql_query() again?
Mailing Data From Mysql Database
I have searched, but didnt find what I need. I am trying to mail someone if a user changes data in my MySQL database, which is being written to by a php script. All is set up, just need to be notified of what data got changed.
Ok Problems Entering Data Into Database
i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block that makes the table in the database, // Define the query. $query = "INSERT INTO blog_entries (blog_id, title, entry, date_entered) VALUES ('{$_POST['title']}', '{$_POST['entry']}', NOW())"; // Execute the query. if (@mysql_query ($query)) { print '<p>The blog entry has been added.</p>' } else { print "<p>Could add the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>"; } --------------------------------------------------------------------------------------------------------------------------------------------------- // Define the query. $query = 'CREATE TABLE blog_entries ( blog_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(100) NOT NULL, entry TEXT NOT NULL, date_entered DATETIME NOT NULL )' // Run the query. if (@mysql_query ($query)) { print '<p>The table has been created.</p>' } else { die ('<p>Could not create the table because: <b>' . mysql_error() . '</b>.</p><p>The query being run was: ' . $query . '</p>'); } Quote:
Writing Data To MySQL Database Using PHP
Can anyone tell me why the following code isn't working? $dbh = mysql_connect($host,$user,$pass) or die("Couldn't connect..."); $selected = mysql_select_db($db,$dbh); $name = $_GET['name']; $state = $_GET['state']; $desc = $_GET['desc']; $lat = $_GET['lat']; $lng = $_GET['lng']; $result = mysql_query("INSERT INTO re_cities (name, state, description, lat, lng) VALUES ('$name','$state','$desc','$lat','$lng')"); The script doesn't die when I attempt to connect so I'm assuming that isn't the problem. I'm pretty sure I also get a result because the following code echoes "City Add Successful". if ($result) { echo "City Add Successful"; } else { echo "City Add Unsuccessful"; } However, the data doesn't show up in the database.
Calculating Some Formulas From Database Data
I am doing a project on beetle diversity and need to calculate a few diversity indices for a load of data i have collected. I thought that maybe i could make a program in php to do that for, and save a bit of time (as well as prevent calculation errors). I imagine this could be quite a bit of programming but i have dreamweaver to help me. Now what i have is a MySQL database full of data on beetle diversity with the following tables: Date - the date the sample is from Habitat - one of 9 habitats that i am testing between (ie. grass, stones, birch woodland, etc) Replica - ie 'Repeats', there were two replicas for each habitat from each date (A and B) Trap number - from each replica there were 6 traps Species - the species of beetle that was found in the trap (of course there are often more than one per trap) Number of Individuals - the number of individuals of that species found in that trap What i need to do is calculate Shannon-Weiner, Shannon Equitability and Margalefs Diversity indices for each replica from each date for each habitat (the data for the individual traps will be merged together). I have an idea of how to do it but what i am stumbling at is how to create a recordset which will calculate the total number of individuals for that species from that replica, date & habitat (I) and calculate the number of different species for that replica, date & habitat (S). Once i have S and I i should be able to write the formula in php to create the indices. Ideally this could be done in a way to allow for each repeating areas to be assigned so that all of the indices for that habitat (for each date and replica) could be shown on one page (to save a lot of clicking).
Using Session Data To Query A Database
Basically the title is the general idea of what i'm trying to do, a user logs in, great, his login id is stored (it is also his number on a seperate database) in a session variable. Now that session variable needs to be queried to another database (with all of that users information) to get all of the information on that user back to the original server (not the first database, the first database just has user number, id, and a password field). So I have a question, and if you have answers great! or if you know of the thread that they are on that would also help because i've been searching and haven't found anything yet. 1. How can I query a session variable in a sql statement, do I just put select * from users where '.$_SESSION['mysessionname'].' = usernumber ?
Check Mysql Database For Data
Need to check if some info matches from mysql database in two tables to see if the current session user is on a friends list for the profile page he or she is viewing. If they do not exist in field, return an error. Here is the structure and what i got so far: Code:
Delete Data From MySQL Database
I am new to PHP and MySQL but I have setup a MySQL database. I can view the information in an HTML table using PHP scripts and can delete an entry form the database table, but what i need to do is to be able to delete an entry by selecting a radio button next to the relevent information however when i try to add a form in the PHP script i get an error.
Selecting Data From Database(php/mysql).
Alright I've come to a point where I only want a DB for settings and nothing based on ID's on a sql table. instead of say: $setting = mysql_query("SELECT * FROM settings WHERE id='1' "); Now i broken up all the sql into seperate settings like so: settingname | value boardonline | no Thats basicaly how I got the sql set up instead of having it all in one table row I have them in seperate rows. So how do I go about selecting data from SQL not based on ID but mainly on setting name? would I do $settings = mysql_query("SELECT * FROM settings"); $settings = mysql_fetch_array($settings); $settings['boardonline'][1];//would echo true/false according to my sql table instead of the row name?
Arrays And Inserting Data In To The Database
I have a form that uses two arrays one get's a list of courses from the database and one creates dates... i have two questions 1. how do i get the $i and $d value off of the arrays to insert in to the database, but still have each know they belong in the same row? 2. how do i change the dates from a multiselect dates ie, Jun 3, Jun 6, and Jun 12 to 'Jun 3, 6, 12' here is the snippet of code from my select page. $numposts is a value selected on an earlier page. Code:
|