Jump to content

Search the Community

Showing results for tags 'database'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. HI Guys First time here and I'm hoping someone can help I've just started to learn PHP and I'm onto databases The problem I have that once I log into 'phpmyadmin' and then I click through to databases to make a database but once there, there is text in red which reads "no privileges". I use Xampp and everything is going well so I know it means I don't have privileges on my own computer to make a database. So my question is where do I find the folder/file to make the changes and once I find the file what code do I add and where do I add it in the file. I've looked in the following folders in my 'C:drive', which are php, mysql and xampp but nothing is there to let me know which file to change. As I said I'm a novice but the database section is holding me back Hope someone can help Thanks guys
  2. For example I have 6 database 1. hats 2.shirts 3.jeans 4.dresses 5.jackets 6.accessories Now my questions: Is how would I be able to fit all 6 databases into 1 shopping cart without any overlapping errors ?
  3. Hi, I'm not new to Sql or PHP or atleast I hope not . I coded a simple register form in HTML and this file opens a 'newuser.php' which in turn opens another one, and another finally after checking all INPUT fields, reaches a 'enterintodb.php' . Now, here's the joke. Every field enters into the table of MySql except for the password field. All entries including 1st name, last name, etc etc. get added to the table and like I said , password doesn't add. Just to be sure, at the end I echo all the fields and then echo "New user created !" . No MySql error or any syntax error displayed. The password field echoes w/o any problems, it displays the entered password. But no entry in the DB . password column : varchar(255) , utf16_general_ci , Iv also attached the enterintodb.php file . the others don't matter, coz when I echo $password, it displays perfectly. in the form this is the password field " <input type="password" name="password" size="20" style="border-left-width=0px"> " and don't worry about sql auth, i run a separate PHP file for that before enterintodb.php So, guys, help me out please Here's the attachment = enterintodb.php
  4. HI guys, Everytime I run my php code I get this error message: This is my code: $query = mysql_query("SELECT * FROM Products WHERE cat='Skate' AND subcat='Footwear' LIMIT $start, $limit_img "); //end of query $limit_img = 24; $start = 0; $cols = 3; $cols_td = 0; //end of table variables $images = $row['photo']; $product = $row['product']; $price = $row['price']; //end of row variables echo "<table width='95%'><tr>"; //end of table while ($row = mysql_fetch_array($query)){ echo "<td><div align='center'>$row[product]</div></td>"; $cols_td = $col_td + 1; if($cols_td == $cols){ echo "</tr><tr>"; $cols_td = 0; } } //end of while statement echo "</tr></table>"; Thanks In advance!
  5. Hi, I'm wanting to design an interface to the database to make it easier to save/select records to the database etc. Using an off the shelf ORM or framework isn't an option at the moment. So I'm looking to build my own so that existing code can be ported over time. Currently I've got something like this: $data->setTables(array('pay_support_cases')); $data->setFields(array('firstname', 'lastname', 'email', 'question')); $data->setRequest($_POST); $data->save(); This simply saves the data in the $_POST array to the table and fields passed in to the set methods. Calling the save method simply generates a query and executes it. This is going to become problematic with lots of tables etc. So I would be looking for something like an object for each table so if I had a "user" table I could do: $user->save(); I'm not sure how best to go about this, can anyone give me any pointers? Cheers in advance
  6. When a user browses through my client's merchandise, they should be able to click on a product image at any time to retrieve a description, details, and larger image(s), of the product. Given the way the site is constructed, it will require a query to the database, and I would like for it to open in a new window so that the shopper does not lose their place. I have a general plan for how to accomplish this. Each product will need a dynamically generated link/submit button. It will open in a new window by using the target='_blank' attribute. I can use either post or get to query the product ID which will allow the new script to query the DB and echo the results to the page. My question is, are there any security risks? This website is generally pretty secure as the only customer input is unsigned integers, and all the get/post requests are validated. Since this is my first cart I just wanted to see if there are any recommended best practices or potential vulnerabilities for which I should plan.
  7. I'm having a lot of trouble with php/mysql website registration. once i put the php/mysql code in the html form doesnt load any more. I can't figure out what is causing the code to die without displaying an error. I have a test file on the server and the include file seems to be working fine. I will attach the whole file. <p> register.php
  8. Hi guys Right I have a major headache of a problem. its with regards to the database design of a phrase system for languages for a client of mine. Basically the client has a website with 219 different countries. They want a new section in which they will call phrases. Within this section they want to be able to show a category..... say greetings. When greetings is clicked all of the phrases for greetings in that country come up next to the english version of that word. Let say a users is looking at emergency phrases in france. when they click phrases and then emergency they will see english phrases next to the correct French response the country languages is stored currently in the country table and has a max of 3 language ID's. ok so here is what i have tables Country Languages phrasecat Phrases idcountry idlanguages idphrasecat idphrases country_name lang_name phrasecat_name phrase idlang1 idcountry idlang2 idlanguages idlang3 idphrasecat so from here I have the phrase with the country the phrase is in and the category the phrase belongs to. I dont know where to go from here!!!! I know that every country will have their languages compared to English versions as its an english site but thats it. How do I link 2 phrases together. Whats more if a country has 3 languages. how do I show all three, in order and the english next to it? Im thinking I may need more tables but I cant figure out the design of them. Any thoughts? Any help would be much appreciated Thanks Danny
  9. Hi Guys, From what I can tell, there is no other similar inquiry around... I'm completing my Higher School Certificate (final year of high school in New South Wales Australia) and I'm creating a web system for a major. Part of it requires me to have fully dynamic pages for my clients purpose, and I'm using database elements - so basically there is a BB Code site editor that translates [element=menu] to <?php elementCreate("menu"); ?> What I'm finding for some reason I can't contemplate, is that it's just blatantly not working! And when I use view source the <?php elementCreate("menu"); ?> is green as if it's a comment? function bbElement($transform){ $a = array( "/\[element=\"(.*?)\"\]/is", ); $b = array( "<?php echo elementCreate($1); ?>", ); $transform = preg_replace($a, $b, $transform); return $transform; } function elementCreate($element){ $element_fetch = mysql_query("SELECT * FROM `elements` WHERE `element_name` = '".$element."'")or die(mysql_error()); while($element_info = mysql_fetch_array($element_fetch, MYSQL_ASSOC)){ $econt = $element_info['content']; } return $econt; } It's quiet likely I've missed something simple - but all help is appreciated! Cheers.
  10. Hi guys, Been a while since I posted on the forums (if at all). Have an issue that's been biting me for about two days. It's probably staring me in the face though. I can display data from MySQL with PHP on the page just fine. However, updating the database via a form is just not happening. The form just reverts to display the data that was manually entered into the database or the database table is emptied upon submit. Here is the PHP being used to retrieve and update: // Update Database Tables $result = mysql_query("UPDATE `dev_cms`.`settings` SET `site_name` = '$site_name', `site_slogan` = '$site_slogan', `admin_email` = '$admin_email', `facebook` = '$facebook', `twitter` = '$twitter', `tos` = '$tos' WHERE `settings`.`id` =1;"); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM settings") or die(mysql_error()); // store the record of the settings table into $row $row = mysql_fetch_array( $result ); The form: <form action="settings.php" method="post"> <table class="listing form" cellpadding="0" cellspacing="0"> <tr> <th class="full" colspan="2">General Settings</th> </tr> <tr> <td width="172"><strong>Site Name</strong></td> <td><input type="text" name="site_name" class="text" value="<?php echo $row['site_name']; ?>"/> <i>Your website Name</i></td> </tr> <tr> <td><strong>Site Slogan</strong></td> <td><input type="text" name="site_slogan" class="text" value="<?php echo $row['site_slogan']; ?>"/> <i>A catchy slogan</i></td> </tr> <tr> <td><strong>Admin Email</strong></td> <td><input type="text" name="admin_email" class="text" value="<?php echo $row['admin_email']; ?>"/> <i>For outgoing email</i></td> </tr> <tr> <td><strong>Facebook Page</strong></td> <td><input type="text" name="facebook" class="text" value="<?php echo $row['facebook']; ?>"/> <i>Your Facebook address</i></td> </tr> <tr> <td><strong>Twitter ID</strong></td> <td><input type="text" name="twitter" class="text" value="<?php echo $row['twitter']; ?>"/> <i>Your Twitter ID</i></td> </tr> <tr> <td><strong>Terms of Service</strong></td> <td><textarea name="tos" border="0" cols="45" rows="5"><?php echo $row['tos']; ?> </textarea><i>Terms and Conditions</i></td> </tr> <tr> <td> <label> <input type="submit" name="Submit" value="Save" /> </label></td> </tr> </table> </form> If anyone could please, without too much Jargon, have a look and point me in the right direction I would greatly appreciate it. Thanks in advance.
  11. Hi All, I am facing an issue I cannot solve and I just do not understand why. In a db table, I've got a field that contains text coming from a textarea in a form. If the user had entered breaklines to divide their text into paragraphs, the breaklines are replaced with "\r\n" strings, so the text in the table field may look like "Hello\r\nHow are you?". This works. Now, assuming that the user wishes to edit that text, I want to retreive that text into a textarea, with the same paragraph layout as that initially used by the user. Here is my code (without the whole db error checking code) : $link = @mysql_connect('localhost', 'root', ''); mysql_select_db('mydb', $link); $sql = 'SELECT * FROM table_name Where field_id="31"'; $rs = mysql_query($sql, $link); $arr = mysql_fetch_array($rs); $txt =$arr['user_input']; $txt = nl2br($txt); echo '<br />retrieved text from db is ' .$txt.'<br />';//Will display "retrieved text from db is Hello\r\nHow are you?" $txt=str_replace("<br />", "", $txt); echo '<br /><textarea name="text" cols="100" rows="15" >'.$txt.'</textarea>';// Will display "Hello\r\nHow are you?" in the textarea Now if manually set a variable called "Hello\r\nHow are you?". The following code $string = "Hello\r\nHow are you?"; $string=nl2br($string); $string=str_replace("<br />", "", $string); echo '<br /><textarea name="text2" cols="100" rows="15" >'.$string.'</textarea>'; Will generate "Hello How are you?" in the textarea. Why can't I manage to make this work with the text retreived from the database ? Thanks for your help. Phd
  12. Ok ill try and describe this best I can. I have a members table, a company table and a link table between the two as a member sets up a company. Also there will be a permission table as other members can be part of that company based on their permission. Members company link_mem_com permission idmembers idcompany idlink_mem_com idpermission etc etc idmembers p_name idcompany idpermission Now Im not sure how to design the next bit. Basically a member will have an area for uploading pictures. However so will a company. Then on top of that other members can be apart of that company and also upload pictures. here is my thinking for the table structure for this feature. I will create an images table with uploader_id and type. i_type will be 1 for member and 2 for company. Then I will create a tag table so a member can share an image with other members and the companies they are part of. Now. I have no idea if this is right or wrong. Can someone please help me with how to do this properly or tell me if this is a suitable option? image tags idimage idtags uploader_id idimage i_type i_type name uploader_id filename i_status Thanks All
  13. Hello All, I was wondering what is the point of having multiple databases? Why not just have X amount of tables inside of one database? If you have multiple databases that means you have to open and close more than one database on one page. I am wondering this because I was thinking about putting all of my uploaded photos into their own database to make a more searchable and well structured database. Does it make it faster? Thanks in advance!
  14. Greetings everyone, I really hope someone would be able to help me quickly... I'm not very clued up on ajax,jquery or javascript, and would really love some help in converting the attached js file to use a database instead of cookies. Please guys, thanx in advance.
  15. Hi there, I am not a proper coder, and am using the built in Dreamweaver options to display some tables and do some updates to tables. I have a form on a php page to update a record, which works fine, but I would like the page to send a php email of the contents of the form either before or after it updates the database. How can I do this? I think the code that Dreamweaver uses to update the table and redirect is this: $updateGoTo = "thank-you.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } What I would like to do is insert a script there somewhere, that will send an html email to a recipient with the information contained in the form, so that they are notified of the update, and what the contents of the update are. Is there someone on this site who could explain to me where to insert the code for the php email, or explain a better way to do it? Thanks for the help
  16. [the database connection file db.php] <?php session_start(); //connect.php DEFINE ('DB_HOST','217.174.253.159'); DEFINE ('DB_USER','xymalfco3'); DEFINE ('DB_PASSWORD','tArq*****'); DEFINE('DB_NAME','xymalfco3'); $dbc =@mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySql:'. mysqli_connect_error() ); ?> [/db] ============================================================================== [the index file] <!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>Books</title> </head> <body> <form method="post"> <table> <tr> <td>WebsiteTitle:</td> <td><input type="text" name="websitetitle" /></td> </tr> <tr> <td>Link</td> <td><input type="text" name="link" /></td> </tr> <tr> <td>WebMaster</td> <td><input type="text" name="webmaster" /></td> </tr> <tr> <td>Description</td> <td><input type="text" name="description" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="add" /></td> </tr> </table> <?php if (isset($_POST['submit'])) { include 'db.php'; $websitetitle=$_POST['websitetitle'] ; $link= $_POST['link'] ; $webmaster=$_POST['webmaster'] ; $description=$_POST['description'] ; mysql_query("INSERT INTO `links`(WebsiteTitle,Link,WebMaster,Description) VALUES ('$websitetitle','$link','$webmaster','$description')"); } ?> </form> <table border="1"> <?php include("db.php"); $result=mysql_query("SELECT * FROM links"); while($test = mysql_fetch_array($result)) { $id = $test['LinkID']; echo "<tr align='center'>"; echo"<td><font color='black'>" .$test['LinkID']."</font></td>"; echo"<td><font color='black'>" .$test['WebsiteTitle']."</font></td>"; echo"<td><font color='black'>". $test['Link']. "</font></td>"; echo"<td><font color='black'>". $test['WebMaster']. "</font></td>"; echo"<td><font color='black'>". $test['Description']. "</font></td>"; echo"<td> <a href ='view.php?LinkID=$id'>Edit</a>"; echo"<td> <a href ='del.php?LinkID=$id'><center>Delete</center></a>"; echo "</tr>"; } mysql_close($dbc); ?> </table> </body> </html> [nb view and edit php are not showing don't know why is this a tree directory issue? ] ----------------------------------------------- [view.php] <?php require("db.php"); $id =$_REQUEST['LinkID']; $result = mysql_query("SELECT * FROM links WHERE LinkID = '$id'"); $test = mysql_fetch_array($result); if (!$result) { die("Error: Data not found.."); } $WebsiteTitle=$test['WebsiteTitle'] ; $Link= $test['Link'] ; $WebMaster=$test['WebMaster'] ; $Description=$test['Description'] ; if(isset($_POST['save'])) { $websitetitle_save = $_POST['websitetitle']; $link_save = $_POST['link']; $webmaster_save = $_POST['webmaster']; $description_save = $_POST['description']; mysql_query("UPDATE links SET WebsiteTitle ='$websitetitle_save', Link ='$link_save', WebMaster ='$webmaster_save',Description ='$description_save' WHERE LinkID = '$id'") or die(mysql_error()); echo "Saved!"; header("Location: index.php"); } mysql_close($conn); ?> <!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>Untitled Document</title> </head> <body> <form method="post"> <table> <tr> <td>WebsiteTitle:</td> <td><input type="text" name="websitetitle" value="<?php echo $WebsiteTitle ?>"/></td> </tr> <tr> <td>Link</td> <td><input type="text" name="link" value="<?php echo $Link ?>"/></td> </tr> <tr> <td>WebMaster</td> <td><input type="text" name="webmaster" value="<?php echo $WebMaster ?>"/></td> </tr> <tr> <td>DESCRIPTION</td> <td><input type="text" name="description" value="<?php echo $Description ?>"/></td> </tr> <tr> <td> </td> <td><input type="submit" name="save" value="save" /></td> </tr> </table> </body> </html> [/view] --------------------------------------------------------------------
  17. Just wondered if anyone could offer any advice on parsing information from a mySQL database into a Flash movie clip with 5 dynamic text fields. the flash movie clip loops eight times creating an id on ever loop, it will display questions for a quiz game. it has 5 text fields to hold the questions and its possible answers, I would like to draw the questions and answers from the database using php. The tables in my database are structured like this: Table structure for table `answers` -- CREATE TABLE `answers` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `ANSWER` varchar(80) NOT NULL, `CORRECT` tinyint(4) NOT NULL DEFAULT '0', `question_ID` int(11) NOT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID` (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ; -- -------------------------------------------------------- -- -- Table structure for table `questions` -- CREATE TABLE `questions` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `text` varchar(80) NOT NULL, `quiz_ID` int(11) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; -- -------------------------------------------------------- -- -- Table structure for table `quizName` -- CREATE TABLE `quizName` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(45) NOT NULL, `Description` varchar(45) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; I planned to first start a connection to a database, then create a function that select's the data from the database using an ISSET to know what number of the loop we are on. so i guess my questions are: 1) is it possible to use the id number created every cycle of the loop in the flash actionscript in my php? 2) could I use this id to select the questions using my Question ID? hope someone can help.
  18. Hi I am currenly doing a project where i am required to send some values to secure http via post request..I am using Curl for this and that works fine, what I am stuck on is how to retrieve stored database values and send each one individually in a loop to the specified url in the curl script. Hard to explain but heres an example: e.g I have a number of reports in db (123456, 123654, 456321) and each one will retrieve a report from the url as they are the specified report_ids required. I would like to pull each one from the database using a foreach loop assigning the report number to $reportid variable one at a time, and also when the report is retrieved with each one, fwrite it to file. I can currently get all of the above working but only if i assign the report number in the script rather than assigning it the db value and looping through each one. I suppose my question is how can i not only loop through db values but assign each id to the reportid sent via curl and then do it all over again for the next id... Any help in the right direction would be awesome.!
  19. I've been trying to generate a database for a quiz game, where players can submit their questions to a database and send their friends the quiz that they have created. I have three problems i hope you can help: 1. I'm having trouble storing the id generated from my last query into a table after the page has changed using the header function, it always returns a 0. 2. I am also having trouble with the final page echoing both an error message about submission and a success message at the same time. 3. I also have a problem with the header link not being able to modify, although it does take you to that page. When the final submit button is pressed I get this: Please complete form before submission Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/Quiz/go.php:33) in /Applications/MAMP/htdocs/Quiz/go.php on line 52 Notice: Undefined variable: quizid in /Applications/MAMP/htdocs/Quiz/go.php on line 73 Quiz submitted sucessfully my code is like this: <?php //error reporting error_reporting(E_ALL); //connect to mysql $con = mysql_connect("localhost","dinita","*****"); if(!$con) { die('Could not connect: '.mysql_error()); } else{ // SELECT DATABASE mysql_select_db("quizCreation", $con); //Which form is it? if(isset($_POST['title']) &&!empty($_POST['title'])) { //accept POST data $name = $_POST['name']; $desc =$_POST['desc']; } //check if POST data is complete (all required fields are filled in) //if POST data is not complete return an error if(empty($name)) { echo "Please complete form before submission"; } else { //insert quiz title $sql=" INSERT INTO quizName (Name, Description) VALUES ('$name','$desc')"; mysql_query($sql, $con); //get ID for quiz title $quizid = mysql_insert_id(); if (empty($quizid)){ die("No Quiz id"); } } header("Location: http://localhost:8888/Quiz/quiz.creator.html"); } if (isset($_POST['creator'])&&!empty($_POST['creator'])) { //accept POST data $question = $_POST['question']; } //check if POST data is complete (all required fields are filled in) //if POST data is not complete return an error if(empty($question) && empty($ans1) && empty($ans2) && empty($ans3) && empty($ans4)) { echo "Please complete form before submission"; } else { //insert question $sql= "INSERT INTO questions (text, quiz_ID) VALUES ('$question', '$quizid')"; mysql_query($sql, $con); //get id of inserted question $id = mysql_insert_id(); //insert answers + question id for($i=1; $i<=4; $i++) { $correct = 0; if($_POST['radio'] == "radio".$i) { $correct = 1; } $answer = $_POST['answer'.$i]; $sql=" INSERT INTO answers (question_ID, answer, correct) VALUES ('$id','$answer','$correct')"; mysql_query($sql, $con); } } //show message to say insert has completed successfully echo "Quiz submitted sucessfully"; //close connection to mysql mysql_close($con); Thanks in advance for any help you can offer.
  20. Is it possible to make two consecutive calls to a MYSQL DB in one trip to the server? Tables are powered by MYISAM (because fatcow doesn't support InnoDB). PHP 5.3. MYSQL 5.0.91 In case you need more information, my site is broken down into header, footer, main content, and side bar, and they are all separate PHP docs. The main content is made up of a few different pages, one of which is called depending on the user's selections. One of the content pages is a catalog. The script accesses the database and loads the current available inventory. When a user adds item to the cart, the whole page reloads (starting with a DB call to load the catalog) and then populates the cart summary in the sidebar, constituting the second DB call for that single trip to the server. Will the second call potentially be attempted when the table is still locked? I ask because I am experiencing connection failures. Please let me know if you need more information. Thank you in advance for your consideration.
  21. Hello web developers, I'm designing my own website, I want to create online assignment submission system which allows to students to upload their assignment through this webpage,and receive feedback immediately via the browser.The teacher can recieve student documents and grade the student for his assignment. Since Im working on my localhost(XAMMP), let say now Im the student and teacher(Admin) at same time because the work will done in my localhose. so far I just was able to upload file using this php code <form action="upload.php" enctype="multipart/form-data" method="post"> <p> Type some text (if you like):<br> <input type="text" name="textline" size="30"> </p> <p> Please specify a file, or a set of files:<br> <input type="file" name="file" id = " file" size="40"> </p> <div> <input type="submit" id ="u_button" name = "u_button" value="Send"> </div> </form> I know this code simple for uploading file . I have to code " upload.php" inorder to send the uploaded file to my server(XAMMP), How can this be done? and How can I create in my database online submission system for student and teacher that I described above. Your Help would be much appreciated if was provide with source code for explanation.
  22. Hello I'm new to PHP and mySQL, I am trying to populate a database created using MySQL Workbench using information submitted via a form in my website. I have followed as many tutorials as i can and there appears to be an error in the php file, but i'm not sure what it is. my form is coded like this: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form id="quizCreator" name="quizCreator" method="post" action="insert.php"> <p> <label>Quiz Title </label> <br /> <input type="text" name="quizTitle" id="quizTitle" /> <p> <label>Describe your Quiz<br /> <textarea name="desc" id="desc" cols="45" rows="5"></textarea> <br /> </label> <p> <label>Question <br /> <input type="text" name="question" id="question" /> </label> <p> <label>Answers <br /> 1. <input type="text" name="answer1" id="answer1" /> </label> <label> <input type="radio" name="radio" id="radio1" value="1" /> </label> <p>2. <label> <input type="text" name="answer2" id="answer2" /> </label> <label> <input type="radio" name="radio" id="radio3" value="1" /> </label> <p>3. <label> <input type="text" name="answer3" id="answer3" /> </label> <label> <input type="radio" name="radio" id="radio3" value="1" /> </label> <p>4. <label> <input type="text" name="answer4" id="answer4" /> </label> <label> <input name="radio" type="radio" id="radio4" value="1" /> </label> <br /> <p> <input type="Submit" name="nextPage" id="nextPage" value="Submit" /> </form> </body> </html> and my php file is like this: <?php // CONNECT TO MYSQL SERVER $con = mysql_connect("localhost","dinita","**********"); if (!$con) { die('Could not connect: ' . mysql_error()); } // SELECT DATABASE mysql_select_db("quizCreator", $con); // CLEAN THE POST VALUES FROM THE FORM $title = clean($_POST['quizTitle']); $desc = clean($_POST['desc']); $question = $_POST['question']; $ans1 = clean($_POST['answer1']); $ans2 = clean($_POST['answer2']); $ans3 = clean($_POST['answer3']); $ans4 = clean($_POST['answer4']); $correct = clean($_POST['radio']); // CREATE SQL QUERY $sql="INSERT INTO quiz (quiz_name, quiz_desc) VALUES ('$title','$desc')"; $sql="INSERT INTO question (question_body) VALUES ('$question')"; $sql="INSERT INTO answer1 (answer) VALUES ('$ans1')"; $sql="INSERT INTO answer2 (answer) VALUES ('$ans2')"; $sql="INSERT INTO answer3 (answer) VALUES ('$ans3')"; $sql="INSERT INTO answer4 (answer) VALUES ('$ans4')"; $sql="INSERT INTO correct (correct_ans) VALUES ('$correct')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Quiz submitted sucessfully"; mysql_close($con); ?> I'm sorry if I havent explained my self well, Thanks for any help you can offer Dinita
  23. Hello, i have a question. I've recently started a website with videos, and I was looking for something like this. http://video.xnxx.com/tags/ . But i want to make a list with a to z. sorry for the link but this is basically what i'm looking for. ( My website is not based on porn ) so how to echo all the list form my table in the database. From videos Where title LIKE '%Funny%' as Funny Thanks.
  24. I get this message and not sure how to fix it...... Success... NULL Warning: mysqli_get_host_info() expects parameter 1 to be mysqli, null given in /www/zzl.org/o/t/t/ottawaglandorfems/htdocs/class-db.php on line 14 Success... NULL This is my form - <?php require_once('class-db.php'); /** * function to check the validity of the given string * $what = what you are checking (phone, email, etc) * $data = the string you want to check */ function isValid( $what, $data ) { switch( $what ) { // validate a phone number case 'phone': $pattern = "/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i"; break; // validate email address case 'email': $pattern = "/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i"; break; default: return false; break; } return preg_match($pattern, $data) ? true : false; } $errors = array(); if( isset($_POST['btn_submit']) ) { if( !isValid( 'phone', $_POST['phone'] ) ) { $errors[] = 'Please enter a valid phone number'; } if( !isValid( 'email', $_POST['email'] ) ) { $errors[] = 'Please enter a valid email address'; } } if( !empty($errors) ) { foreach( $errors as $e ) echo "$e <br />"; } if ( !empty ( $_POST ) ) { $type = 'post'; $insert = insert($type, $values); } ?> <html> <head> <title>Registration form for Octoberfest With O-G EMS 2013</title> </head> <body> <form action="" method="post"> <p Registration /> <p>First Name:<input type="text" name="fname" > </p> <p>Last Name:<input type="text" name="lname" > </p> <p>Phone Number:<input type="text" name="phone" ></p> <p>Address:<input type="text" name="address" ></p> <p>Department:<input type="text" name="department" ></p> <p>Email Address:<input type="text" name="email" ></p> <p>Level of Training:<input type="text" name="level" ></p> <input type="submit" name="btn_submit" value="Register"> </form> </body> </html> and this is my script <?php require_once('config1.php'); function connect() { $sql = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); if ($sql->connect_error) { die('Connect Error (' . $sql->connect_errno . ') ' . $sql->connect_error); }echo 'Success... ' . mysqli_get_host_info($link) . "\n"; return $sql; } function insert($type){ $sql=connect(); /* Set our params */ $fname = $_POST["fname"]; $lname = $_POST["lname"]; $phone = $_POST["phone"]; $address = $_POST["address"]; $department = $_POST["department"]; $email = $_POST["email"]; $level = $_POST["level"]; $query=("INSERT INTO Oktoberfest2013 (First_Name, Last_Name, Phone, Address, Department, Email_Address, Level_of_Traning) values (?, ?, ?, ?, ?, ?, ?)"); /* Create the prepared statement */ if ($stmt = $sql->prepare($query)); var_dump($qSelect); if ( !$sql->query($query) ) { return "Errormessage: $mysqli->error"; /* Bind our params */ $stmt->bind_param('sssssss', $fname, $lname, $phone, $address, $department, $email, $level); /* Execute the prepared Statement */ $stmt->execute(); } } function select($query) { $sql = connect(); $result = $sql->query($query); while ( $obj = $result->fetch_object() ) { $return[] = $obj; } } ?> Thanks in advance for the help.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.