Search the Community

Showing results for tags 'mysql'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 244 results

  1. $text = "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . Actually, we have a database table called "text_word". So, i want a script that will search through the above text and check if any of those words from the above text does not exist in the "text_word" table, such word should be replaced by asterisks and store the replaced word into a separate column called "unmatched_word" in the same "text_word" table. let's assume the word "welcoming" was not existing in my database what i want to achieve is this. the text is parsed through the program INPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really welcoming" . OUTPUT: "i am a student of oxford university, and i love to tell everyone how much i have enjoyed my four years in school. the whole environment was really ******" . Code Sample: foreach ($text as $word) { $select_word = $f->filterRecord("*", "parts_of_speech", "word", $word); $get_word = $f->show_data($select_word); $count_words = $f->numR($select_word); if ($count_words > 0) { $result[] = '<a href="word/?w='.$word.'">'.$word.'</a>'; } else { $result[] = "******"; } } Please i believe the code is not doing exactly what i want. If you have a better approach to how i can get the job done, i don't mind if you give me a fresh code snippet or script. I hope you understand what i'm trying to do now?
  2. QUESTION ONE: How does one suppress duplicate row entries? QUESTION TWO: In the following case what is causing them to occur? BACKGROUND: I created several tables only to discover that they were not as I wanted them. AFter truncateng each, I dropped what I believed to be poorly structured columns, rearranged some, and added still others. When I tested the result, everything worked great except for one problem -- a single table entry reuslted in duplicate rows. THE TABLE STRUCTURE CREATE TABLE 'table_name' (obs` int(5) NOT NULL AUTO_INCREMENT . . . PRIMARY KEY (`obs`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 A SAMPLE SQL STATEMENT INSERT INTO rss2_podcast_itunes (podcast_no_itunes, itunes_category1, itunes_category2, itunes_category3, itunes_complete, itunes_new_feed_url, itunes_name, itunes_email, itunes_duration, itunes_order, itunes_author, itunes_block, itunes_image, itunes_explicit, itunes_summary) VALUES ('54', 'education', 'language', 'English', '', '', 'Roddy A. Stegemann', 'kiusau@me.com', '00:01:01', '', 'Roddy A. Stegemann', '', 'http://www.grammarcaptive.com/_images/captive.png', '', 'Test') Please note the following: No value is entered for the obs field/column. The auto increment advances one for each row entered. Below each successfully loaded row entry appears another row identical in every way but one -- the appearance of an incremental advance in the value of the obs field. Please advise. Roddy
  3. 1) I have login scripts working in combination with database table and verify_password 2) the login scripts are RE-USED for another site 3) In the test fase I use the SAME database table values and copy these in phpmyadmin to a new table is it possible there is some kind of copy security or whatever in the encrypted original table values? I presume this because there is no password_verify match. It could be I'm overlooking something, but the password_verify($form_pw, $database_pw) procedure, does not need encryption BEFORE $form_pw is read? The only conclusion then is: the value in the newly copied table is not the same is in the original table. (of course I can also reinstall the registration scripts to test it, but i would like to rule out other causes ) EDIT: solved. silly me using the wrong password
  4. Hey guys, I have a problem. I want to write a record in my db when it does not already exists. For this, i have been looking on the web and found multiple solutions on Stackoverflow. The one I use is proved working, by the stack user however I get my die response :(. I use the following query (mysql/php): $query= "IF NOT EXISTS (SELECT * FROM tasksmade WHERE teamnumber='$teamnumber' AND tasknumber='$tasknumber' AND date='$date') INSERT INTO tasksmade (teamnumber, tasknumber, taskfinished, date) VALUES ('$teamnumber', '$tasknumber', '$taskfinished', '$date')"; $result= mysql_query($query,$mysql) or die("The query result has failed on the db!"); Hope someone can help! Thanks!
  5. Hi all, I have a question about join or inner join; not sure in what way it should be used. I now use 2 queries in 2 different databases (made in phpmyadmin). SELECT `title` FROM `writers` WHERE id ='qwert58efedd1979f'; SELECT `name`, `lastname`, `str`, `nr`,` place` FROM `client` WHERE id ='qwert58efedd1979f'; I would like to make one mysql query and use join to search in 2 tables in 2 different databases. Can anyone tell how mysql does this?
  6. Hello folks, I installed a XAMPP Version 7.0.15 on my windows 7(32-bit) computer but it doesn't work properly.When i open in the browser it shows "The site can't be reached". What's the solution for it? please help me. Thank you in Advance..
  7. Hi, i'm new and i hope not wrong with to ask the following question: i see this instruction SELECT * INTO CustomersBackup2013 IN 'Backup.mdb' FROM Customers; in thee site, that is in a section of copy from sql (to mdb, i thougt since the db name is backup.mdb). I'm looking for the similar command for copy/create the similar command but for mysql as origin and mdb as destination. Thanks of all.
  8. is there a way to make a singular login for a wordpress website that also logs a person into the forums and the wiki at the same time?
  9. Looking at how form items are put into a mysql table, the part that seems daunting is if ones form has like 50 items... having to list all those IDs with their variables makes me wonder if there is a better way or if its just " it up buttercup.".
  10. So my question is: how can I insert variables into my mysql queries in php? This is my code now, I would like to use the $me and the $friend variables to work in the sql query: function newChat($me, $friend) { global $conn; $sql = "SELECT id FROM chats WHERE (person1 = $me AND person2 = $friend) OR (person1 = $friend AND person2 = $me);"; mysqli_query($conn, $sql) or die('Error querying database.'); echo "check <br />"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo $row['id'] . ' - ' . $row['person1'] . ' - ' . $row['person2'] . ' - ' . $row['date'] .'<br />'; } } newChat('John', 'Marie'); Also if I set $sql to "SELECT * FROM chats" it only gives me one row of my two test rowes in my database. (it only gives the second row, and just ignores the first one? --> a screenshot of the database is at the end of this post) Can anyone please help me with this? Thanks already!
  11. In phpmyadmin I did the following query and had it output in php like this: $sql = "UPDATE `table` SET count = count + 1 WHERE unique_nr = 5175781"; this all worked well. though when I tried to implement it in my script I had an error: script: <?php // code to establish dbase connection: var_dump($unique_nr); // $stmt = $conn->prepare('UPDATE table SET count = ? WHERE unique_nr = ? '); $stmt = $conn->prepare('UPDATE table SET count = count + 1 WHERE unique_nr = ? '); $stmt->bind_param("is", $count, $unique_nr); $stmt->execute(); ?> resulting in an error message. I also tried this way of writing for bind_param: $stmt->bind_param("s", $unique_nr); but that didnt update the column, though there wasnt an error message anymore
  12. MySQL queries are not working only inside this block: ... if (isset($_POST['send'])) { } ... The variable itself is set and transferred from the form. What could be the reasons of this and how is better to check?
  13. Dear all, For photo gallery tables (named: gallery_album, gallery_image, gallery_relation), I have seen a recommendation to use InnoDB engine in preference to MyISAM. I thought MyISAM would be the choice for all tables but tables for transactions. Do you agree with the recommendation to using InnoDB for photo gallery tables and why?
  14. Dear all, I am trying to dig into the exact difference between key and index in MySQL tables. Some say they are synonymous, others give some differences. I still don't feel confident enough to decide when to use each on a table. I would appreciate if someone well-versed in their difference explain such difference and when to use each. Thanks.
  15. Hi all, I have uploaded an image to a folder/directory and stored its size using the $_FILES['image']['size'] superglobal. While the image source size was reading 153kb, the stored size is 157317. Why there is a difference in size?
  16. Dear all. For an image uploaded to a folder/directory and stored its name, type, and size in a DB table, what could be the merits of also storing its temporary name, noting that such temporary name is deleted by the server upon moving the image to the desired folder/directory?
  17. Hi all, In fetching a result from a table (below code), 1 is also printed after the fetched record (fetched record below). There is no 1 in the table, nor have I accidentally included it in my script. What is it and why does it appear? <?php require 'db/connect.php'; if($result = $db->query("SELECT * FROM user")) { if ($count = $result->num_rows) { $rows = $result->fetch_assoc(); echo '<pre>', print_r($rows), '</pre>'; } } ?> Array ( [id] => 1 [first_name] => Bill [last_name] => John [bio] => I'm a web developer [created] => 2016-11-21 12:50:12 ) 1
  18. Hi all, <?php require 'db/connect.php'; $result = $db->query("SELECT * FROM people"); ?> I obtained a blank page running the above script, which indicates that everything is fine (path and table name are correct). I then removed the * from the query to see if it would report an error, but it did not. I added print_r($result); and run it. Nothing has changed. I included the * and run, it reported the number of rows and columns in the table. Why there has a been a lack of error reporting in this instance, noting that the ini file is configured to report all sorts of errors, even the warnings and notices (and it is reporting all that in other scripts)?
  19. Hi all, In one website, I read the following note: "You should also think about storing files locations on disk. Using MySQL for storing images is thought to be Bad Idea™. Handling SQL table with big data like images can be problematic." Do you agree? If not, why? What is the best practice in storing and displaying on a website a big number of images?
  20. I'm trying to select data from a MySQL database that is hosted on a webserver. I want to be able to retrieve the data from a table within the database and then illustrate it within a HTML table. There's an example on W3Schools that I've been following, but I'm unable to retrieve the data successfully. http://www.w3schools.com/php/php_ajax_database.asp Below is the source code: (HTML) <html> <head> //Javascript code <script> function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">Peter Griffin</option> <option value="2">Lois Griffin</option> <option value="3">Joseph Swanson</option> <option value="4">Glenn Quagmire</option> </select> PHP File: (getuser.phd) <!DOCTYPE html> <html> <head> <style> table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} </style> </head> <body> <?php $q = intval($_GET['q']); $con = mysqli_connect('www.example.com','user_Admin','12345-678','my_DB'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"ajax_demo"); $sql="SELECT * FROM user WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> <th>Hometown</th> <th>Job</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "<td>" . $row['Hometown'] . "</td>"; echo "<td>" . $row['Job'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> </html> *MySQL table is attached I think the issue might exist from mysqli_select_db($con,"ajax_demo"); onwards inside the PHP file. Should I be referring to the table that contains the data inside the database? I have the PHP File hosted on my webserver, so I'm not sure why it won't retrieve that data when a person is selected from the list of options on the HTML page. Any help would be much appreciated.
  21. Dear all, I came across the following statement on one website: "Note: Since MySQL 5.5.3 you should use utf8mb4 rather than utf8. They both refer to the UTF-8 encoding, but the older utf8 had a MySQL-specific limitation preventing use of characters numbered above 0xFFFD." 1) Is there any drawbacks in using utf8mb4, or it is recommended for use from now on?
  22. Hi I have been working on building a custom post a result set to a database which thankfully I have now managed with some help, now I am working on the other end of this project the displaying the saved data back to users, From the start of this I have an online tournament hosting group that go to my form and post a list of player names with points earned per tournament. Once the form is submitted it's sent to my form_processing.php where the results are exploded and split into 2 arrays "$player_name, $points" Then on the INSERT I have an INSERT $sql = "INSERT into `bg_points` (`player_name`, `points`) values (?, ?) on duplicate key update points = points + ?"; to of course update current player points if the exist or add new records if not. Then finally saved into my DB table, now I am working on building the page to display these points back to the players so they can track their earned points and standings each month. which is easy enough I just call an MySQL SELECT * FROM statement on the DB table that's done, Now I need to sort these results in lowest to highest order by points so if player1 has 120 points player2 has 50 points player3 has 75 points player4 has 5 points then I need to be displaying these back as player4 player2 player3 player1 I have had a look online for some possible examples to help guide me into this and I either get HTTP 500 or just no effect at all. here is the very basic code I have put together so far which I can and will update and add into my site framework once I have it in order and working... <HTML> <head></head> <body bgcolor="#0000FF"> <?PHP $servername = "localhost"; $username = "***********"; $password = "*******"; $dbname = "***********"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //output the saved data $sql = "SELECT * FROM `bg_points` "; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " $nbsp $nbsp Playerv Name: " . $row["player_name"]. " $nbsp $nbsp Points: " . $row["points"]. "<br>"; } } else { echo "0 results"; } $conn->close(); ?> </body> </html> thanks for any help or ideas in advanced
  23. Hi I am having trouble inserting data into my MySQL database. This is my PHP code ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); static $connection; if(!isset($connection)) { $connection = new mysqli("localhost","username","password"); } if ($connection->connect_error) { die("Connection failed: " . $connection->connect_error); } $stmt = $connection->prepare("INSERT into Product(product_title,product_price,product_availability,productImage_1,productImage_2,productImage_3,productImage_4,product_description,product_shipping,product_pickup) VALUES(?,?,?,?,?,?,?,?,?,?)"); $product_title = $_POST['title']; $product_price = $_POST['price']; $product_availability = $_POST['stock']; $null = NULL; $product_description = $_POST['description']; $product_shipping = $_POST['postage']; $product_pickup = $_POST['pickup']; $stmt->bind_param('sisbbbbsis',$product_title,$product_price,$product_availability,$null,$null,$null,$null,$product_description,$product_shipping,$product_pickup); $stmt->send_long_data(3, file_get_contents($_FILES['img1']['tmp_name'])); $stmt->send_long_data(4, file_get_contents($_FILES['img2']['tmp_name'])); $stmt->send_long_data(5, file_get_contents($_FILES['img3']['tmp_name'])); $stmt->send_long_data(6, file_get_contents($_FILES['img4']['tmp_name'])); $stmt->execute(); $stmt->close(); $connection->close(); echo "Product inserted successfully"; I am also getting these errors. Notice: Undefined index: title in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 61 Notice: Undefined index: price in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 62 Notice: Undefined index: stock in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 63 Notice: Undefined index: description in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 67 Notice: Undefined index: postage in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 68 Notice: Undefined index: pickup in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 69 Fatal error: Call to a member function bind_param() on boolean in /Applications/MAMP/htdocs/Bourke/insertproduct.php on line 71 Thanks in advance.
  24. <?php $host = 'localhost'; $username = 'root'; $password = ''; $datadase = 'registerfinal'; $connect = mysqli_connect($host, $username, $password) or die ('error to connect to datadase'.mysqli_error()); if ($connect) { echo 'mysqli connect succsessfull'; } echo '<br /><br />'; $selectdb = mysqli_select_db($connect, $datadase) or die ('unable to select datadase'.mysqli_error()); if($selectdb) { echo 'database selected succsessfully'; } if(isset($_POST['savedetails'])) { $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = $_POST['username']; $password = $_POST['password']; $repeat_password = $_POST['repeat_password']; $gender = $_POST['gender']; $country = $_POST['country']; if(isset($_POST['food'])) { $food = $_POST['food']; $favfood = ""; foreach($food as $meal ) { $favfood = $meal.","; print_r($favfood); } } if(isset($_POST['imageUpload'])) { $imageUploadname = $_FILES['imageUpload']['name']; $imageUploadsize = $_FILES['imageUpload']['size']; $imageUploadtmp_name = $_FILES['imageUpload']['tmp_name']; $imageUploadtype = $_FILES['imageUpload']['type']; $uploadFolder = "uploadFolder/"; $destinationName = rand(1000, 10000).$imageUploadname; move_uploaded_file($imageUploadtmp_name, $uploadFolder.$destinationName); echo "$imageUploadname"; echo "$imageUploadsize"; echo "$imageUploadtmp_name"; echo "$imageUploadtype"; echo "$destinationName"; } $sqltwo = "INSERT INTO `registerfinaltable` (`id`, `firstname`, `lastname`, `username`, `password`, `repeat_password`, `gender`, `food`, `country`, `imageUploadname`, `imageUploadsize`, `imageUploadtype`) VALUES (NULL, '$firstname', '$lastname', '$username', '$password', '$repeat_password', '$gender', '$favfood', '$country', '$destinationName', '$imageUploadsize', '$imageUploadtype')"; $results = mysqli_query($connect, $sqltwo) ; if($results){ echo "inserted successfully"; } } ?> <html> <head> <title>register</title> </head> <body> <form action = "" method = "post" enctype = "multipart/form-data" > <label>first name : <input type = "text" name = "firstname" /> </label> <br /><br /> <label>last name : <input type = "text" name = "lastname" /> </label><br /><br /> <label>username : <input type = "text" name = "username" /> </label><br /><br /> <label>password : <input type = "password" name = "password" /> </label><br /><br /> <label>repeat password : <input type = "password" name = "repeat_password" /> </label><br /><br /> <label>Male : <input type = "radio" name = "gender" value = "Male" /> </label><br /><br /> <label>Female : <input type = "radio" name = "gender" value = "Female" /> </label><br /><br /> <label>pizza : <input type = "checkbox" name = "food[]" value = "pizza"/> </label><br /><br /> <label>burger : <input type = "checkbox" name = "food[]" value = "burger"/> </label><br /><br /> <label>chips : <input type = "checkbox" name = "food[]" value = "chips"/> </label><br /><br /> <label>sausage : <input type = "checkbox" name = "food[]" value = "sausage"/> </label><br /><br /> <label>sandwich : <input type = "checkbox" name = "food[]" value = "sandwich"/> </label><br /><br /> <label>Image : <input type = "file" name = "imageUpload" /> </label><br /><br /> <select name = "country"> <?php $sql = 'SELECT * FROM `countrie` '; $querry = mysqli_query($connect, $sql); while($country = mysqli_fetch_array($querry)):; ?> <option value = "<?php echo $country['country']; ?>"><?php echo $country['country']; ?></option> <?php endwhile;?> </select> <br /> <input type = "submit" name = "savedetails" /> </form> <table border = "1" bgcolor = "" width = "100%"> <tr><th>id</th><th>Firstname</th><th>Lastname</th><th>Username</th><th>Password</th><th>Password 2</th><th>Gender</th><th>Fav. Food</th> <th>Image</th> <th>Country</th><th>imageUploadname</th><th>imageUploadsize</th><th>imageUploadtype</th></tr> <?php $sqldata = "SELECT * FROM registerfinaltable"; $querysqldata = mysqli_query($connect, $sqldata); while($rows = mysqli_fetch_array($querysqldata) ):; ?> <tr> <td><?php echo $rows['id'];?></td> <td><?php echo $rows['firstname'];?></td> <td><?php echo $rows['lastname'];?></td> <td><?php echo $rows['username'];?></td> <td><?php echo $rows['password'];?></td> <td><?php echo $rows['repeat_password'];?></td> <td><?php echo $rows['lastname'];?></td> <td><?php echo $rows['gender'];?></td> <td><?php echo $rows['food'];?></td> <td><?php echo $rows['country'];?></td> <td><?php echo $rows['imageUploadname'];?></td> <td><?php echo $rows['imageUploadsize'];?></td> <td><?php echo $rows['imageUploadtype'];?></td> <?php endwhile;?> </tr> </table> </body> </html>
  25. My goal is to store javascript code into a database. My first idea was to use htmlspecialchars; store it in mysql in a table column and later retrieve it with htmlspecialchars_decode. All this to prevent injection / hacking. But online I read one or two warnings that it wouldnt work, which I assume is so (I didnt test it, but it seems quite obvious afterwards) . So my question is: is it possible to have a user store javascript in a database and use it in a php script for specific purposes in a secure way?