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. Hello dear php-experts - good day. note; i run linux opensuse 13.1 the final goal is to get stored some xml-files in a mysql-database. thats what i am looking for. - the xml-files are derived from a osm-request - at a OpenSteetpmap-api. and thats why i am here. Guess that you are good php and mysql-experts see the data <node id="2064639440" lat="49.4873181" lon="8.4710548"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="turkish"/> <tag k="email" v="info@lynso.de"/> <tag k="name" v="Kilim - Café und Bar Restaurant"/> <tag k="opening_hours" v="Su-Th 17:00-1:00; Fr, Sa 17:00-3:00"/> <tag k="operator" v="Cengiz Kaya"/> <tag k="phone" v="06 21 - 43 755 371"/> <tag k="website" v="http://www.kilim-mannheim.de/"/> </node> <node id="2126473801" lat="49.4851170" lon="8.4756295"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="italian"/> <tag k="email" v="mannheim1@vapiano.de"/> <tag k="fax" v="+49 621 1259 779"/> <tag k="name" v="Vapiano"/> <tag k="opening_hours" v="Su-Th 10:00-24:00; Fr-Sa 10:00-01:00"/> <tag k="operator" v="Vapiano"/> <tag k="phone" v="+49 621 1259 777"/> <tag k="website" v="http://www.vapiano.de/newsroom/?store=29"/> <tag k="wheelchair" v="yes"/> </node> <node id="667927886" lat="49.4909673" lon="8.4764904"> <tag k="addr:city" v="Mannheim"/> <tag k="addr:country" v="DE"/> <tag k="addr:housenumber" v="5"/> <tag k="addr:postcode" v="68161"/> <tag k="addr:street" v="Collinistraße"/> <tag k="amenity" v="restaurant"/> <tag k="name" v="Churrascaria Brasil Tropical"/> <tag k="phone" v="+496211225596"/> <tag k="wheelchair" v="limited"/> </node> <node id="689928440" lat="49.4798794" lon="8.4853418"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="greek"/> <tag k="email" v="epirus70@hotmail.de"/> <tag k="fax" v="0621/4407 762"/> <tag k="name" v="Epirus"/> <tag k="opening_hours" v="Mo-Sa 12:00-15:00,18:00-24:00"/> <tag k="phone" v="0621/4407 761"/> <tag k="smoking" v="separated"/> <tag k="website" v="http://epirus-ma.blogspot.com/"/> <tag k="wheelchair" v="no"/> </node> <node id="689928445" lat="49.4799409" lon="8.4851357"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="italian"/> <tag k="email" v="gianlucascurti@ristorante-augusta.de"/> <tag k="name" v="Ristorante Augusta"/> <tag k="opening_hours" v="Mo-Fr 12:00-14:00,18:00-23:00;Su 12:00-14:00,18:00-23:00"/> <tag k="phone" v="0621 449872"/> <tag k="website" v="ristorante-augusta.com/"/> <tag k="wheelchair" v="no"/> </node> with the following fields in the db: CREATE DATABASE `db123` DEFAULT CHARACTER SET latin1 COLLATE latin1_german2_ci; USE hans; CREATE TABLE `pois` ( `id` BIGINT(20) UNSIGNED NOT NULL, `lat` FLOAT(10,7) NOT NULL, `lon` FLOAT(10,7) NOT NULL, `name` VARCHAR(255) COLLATE utf8_bin NOT NULL, `amenity` VARCHAR(255) COLLATE utf8_bin NOT NULL, `operator` VARCHAR(255) COLLATE utf8_bin NOT NULL, `vending` VARCHAR(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin; EDITED BY MODERATOR - DB CREDENTIALS REMOVED see the dataset; - which is stored in the file mysql.txt the dataset - it is gathered from the request on the overpass-api which resides here http://www.overpass-turbo.eu cf. http://overpass-turbo.eu/?q=PCEtLQpUaGlzIHF1ZXJ5IGxvb2vEiGZvciBub2Rlcywgd2F5xIhhbmQgcmVsYXRpb27EiAp3aXRoIMS0ZSBnaXZlbiBrZXkvdmFsxIsgY29tYmluxKvErW4uCkNoxJFzxLh5b3XEl8SoxLrEriDEpMSmxIZ0xLZoxLhSdcS-YnV0dMWfYWJvxLwhCsSCPgp7e8WAeT1hbcS9xLN5fX3FuHvFhMWGZT3EqHN0YcWbxKR0xoMKPG9zbS1zY3JpcMWkxZp0cMWsPSJ4bWwixbcgIDzFqcWQxqnGqsarxIrEjMSOdHlwxokixJnEm8aoCsawxrA8aGFzLWt2xL_Go8W5xbvGgyIgdseIxobFhcSLx4svxq_GvjxixbF4LcayxI0gxbnHmG94xoPHlMa9xr8vx5x5x5XGscSLx53Gtca3xqPEoHnGvMa-xqrHgMeCx4THhmvHj8eKfceMx44ixbnGh8eSx73HpMe0xqvHoMeax6jHnnvIiMejx6o8x6fHrMepx6XHtciKx67GuMSoxKrErMSux7PHtMe2x4PHhceHyIDFusWBx4vHjcePyIJlx5PHqse1yIjHm8iSyIvIjX3Ihcemx6jGr8iQxq3Ersi3cMabbsWkbcSaxrjFsWTHssi0PMSoY8WbxZfEtsa2xrhkb3duIsmGyLzFjci_yYHGo3PFgGxlxa7JksekyJDGlcaXxpnGm8adPg&c=BNJBWRBb1P you see a request on the left part of the screen note: to get the output - just press the button in the top-menu called "Ausführen" after this you press the button called "DATEN" on the top-right - just below the green button called "flatter this": after pressing this "DATEN"-button you see the data in the right window of the screen. note - it has got various ids - that means that the osm-file does not give back constantly all the tags... the last question; does this make any problems to our project - does this has any influence on our db-connection...!?!? see the output here: <node id="2064639440" lat="49.4873181" lon="8.4710548"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="turkish"/> <tag k="email" v="info@lynso.de"/> <tag k="name" v="Kilim - Café und Bar Restaurant"/> <tag k="opening_hours" v="Su-Th 17:00-1:00; Fr, Sa 17:00-3:00"/> <tag k="operator" v="Cengiz Kaya"/> <tag k="phone" v="06 21 - 43 755 371"/> <tag k="website" v="http://www.kilim-mannheim.de/"/> </node> <node id="2126473801" lat="49.4851170" lon="8.4756295"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="italian"/> <tag k="email" v="mannheim1@vapiano.de"/> <tag k="fax" v="+49 621 1259 779"/> <tag k="name" v="Vapiano"/> <tag k="opening_hours" v="Su-Th 10:00-24:00; Fr-Sa 10:00-01:00"/> <tag k="operator" v="Vapiano"/> <tag k="phone" v="+49 621 1259 777"/> <tag k="website" v="http://www.vapiano.de/newsroom/?store=29"/> <tag k="wheelchair" v="yes"/> </node> <node id="667927886" lat="49.4909673" lon="8.4764904"> <tag k="addr:city" v="Mannheim"/> <tag k="addr:country" v="DE"/> <tag k="addr:housenumber" v="5"/> <tag k="addr:postcode" v="68161"/> <tag k="addr:street" v="Collinistraße"/> <tag k="amenity" v="restaurant"/> <tag k="name" v="Churrascaria Brasil Tropical"/> <tag k="phone" v="+496211225596"/> <tag k="wheelchair" v="limited"/> </node> <node id="689928440" lat="49.4798794" lon="8.4853418"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="greek"/> <tag k="email" v="epirus70@hotmail.de"/> <tag k="fax" v="0621/4407 762"/> <tag k="name" v="Epirus"/> <tag k="opening_hours" v="Mo-Sa 12:00-15:00,18:00-24:00"/> <tag k="phone" v="0621/4407 761"/> <tag k="smoking" v="separated"/> <tag k="website" v="http://epirus-ma.blogspot.com/"/> <tag k="wheelchair" v="no"/> </node> <node id="689928445" lat="49.4799409" lon="8.4851357"> <tag k="amenity" v="restaurant"/> <tag k="cuisine" v="italian"/> <tag k="email" v="gianlucascurti@ristorante-augusta.de"/> <tag k="name" v="Ristorante Augusta"/> <tag k="opening_hours" v="Mo-Fr 12:00-14:00,18:00-23:00;Su 12:00-14:00,18:00-23:00"/> <tag k="phone" v="0621 449872"/> <tag k="website" v="ristorante-augusta.com/"/> <tag k="wheelchair" v="no"/> </node> well you see that i have some questions the second one is regarding the variations in the mysql.txt - file - i.e. the different number of tags.; How to make the script robust so that it is able to work with this - and does not stopt to work....!? I look forward to hear from you many many greetings
  2. I have 3 tables. 1)state(s_id, details); 2)univer(u_id,details,s_id); 3)sub(su-id,daetails,u_id, s_id) Now there is a problem, for ever selection of state and univer there is multiple choice of sub and they can be common in different selections. And how to store these values in databse and can call in a selection menu. so how can i solve it?
  3. Hey, I'm really new to PHP and having some difficulties with $_SESSION and getting userid from the database. I've managed to put content to my database and also a login script. Though, adding sessions has been a pain. Here's what I got so far: $sql = "SELECT username, password FROM users WHERE username = '$username' and password = '$pas'"; $query_login = $db->prepare($sql); $query_login->execute(array('userid' => $userid, 'username' => $username, 'password' => $pas)); $result = $query_login->rowcount(); if ($result>0) { session_start(); $_SESSION['username'] = $username; $_SESSION['logged'] = 1; $_SESSION['userid'] = $result['userid']; header('Location: ../user/user.php'); }
  4. Hello there, I'm really new at PHP and I've been reading several beginner tutorials so please accept my apologies for any stupid questions I may ask along the way. I've gotten as far as installing XAMPP, set up a database plus PHP form and I'm struggling to figure out how to insert values from an array into my database. I've learnt the code in one particular way (see beginner tutorials) so I was wondering if you could help me keeping this in mind. I know there'll be a million better ways to do what I'm doing but I fear I will be bamboozled with different code or differently structured code. Anyway the tutuorials I'm reading don't see to cover how I can insert an array of values into my database, just singular values. In the attached file, I have 10 rows of 2x text inputs (20 text inputs total). Each row allows the user to enter a CarID and CarTitle. I've commented out the jQuery which validates the inputs so I can build a rudimentary version of this validation with PHP. I thought that because the line $sql="INSERT INTO carids_cartitles (CarID, CarTitle) VALUES ($id, $title)"; is inside the foreach, means that for each pair of values from the form it'd insert to the database. It doesn't do this. If I enter two or more CarIDs and CarTitles, only one pair of values gets saved to the database. I'm sorry if I haven't explained this well enough, any questions please let me know. Many thanks for your help in advance. form.php
  5. Hi Guys, I'm new to OOP. I've mastered some basic syntax, but am wondering about an issue of design. To clarify in this example, I'm simply looking to pull Team data from a Database (I've not included my db class (PDO wrapper) although I know it is working. Although I have seen this sort of method below in a book (I believe and on the net) and it does work, I cannot help thinking coupling the DB class so tightly with the Team Class isn't a great approach. Can anyone give me feedback as to whether my approach is valid? While I can see the negative issue of tight coupling (i.e. changes to any database method would require multiple changes in Team (as team methods were added), I cannot really see an alternative way of doing this? I guess this is an issue of a design pattern or more advance OOP. Can anyone suggest an alternative way and/or more reading on making the coupling looser while still achieving my objectives? Should, for example, all DB functionality in getName be done during implementation? I initally thought pushing all db related functionality inside a Team method was wise and the best way then to add further methods, i.e. getResults method would be similar to getName but obviously with a different query and processing afterwards inside Team, but now I wonder if all should be in the implementation, or is there another approach? Thanks in advance. // create team class class Team { private $db; private $team_name; private $team_id; private $result; // in constructor lets pass DB object public function __construct($db) { $this->db = $db; } //function to get team name public function getName($team_id) { $this->team_id = $team_id; $this->db->query("SELECT team_name, nickname, founded FROM club WHERE team_id=:teamid"); $this->db->bind(':teamid', $this->team_id); if ($result = $this->db->single()); { return $result[]; } } }// end class // Implementation $team_id=1; //passed from user input // First Create Db Object with correct passed variables $database = new Database($server,$db_type); // Invoke DB connect method $database->connect(); // Now create Team object, pass it database object $team = new Team($database); // call Team method $team_display = $team->getName($team_id); // close db $database->closedb();
  6. Hi I wondering what i did wrong here: I wont to register 1 or 0 into database. Checkbox file: <?php include("db-tilkobling.php"); $sqlSetning="SELECT * FROM Kvarterbestilt ORDER BY Møtt;"; $sqlResultat=mysqli_query($db,$sqlSetning) or die ("Ikke mulig å hente data fra databasen"); $antallRader=mysqli_num_rows($sqlResultat); print("<input type='checkbox' name='møtt' value='$møtt'>"); ?> Register-møtt.php <?php include("start.html"); ?> <br/> <p>Registrer Møtt/Ikke møtt ved å fylle ut skjemaet under</p> <form method="post" action="" id="registrerAnsattSkjema" name="registrerAnsattSkjema"> <fieldset> <legend>Registrer møtt / ikke møttt</legend> <label for="personnummer">Personnummer</label> <?php include("listeboks-personnummer.php"); ?><br/> <label for="timenummer">Timenummer</label> <?php include("listeboks-timenummer.php"); ?><br/> Sjekk av denne boksen hvis pasient har møtt til time:<br/> <?php include("checkbox-møtt.php"); ?><br/> <input type="submit" name="registrerMottKnapp" id="registrerMottKnapp" value="Registrer møtt/ikke"> <input type="reset" name="nullstill" id="nullstill" value="nullstill"> </fieldset> </form><br/> <?php /* include("valider-mott.php");*/ $registrerMottKnapp=$_POST ["registrerMottKnapp"]; if ($registrerMottKnapp) { $personnummer=$_POST["Personnummer"]; $timenummer=$_POST["Timenummer"]; $møtt=$_POST["Møtt"]; } if ($møtt == '1') { $query = mysql_query("INSERT INTO Kvarterbestilt(Møtt) VALUES('1')"); } /* $lovligFornavn=validerFornavn ($fornavn); $lovligFornavn2=validerFornavn2 ($fornavn); $lovligFornavn3=validerFornavn3 ($fornavn); $lovligEtternavn=validerEtternavn ($etternavn); $lovligEtternavn2=validerEtternavn2 ($etternavn); $lovligEtternavn3=validerEtternavn3 ($etternavn); $lovligYrke=validerYrke ($yrke); $lovligYrke2=validerYrke2 ($yrke); $lovligYrke3=validerYrke3 ($yrke); if (!$lovligFornavn) { print("Fornavn er ikke fylt ut! <br/>"); } else if (!$lovligFornavn2) { print("Bare bokstaver og mellomrom er tillat; $fornavn<br/>"); } else if (!$lovligFornavn3) { print("Ingen tall tillat; $fornavn<br/>"); } else if (!$lovligEtternavn) { print("Etternavn er ikke fylt ut!<br/>"); } else if (!$lovligEtternavn2) { print("Bare bokstaver og mellomrom er tillat; $etternavn<br/>"); } else if (!$lovligEtternavn3) { print("Ingen tall tillat; $etternavn<br/>"); } else if (!$lovligYrke) { print("Yrke er ikke fylt ut!<br/>"); } else if (!$lovligYrke2) { print("Bare bokstaver og mellomrom er tillat; $yrke<br/>"); } else if (!$lovligYrke3) { print("Ingen tall tillat; $yrke<br/>"); } */ /* include("db-tilkobling.php"); $check=mysqli_query($db,"SELECT * FROM Kvarterbestilt WHERE Personnummer='$personnummer' AND Timenummer='$timenummer'"); $checkrows=mysqli_num_rows($check); if($checkrows>0){echo "Ansatt eksiterer fra før";} else { $sqlSetning="INSERT INTO Kvarterbestilt(Møtt) WHERE Personnummer='$personnummer' VALUES ('$møtt');"; mysqli_query ($db,$sqlSetning) or die ("Ikke mulig Ã¥ registrere i db"); print ("Det er registrert at pasienten har $møtt til timen $timenummer"); } } */ include("slutt.html"); ?>
  7. I am new to PHP and MySQL, but not to coding in general. I finally got brave and I am trying to move from a MS Access database to a server based MySQL database with a web enabled front end. The goal of the database is to be online aviation logbook with the ability to enter/retrieve data with my iPhone. My ultimate end state is to code my app for the phone. I have exported all of my Access data to a MySQL database on server. I've spent the last two weeks learning PHP and MySQL by writing small scripts and expanding as I learned. I finally reached a point where I was ready to write the code for entering all of the data for a flight and inserting into the database. I had mastered all of the sub-steps. I built a form for entering the data. The form querys the DB to populate some of the drop down menus. All of that works fine and the drop menus are populated with information from the DB. After I click on the "submit" button, the code throws an error. I eventually learned how to capture and display the error. I was getting the following: Access denied for user ''@'localhost' to database 'FltLogbook'. Initially, I thought that maybe there was some sort of data type mismatch (I wasn't displaying the error initially, just a phrase stating the add failed) and I ended up commenting out the INSERT query and trying to insert just one piece (column) of data. That didn't work. Then I finally stumbled on the method to display the error. After seeing the actual error statement, I thought that I was losing DB connectivity after pressing submit and executing the code or it may be a permission issue. If I place the "INSERT" code up in the portion of the code where the form is built, I can successfully add a record. So my username/password has the correct privileges since I can add a record using the code - just not where I want to do it. After googling, it looks like the code is passing a null value for user (and I assume password). I have no idea why, but suspect it has something to do with the "POST" process after the submit. Stumbling upon another function (connection_status), it passes a "0" for normal in both sections of the code. I am truly stumped and have been this way for three days now!! I have googled anonymous, the exact error phrase, etc. None of it has helped me bridge this impasse. I am sure, as in previous coding impasses, it will be quite obvious to someone. Thanks for any help, Heed <?php $conn = mysqli_connect("localhost", $_POST[user], $_POST[password], "FltLogbook"); if ($_POST[op] != "add") { //Form not shown, show it $display="<h1>Add Logbook Entry</h1>"; $CnxSt = connection_status(); $display .= "Connection Status: $CnxSt<br><br>"; $display .= " <form method=\"post\" action=\"$_SERVER[PHP_SELF]\"> <strong>Details:</strong> <table border=\"1\" width=\"520\"> <tr> <td><input type=\"checkbox\" name=\"Sim\">Simulator</td> <td colspan=\"2\">SimType: <select name=\"SimType\"> <option value=\"\"> NA </option> <option value=\"Miltary Visual\"> Military Visual </option> <option value=\"Military Non-Visual\"> Military Non-Visual </option> <option value=\"ATD\"> ATD </option> <option value=\"FTD\"> FTD </option> <option value=\"FFS\"> FFS </option></select></td> </tr> <tr> <td>Date: <input type=\"date\" name=\"FltDate\"></td> <td>Aircraft: <select name=\"Aircraft\"> <option selected=\"selected\" value=\"26\">C-172M</option>"; $AcftQuery="SELECT Aircraft.AirKey,Aircraft.Aircraft, Aircraft.ME, Aircraft.Complex, Aircraft.HighPerf FROM Aircraft"; $AcftResult=mysqli_query($conn, $AcftQuery) or die ("Aircraft Query Failed"); While ($AcftRow=mysqli_fetch_array($AcftResult)) { $AcftKey=$AcftRow['AirKey']; $AcftAircraft=$AcftRow['Aircraft']; $AcftME=$AcftRow['ME']; $AcftComplex=$AcftRow['Complex']; $AcftHP=$AcftRow['HighPerf']; $display .= "<option value=\"$AcftKey\"> $AcftAircraft </option>"; } $display .= " </select> </td> <td>Aircraft ID: <input type=\"text\" name=\"ID\" size=\"8\"></td> </tr> <tr> <td>From: <select name=\"From\"> <option selected=\"selected\" value=\"PVG\">PVG</option>"; $ArfldQuery="SELECT AirfieldID FROM Airfields ORDER BY AirfieldID"; $ArfldResult=mysqli_query($conn, $ArfldQuery) or die ("Airfield Query Failed"); While ($ArfldRow=mysqli_fetch_array($ArfldResult)) { $Arfld=$ArfldRow['AirfieldID']; $display .= "<option value=\"$Arfld\"> $Arfld </option>"; } $display .= " </select> </td> <td>To: <select name=\"To\"> <option selected=\"selected\" value=\"PVG\">PVG</option>"; $ArfldQuery="SELECT AirfieldID FROM Airfields ORDER BY AirfieldID"; $ArfldResult=mysqli_query($conn, $ArfldQuery) or die ("Airfield Query Failed"); While ($ArfldRow=mysqli_fetch_array($ArfldResult)) { $Arfld=$ArfldRow['AirfieldID']; $display .= "<option value=\"$Arfld\"> $Arfld </option>"; } $display .= " </select> </td> <td>Leg: <select name=\"Leg\"> <option value=\"1\">1</option> <option value=\"2\">2</option> <option value=\"3\">3</option> <option value=\"4\">4</option> <option value=\"5\">5</option> <option value=\"6\">6</option> </select> </td> </tr> </table><br> <strong>Flight Time Info:</strong> <table border=\"1\" width=\"520\"> <tr> <td>TPT: <input type=\"text\" name=\"TPT\" size=\"4\"></td> <td>PIC: <input type=\"text\" name=\"PIC\" size=\"4\"></td> <td>SIC: <input type=\"text\" name=\"SIC\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Solo: <input type=\"text\" name=\"Solo\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">Dual Received: <input type=\"text\" name=\"Dual\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Cross Country: <input type=\"text\" name=\"XC\" value=\"0.0\" size=\"4\"></td> <td><input type=\"checkbox\" name=\"FARXCntry\" size=\"4\">FAR X-Cntry</td> <td><input type=\"checkbox\" name=\"ATPXCntry\" size=\"4\">ATP X-Cntry</td> </tr> <tr> <td>Single Engine: <input type=\"text\" name=\"SE\" size=\"4\"></td> <td>Multiengine: <input type=\"text\" name=\"ME\" size=\"4\"></td> <td>Night: <input type=\"text\" name=\"NT\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Complex: <input type=\"text\" name=\"Complex\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">High Performance: <input type=\"text\" name=\"HP\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Instrument: <input type=\"text\" name=\"Inst\" value=\"0.0\" size=\"4\"></td> <td colspan=\"2\">Sim Instrument: <input type=\"text\" name=\"SimInst\" value=\"0.0\" size=\"4\"></td> </tr> <tr> <td>Instructor: <input type=\"text\" name=\"Instructor\" value=\"0.0\" size=\"4\"></td> <td>Pre-Post: <input type=\"text\" name=\"PrePost\" value=\"0.0\" size=\"4\"></td> <td>Ground: <input type=\"text\" name=\"Ground\" value=\"0.0\" size=\"4\"></td> </tr> </table><br> <strong>Actual Approaches:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Precision: <input type=\"text\" name=\"PrecAct\" value=\"0\" size=\"3\"></td> <td>Non-Precision: <input type=\"text\" name=\"NonPrecAct\" value=\"0\" size=\"3\"></td> </tr> </table><br> <strong>Simulated Approaches:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Precision: <input type=\"text\" name=\"PrecSim\" value=\"0\" size=\"3\"></td> <td>Non-Precision: <input type=\"text\" name=\"NonPrecSim\" value=\"0\" size=\"3\"></td> </tr> </table><br> <strong>Landings:</strong> <table border=\"1\" width=\"520\"> <tr> <td>Day Landings: <input type=\"text\" name=\"DayLdg\" size=\"3\"></td> <td>Night Landings: <input type=\"text\" name=\"NtLdg\" size=\"3\"></td> </tr> </table><br> <strong>Remarks:</strong><br> <textarea name=\"Remarks\" rows=\"5\" cols=\"70\"></textarea> <input type=\"hidden\" name=\"op\" value=\"add\"> <p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p> </FORM>"; } else if ($_POST[op] == "add") { if ($_POST[Sim] == "") { $_POST[Sim] = "0"; } else { $_POST[Sim] = "1"; } if ($_POST[FARXCntry] == "") { $_POST[FARXCntry] = "0"; } else { $_POST[FARXCntry] = "1"; } if ($_POST[ATPXCntry] == "") { $_POST[ATPXCntry] = "0"; } else { $_POST[ATPXCntry] = "1"; } // $add_flt = "INSERT INTO FlightData (Date, MakeModel, AircraftID, Simulator, SimType, AfldFrom, AfldTo, // Leg, TPT, PIC, SIC, Solo, Dual, Night, XCntry, SE, ME, Complex, HighPerf, Inst_Act, Inst_Sim, // Instructor, PrePost, Ground, Prec_Act, Prec_Sim, NonPrec_Act, NonPrec_Sim, DCL, NCL, // FAR_XCntry, ATP_XCntry, Remarks) // VALUES ('$_POST[FltDate]', '$_POST[Aircraft]', '$_POST[ID],$_POST[Sim]', '$_POST[SimType]', '$_POST[From]', // '$_POST[To]', '$_POST[Leg]', '$_POST[TPT]', '$_POST[PIC]', '$_POST[SIC]', '$_POST[Solo]', '$_POST[Dual]', // '$_POST[NT]', '$_POST[XC]', '$_POST[SE]', '$_POST[ME]', '$_POST[Complex]', '$_POST[HP]', '$_POST[Inst]', // '$_POST[SimInst]', '$_POST[Instructor]', '$_POST[PrePost]', '$_POST[Ground]', '$_POST[PrecAct]', // '$_POST[PrecSim]', '$_POST[NonPrecAct]', '$_POST[NonPreSim]', '$_POST[DayLdg]', '$_POST[NtLdg]', // '$_POST[FARXCntry]', '$_POST[ATPXCntry]', '$_POST[Remarks]')"; $add_flt = "INSERT INTO FlightData (Date, MakeModel) VALUES ('$_POST[FltDate]', '$_POST[Aircraft]')"; $result = mysqli_query($conn, $add_flt) or die('Error: '. mysqli_connect_error()); $display = "<h1>Entry Added</h1> <p>Your entry was added.</p><br> <p>$_POST[FltDate] | $Make </p>"; // $CnxSt = connection_status(); // $display .= "Connection Status: $CnxSt<br><br>"; // $display .= "$_POST[FltDate] / $_POST[Aircraft] / $_POST[ID] / $_POST[Sim] / $_POST[FARXCntry] / $_POST[ATPXCntry]"; } ?> <html> <head> <title>Add Logbook Entry></title> </head> <body> <?php echo $display; ?> </body> </html>
  8. Hi, I'm trying to let JavaScript check if a givin user exist in the database. It seems that the _check-user.php always returns 0, but if I fill in a name that doesn't exist, and echo out the result variable in JS, the echo will return 1. Is there someone who could help me? JavaScript part: function checkUser() { $.post("_check_user.php", { 'username': document.getElementById("username").value }, function(result) { if (result == 1) { document.getElementById("checkUser").className = "succes"; document.getElementById("checkUser").innerHTML = "Name is available"; }else{ document.getElementById("checkUser").className = "errormsg"; document.getElementById("checkUser").innerHTML = "Name is not available!"; } }); } _check-user.php: <?php include("config.php"); $result = mysql_query("SELECT login FROM users WHERE login='".clean_string($_POST["username"])."'"); if(mysql_num_rows($result)>0){ echo 0; }else{ echo 1; } ?>
  9. Hello! I am new to PHP programming and am currently working on an account system. I have posted my work so far. From what I understand the problem is that when I log in the php script doesn`t acknowledge it and acts as if noone is logged in. Thanks in advace! Here are my files: users.sql : CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(30) DEFAULT NULL, `password` varchar(255) DEFAULT NULL, `fullname` varchar(100) DEFAULT NULL, `location` varchar(200) DEFAULT NULL, `gender` varchar(10) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; auth_check.php common.php dashboard.php index.php login.php logout.php register.php auth_check.php
  10. help me... suppose some data is fetched from database using while(mysql_fetch_array(**) and i want that on click of each fetched data from database one div must be opened up ..please somebody tell me help please
  11. Dear Forum Members, I'm trying to create a snippet of PHP code which can select a specific number of rows from a Database table (Database "formulier", "tables under invoer"), and output this data into a .cvs file. The script: export.php This script will be running on a website, where after people click on a button and submit a client-specfic ID and Last Name, they get a .csv to download for administrative use. Needless to say, I want the script to generate a .csv file with all entries (different dates of entries, total 23 variables) of one ID-number from the database. I've started to work on this, and whilst it works for the larger part, I'm really stuck at the moment. I hope that some of you can shed some light on the issue. Attached are the scripts I'm currently running. formulier.htmlinsert.php Please note that they're definetly not final, and still insecure. That's not the issue right now. Kind regards,
  12. Hi guys, I had a question about how to do a safe query. For example, I've a query like SELECT * FROM users WHERE login='".$_GET["x"]."' Do I need to do more then just adding mysql_real_escape_string(), or is that one just enough? And how goes it for the INSERT, UPDATE, DELETE statement? And do you need to parse the output from a database before displaying it? Thanks in advance,
  13. I have been working on a php project which has a total no. tables of 124 and the total size of whole DB is `5GB. Now, we are re designing it in Codeigniter and reduced total tables to `40. Now, we were told to get the data of the old DB and to put it in the new one. Here are the situation, the old DB is massive and data is too scattered, in the new version we combined and organized well, so New version has different architecture and mapping. Any suggestions are heart-fully loved.
  14. I am trying to use the following code to get information from a WooCommerce Wordpress Order, then pass the details to a database. The code that is supposed to execute this action is as follows: //Pass udid to database add_action('woocommerce_payment_complete', 'send_to_db'); function send_to_db( $order_id ) { $order = new WC_Order( $order_id ); $udid = $order->customer_note; $email = $order->billing_email; $db_hostname = 'MYIP'; $db_database = 'MYDATABASE'; $db_username = 'MYUSER'; $db_password = 'MYPASSWORD'; // Connect to server. $link = mysqli_connect($db_hostname, $db_username, $db_password); if (!$link) { die('Not connected : ' . mysqli_error()); } // Select the database. $db_selected = mysqli_select_db($link, $db_database); if (!$db_selected) { die ('Can\'t use database : ' . mysqli_error()); } //find package type $items = $order->get_items(); foreach($items as $item) { $type = '1'; if(preg_match("/Basic/i", implode($item))) { $type = '0'; } } //put it into the db $query= "INSERT INTO udid_orders (udid, email, type) VALUES ('$udid','$email','$type')"; $sql = mysqli_query($link, $query); } mysqli_close($link); //end pass to db After this code is executed, it should fill the database then another piece of helper PHP will get the information from the database. However **I have two issues**. The first issue, is that I don't think I created the database properly. I can successfully connect, but after an order is placed, the information is not stored in the database. To create the database, I followed just did a simple `CREATE DATABASE menagerie;` and created the database. I assumed the table and rows would create themselves after this code was executed. Please correct me if I'm wrong. My second issue is when I run the following helper code: <?php $x = '1'; //include 'db.php'; $db_hostname = 'MYIP'; $db_database = 'MYDATABASE'; $db_username = 'MYUSERNAME'; $db_password = 'MYPASSWORD'; // Connect to server. $link = mysqli_connect($db_hostname, $db_username, $db_password); if (!$link) { die('Not connected : ' . mysqli_error()); } // Select the database. $db_selected = mysqli_select_db($link, $db_database); if (!$db_selected) { die ('Can\'t use database : ' . mysqli_error()); } //get udid from database while($x = '1'){ $query = "SELECT id, udid, email, premium FROM udid_orders ORDER BY timestamp DESC LIMIT 1"; $sql = mysqli_query($link, $query); if(mysqli_num_rows($sql) >= 1){ echo 'registering'; $row = mysqli_fetch_array($sql); $number = $row['id']; $udidsql = $row['udid']; $email = $row['email']; $is_premium = $row['premium']; $service_port = '622'; $address = 'MYIPHERE'; $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo 'Failed to create socket'; return; } $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo 'Failed to connect socket'; return; } $in = "weTi3xJEy7kbldDYWdXe"; $out = ''; socket_write($socket, $in, strlen($in)); while ($out = socket_read($socket, 1024)) { break; } //get us a random number for the name $request = 'OrderInfo '; //$random = rand(1, 2000); //name that nigga $name = $number; $request .= $name; $request .= " "; //$request .= $order->billing_email; $request .= $email; $request .= " "; //$is_premium = '1'; // if(preg_match("/Bronze/i", implode($item))) { // $is_premium = '0'; // } // $request .= $is_premium; //} $request .= $is_premium; $out = ''; socket_write($socket, $request, strlen($request)); while($out = socket_read($socket, 1024)) { break; } $udids = explode(',', $udidsql); foreach($udids as $udid){ $udid_request = "UdidRegister "; $udid = $udidsql; $udid_request .= $udid; $udid_status = ""; socket_write($socket, $udid_request, strlen($udid_request)); } socket_close($socket); $update = "UPDATE udid_orders SET status='1' WHERE udid='$udidsql'"; $sql_update = mysqli_query($link, $update); } else{ echo 'sleeping'; sleep(5); } } // close mysql mysqli_close($link); ?> I get the following error `PHP Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /link.php on line 25. I have no idea what is even means, let alone how to troubleshoot it. I am pretty new to both PHP and MySQL, so any pointers in the right direction would be really helpful.
  15. In my database I have a column which contain location of a file. The column contains entries like - scripts/testSuite/sdnSTC/Flare/Backup_Restore/Sprint16_tests/BackupHugeDatabase.tcl scripts/testSuite/sdnSTC/Flare/Backup_Restore/Standalone_backup/Backup_Restore_BackupRestoreApplications.tcl scripts/testSuite/networkSecurity/802dot1x/802dot1xConfiguration/802dot1xBasicUserMode.tcl scripts/testSuite/hostAgentFeatures/debugLogging/debugLoggingFeatureTesting/DebugLoggingIPv6Forwarding.tcl I want to query this database and check for the values like networkSecurity, hostAgentFeatures etc at the specified index 2. I tried using REGEXP and LIKE but it does not always returns the correct output. Also my DB doesn't support FULLTEXT indexes Is there a way to specify index in MySQL ? Please guide.
  16. Hi All, Currently building a Joomla component. Having an issue with data being duplicated when I click the save button. Instead of the item in the database being updated a new item is being created, has anyone faced this issue before? I am wondering if it might be to do with my database design. I have named the primary key as journal_id, but I see in the tutorial it is set just to id, is this a requirement for Joomla to function properly? Any help with this issue would be gratefully received. Andrew
  17. xampp 1.8.3-3 Mac OSX 10.9.1 Hello, I'm creating a form using html and php, which when run uploads information into a locally hosted xampp database. The issue; sometimes the table simply refuses the information - it doesn't show up in the database when sent and continues to do so and I cannot get it working again. I'm given no errors when the data is submitted so it must be connecting, the info just doesn't show up. Because of this I decided to start from the beginning again, creating a new database and table, and starting with one input (date) - it works. I add more and more fields and it continues to work... I add a couple of the dynamic name fields (see code below) and it continues to work. I get confident so add the rest of my fields - bam, it stops working. After it stops accepting data, I can't get it accepting again - even if I delete all fields so I just have "date". Am I hitting some limit somehow? I do apologise if the code is appalling - this isn't my day job! Any help anybody can give me will be greatly appreciated, and will stop me tearing my hair out! Many thanks Simon <? $username="xxxxxx"; $password="xxxxxx"; $database="Final"; $date=$_POST['date']; $group_name=$_POST['group_name']; $cruise=$_POST['cruise']; $no_adults=$_POST['no_adults']; $no_half=$_POST['no_half']; $no_free=$_POST['no_free']; $email=$_POST['email']; $phone=$_POST['phone']; $accommodation=$_POST['accommodation']; $payment=$_POST['payment']; $info=$_POST['info']; $name_adult=$_POST['name_adult']; $name_adult_2=$_POST['name_adult_2']; $name_adult_3=$_POST['name_adult_3']; $name_adult_4=$_POST['name_adult_4']; $name_adult_5=$_POST['name_adult_5']; $name_adult_6=$_POST['name_adult_6']; $name_adult_7=$_POST['name_adult_7']; $name_adult_8=$_POST['name_adult_8']; $name_adult_9=$_POST['name_adult_9']; $name_adult_10=$_POST['name_adult_10']; $name_adult_11=$_POST['name_adult_11']; $name_adult_12=$_POST['name_adult_12']; $name_adult_13=$_POST['name_adult_13']; $name_adult_14=$_POST['name_adult_14']; $name_adult_15=$_POST['name_adult_15']; $name_half=$_POST['name_half']; $name_half_2=$_POST['name_half_2']; $name_half_3=$_POST['name_half_3']; $name_half_4=$_POST['name_half_4']; $name_half_5=$_POST['name_half_5']; $name_half_6=$_POST['name_half_6']; $name_half_7=$_POST['name_half_7']; $name_half_8=$_POST['name_half_8']; $name_half_9=$_POST['name_half_9']; $name_half_10=$_POST['name_half_10']; $name_half_11=$_POST['name_half_11']; $name_half_12=$_POST['name_half_12']; $name_half_13=$_POST['name_half_13']; $name_half_14=$_POST['name_half_14']; $name_half_15=$_POST['name_half_15']; $name_free=$_POST['name_free']; $name_free_2=$_POST['name_free_2']; $name_free_3=$_POST['name_free_3']; $name_free_4=$_POST['name_free_4']; $name_free_5=$_POST['name_free_5']; $name_free_6=$_POST['name_free_6']; $name_free_7=$_POST['name_free_7']; $name_free_8=$_POST['name_free_8']; $name_free_9=$_POST['name_free_9']; $name_free_10=$_POST['name_free_10']; $name_free_11=$_POST['name_free_11']; $name_free_12=$_POST['name_free_12']; $name_free_13=$_POST['name_free_13']; $name_free_14=$_POST['name_free_14']; $name_free_15=$_POST['name_free_15']; $email_2=$_POST['email_2']; $email_3=$_POST['email_3']; $email_4=$_POST['email_4']; $phone_2=$_POST['phone_2']; $phone_3=$_POST['phone_3']; $phone_4=$_POST['phone_4']; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO final VALUES ('$date','$group_name','$cruise','$no_adults','$no_half','$no_free','$email','$phone','$accommodation','$payment','$info','$name_adult','$name_adult_2','$name_adult_3','$name_adult_4','$name_adult_5','$name_adult_6','$name_adult_7','$name_adult_8','$name_adult_9','$name_adult_10','$name_adult_11','$name_adult_12','$name_adult_13','$name_adult_14','$name_adult_15','$name_half','$name_half_2','$name_half_3','$name_half_4','$name_half_5','$name_half_6','$name_half_7','$name_half_8','$name_half_9','$name_half_10','$name_half_12','$name_half_13','$name_half_14','$name_half_15','$name_free','$name_free_2','$name_free_3','$name_free_4','$name_free_5','$name_free_6','$name_free_7','$name_free_8','$name_free_9','$name_free_10','$name_free_11','$name_free_12','$name_free_13','$name_free_14','$name_free_15','$email_2','$email_3','$email_4','$phone_2','$phone_3','$phone_4')"; mysql_query($query); mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="robots" content="noindex" /> <title>Guest Entry Form - Friendship Rose</title> <script language="JavaScript"> function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox if(key == 13) return false; else return true; } </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(function() { var addDiv = $('#addinputadult'); var i = $('#addinputadult p').size() + 1; $('#addNewadult').live('click', function() { $('<p><input type="text" id="adult_' + i +'" value="" size="40" name="name_adult_' + i +'" value="" placeholder="Full Name (Adult)" /><a href="#adult" id="remname_adult">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remname_adult').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <script type="text/javascript"> $(function() { var addDiv = $('#addinputhalf'); var i = $('#addinputhalf p').size() + 1; $('#addNewhalf').live('click', function() { $('<p><input type="text" id="name_half_' + i +'" value="" size="40" name="name_half_' + i +'" value="" placeholder="Full Name (Half)" /><a href="#half" id="remname_half">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remname_half').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <script type="text/javascript"> $(function() { var addDiv = $('#addinputfree'); var i = $('#addinputfree p').size() + 1; $('#addNewfree').live('click', function() { $('<p><input type="text" id="name_free_' + i +'" value="" size="40" name="name_free_' + i +'" value="" placeholder="Full Name (Free)" /><a href="#free" id="remname_free">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remname_free').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <script type="text/javascript"> $(function() { var addDiv = $('#addinputemail'); var i = $('#addinputemail p').size() + 1; $('#addNewemail').live('click', function() { $('<p><input type="text" id="email_' + i +'" value="" size="40" name="email_' + i +'" value="" placeholder="Contact Email" /><a href="#email" id="remNewemail">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#rememail').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <script type="text/javascript"> $(function() { var addDiv = $('#addinputphone'); var i = $('#addinputphone p').size() + 1; $('#addNewphone').live('click', function() { $('<p><input type="text" id="phone_' + i +'" value="" size="40" name="phone_' + i +'" value="" placeholder="Phone Number" /><a href="#phone" id="remNewphone">Remove</a> </p>').appendTo(addDiv); i++; return false; }); $('#remphone').live('click', function() { if( i > 2 ) { $(this).parents('p').remove(); i--; } return false; }); }); </script> <link href="guest_form.css" rel="stylesheet" type="text/css" /> </head>[/color][/color] <body> <h1 style="padding-left:30px"> Friendship Rose Guest Info </h1> <p style="padding-left:30px"> <b>Note:</b> The Tab Button scrolls through the form fields (mouse click can also be used), the return key creates a new line for text in the text fields </hp> <p> </p> <div class="form" style="float:left; padding:0 0 30px 30px"> <form name="guest_form" action="guest_form.php" method="post" style="float:left"> Cruise Date: dd/mm/yy (IMPORTANT) <br /> <input type="date" name="date" size="30" onKeyPress="return disableEnterKey(event)" /><br /><br /> Cruise <br /> <input type="radio" name="cruise" value="tobagocays">Tobago Cays<br> <input type="radio" name="cruise" value="mustique">Mustique<br /> <input type="radio" name="cruise" value="mayreau">Mayreau<br> <input type="radio" name="cruise" value="st_vincent">St Vincent<br /> <input type="radio" name="cruise" value="bequia">Bequia<br> <p> </p> Group Name / Identification (Surname) <input type="text" id="group_name" size="40" name="group_name" value="" placeholder="Group Name" onKeyPress="return disableEnterKey(event)" /> <p> </p> Number of Adults:<br /> <input type="number" name="no_adults" min="1" onKeyPress="return disableEnterKey(event)" /> <br /><br /> Number of Kids - Half Price: (Use 0 for none)<br /> <input type="number" name="no_half" min="0" onKeyPress="return disableEnterKey(event)" /> <br /><br /> Number of Kids - Free: (Use 0 for none)<br /> <input type="number" name="no_free" min="0" onKeyPress="return disableEnterKey(event)" /> <p> </p> Names of Adults: <div id="addinputadult" style="line-height:0px"> <p> <a href="#adult" id="addNewadult">Add</a><br /> <input type="text" id="name_adult" size="40" name="name_adult" value="" placeholder="Full Name (Adult)" /> </p> </div> Names of Kids - Half: <div id="addinputhalf" style="line-height:0px"> <p> <a href="#half" id="addNewhalf">Add</a><br /> <input type="text" id="name_half" size="40" name="name_half" value="" placeholder="Full Name (Half)" /> </p> </div> Names of Kids - Free: <div id="addinputfree" style="line-height:0px"> <p> <a href="#free" id="addNewfree">Add</a><br /> <input type="text" id="name_free" size="40" name="name_free" value="" placeholder="Full Name (Free)" /> </p> </div> <p> </p> Contact Email/s: <div id="addinputemail" style="line-height:0px"> <p> <a href="#email" id="addNewemail">Add</a><br /> <input type="email" id="email" size="40" name="email" value="" placeholder="Contact Email" /> </p> </div> Contact Phone Number/s: <div id="addinputphone" style="line-height:0px"> <p> <a href="#phone" id="addNewphone">Add</a><br /> <input type="number" id="phone" size="40" name="phone" value="" placeholder="Phone Number" /> </p> </div> <p> </p> Accommodation: <br /> <textarea name="accommodation" rows="5" cols="60" input type="text"></textarea> <p> </p> Payment Status: <br /> <textarea name="payment" rows="2" cols="40" input type="text"></textarea> <p> </p> Extra Info / Dietry Requirements: <br /> <textarea name="info" rows="10" cols="60" input type="text"></textarea> <br /> <p> </p> <input type="Submit" value="Submit" /> </form> </div> </body> </html>
  18. Hi all, im having a problem with deleting users from a student database, the database adds new students fine, the problem is deleting a student from the system. Each student has a button beside the student name labeled "Delete Student Number: (student number here)", but for some reason the code is just always deleting the last entry from the database and not the student for which the button beside their name is pressed... Any ideas? Thanks! <?php echo "<h1>Student Database</h1>"; require_once('output_functions.php'); function is_initial_request() { return ! isset($_POST['submit']); } function output_form() { echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">"; output_textfield('username', 'New Student: ', 'username', 30, 30, '', false); output_submit_button('Add Student'); echo "</form>"; } // Try to connect to database $dbconnection = mysqli_connect( "localhost", "bfm3", "eeshaica", "2017_bfm3" ); if ( ! $dbconnection ) { die('Unable to connect to database'); } // Code to allow the user to enter a new Student if ( ! is_initial_request() ) { $username = $_POST['username']; // Insert into the database $insert_sql = "INSERT INTO students ( username ) VALUES ('{$username}');"; $dbinsert_result = mysqli_query( $dbconnection, $insert_sql ); if ( ! $dbinsert_result ) { die(); } } // Code to allow the user to delete a new Student if ( isset($_POST['delete_row']) ) { $id = $_POST['deleteStudent']; $delete_sql = "DELETE FROM students WHERE id = {$id}"; $dbdelete_result = mysqli_query( $dbconnection, $delete_sql ); } $retrieve_sql = "SELECT * FROM students"; $dbretrieve_result = mysqli_query( $dbconnection, $retrieve_sql ); if ( ! $dbretrieve_result ) { die(); } if ( mysqli_num_rows( $dbretrieve_result ) != 0 ) { while ( $row = mysqli_fetch_assoc( $dbretrieve_result ) ) { echo $row['id']; echo "<table>"; echo "<form action=\"{$_SERVER['PHP_SELF']}\" name=\"delete_student\" method=\"POST\">"; echo "<tr><td><p><input type=\"submit\" name=\"delete_row\" value=\"Delete Student Number: {$row['id']}\" /></p></td><td><b>Student ID NO.</b> {$row['id']}</td></tr>"; echo "<input type=\"hidden\" name=\"deleteStudent\" value=\"{$row['id']}\">"; echo "<tr><td></td><td><b>Student Name:</b> {$row['username']}</td></tr>"; echo "</table>"; echo "<br>"; } } output_form(); // Free up memory and close the database connection mysqli_free_result( $dbretrieve_result ); mysqli_close( $dbconnection ); ?>
  19. $create_table = "SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `" .$date."`; CREATE TABLE `".$date."` ( `transaction_id` varchar(11) NOT NULL, `name` varchar(255) character set latin1 default NULL, `price` varchar(255) character set latin1 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $run_query = mysql_query($create_table); Ok so i am some what confused as to why my table is not being created with this. When I insert the query directly into SQL the table is created with no error or issue. So i know the statement is true and syntax is not an issue. When i create the variable in PHP with the same query, then try to run the query, the same table is then not created in the DB. Am i missing a step ? usually this is pretty straight forward when working with DB. I would usually grab the data then fetch the array, then extract the data into a set of variables. Any suggestions ?
  20. I am refactoring a huge legacy codebase. This codebase has SQL code everywhere. i.e. if any function needs some data from a database, it just calls the SQL right there and uses it. If I started from scratch I'd consider using Doctrine, or maybe some kind of an active record. But ... I basically want to refactor, and I am kind of lost ... What can I do with the SQL DB calls to refactor the code to a better more maintainable state? I mean what is the best practice today when it comes to using Databases in your code?
  21. Hi can i find out if it is possible to retrieve rows from my tables in the database but display them as hyperlinks which can lead to a page (can it be just 1 page that allows values to be inserted into?) that allows charts (using highcharts) or so to be created based on the values passed from the database? Sorry if this is a stupid question. I'm new to this and I'm exploring ways to present my data. Thanks!
  22. I am a PHP beginner. Every x days (every 7 days for example), I would like all the values in a certain column in my MySQL database to reset back to '1'. How do I do this? Please note: My web host does NOT have the MySQL event scheduler enabled so that is not an option. Also, my web hosting plan does not allow me to do cronjobs so that is not option either. Any other ideas? Thanks!
  23. Hi there, newbie to this forum and newbie to PHP (infact I only started "attempting" to use it today) I have a contact form on https://scm-intranet.tees.ac.uk/users/l1071039/bobbin/order.html And I have a table set up on MySQL named "orderform" According to my order.html, the form data should be posted to order.php (code can be seen below) <?php $product = $_POST['product']; $productcomments = $_POST['productcomments']; $name = $_POST['name']; $address = $_POST['address']; $age = $_POST['age']; $delivery = $_POST['delivery']; ?> <?php $host=”mysql.scm.tees.ac.uk”; $user_name=”l1071039”; $pwd=”+i^RR9b7”; $database_name=”l1071039”; $db=mysql_connect($host, $user_name, $pwd); if (mysql_error() > “”) print mysql_error() . “<br>”; mysql_select_db($database_name, $db); if (mysql_error() > “”) print mysql_error() . “<br>”; ?> <?php $query = “insert into orderform (product, productcomments, name, address, age, delivery) values (‘” . $product . “‘, ” . $productcomments . “, ‘” . $name . “‘, ‘” . $address . “. $age . “. $delivery . “‘)”; $qresult = mysql_query($query); ?> However when I fill the form in I get a snippet of code? How do I get it so when the submit button is clicked, it returns to the Home Page, and how can I view the data that was inputted? Many Thanks in advance
  24. I have a website that runs on a hosted server with iis6 and php5.2.5 installed the website is written in asp3.0 (sorry) and fetches its data from an ms access database (again sorry). The database is stored on the physical path: D:\databases\database.mdb and there is no use of username/password. I want to create PDF files on the fly using FPDF so a database connection in php is the challenge, I've tried loads of examples from the web but unsuccesful so far. My phpinfo: http://www.freebits.nl/images/211screen1.jpg http://www.freebits.nl/images/424screen2.jpg Thanks in advance for the effort Paul
  25. Trying to find a way to combine two scripts. 1. picture upload script that uploads the picture, gives it a new unique name, saves it to a specified directory and saves the unique name path to a user database (basically a user profile picture upload). and 2. A larger user login script I already have worked into my website that allows users to register on the site, view and edit their profile, log in, log out, etc. The issue is in part that I don't understand PHP well enough to figure out how to work these in together and the other part is that they are written a bit differently from each other so it's making it hard to combine them. One of the user profile fields I am using with script 2 is valued "bpic" and is where path to the uploaded picture would go. I have been successful in getting the unique path to save in that field in the database but absolutely can NOT seem to get the picture to actually upload and save in the "avatars" directory no matter what I try. I have determined that because my user script already calls the database, has an "INSERT INTO" database command and has error and success messages, I could take out those aspects of the picture uploading code below so I'm just trying to figure out where to place the "$new_image_name =" and "$bpic = " lines and how and where to code in the "move_uploaded_file" portion so the file actually uploads lol. (These are the two portions of the script below that I have decided I need to use and find a place to paste): $new_image_name = md5( rand (0, 1000) . rand (0, 1000) . rand (0, 1000) . rand (0, 1000) ) .'.jpg'; $bpic = 'avatars/' . $new_image_name; if(move_uploaded_file($_FILES['bpic']['tmp_name'], $bpic)) { } Any help and direction is appreciated! I have been at this for weeks with no success. It took me a while to actually get the picture upload script to work on it's own and upload the file, give it a unique name and save that unique name in both the directory and database so it can be found and displayed correctly. But anyway, the upload picture script works perfect now on it's own, but I gotta figure out how to place it in the script I already have. Upload Picture Script: (note: "bpic" is the field name of the file upload on the form and "$bpic" both references the field in the database and the file path to be created for the pic.) <?php //This is the directory where images will be saved $new_image_name = md5( rand (0, 1000) . rand (0, 1000) . rand (0, 1000) . rand (0, 1000) ) .'.jpg'; $bpic = 'avatars/' . $new_image_name; // Connects to your Database mysql_connect("businessdb1.db.9878324.hostedresource.com", "businessdb1", "Spidey148!") or die(mysql_error()) ; mysql_select_db("businessdb1") or die(mysql_error()) ; //Writes the photo to the server if(move_uploaded_file($_FILES['bpic']['tmp_name'], $bpic)) { //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$bpic')") ; //Tells you if its all ok echo "The file has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> As far as the user upload script goes, I'm not sure which page to work this code into so I don't want to make this post insanely long by posting every potential page (database.php - which I think is it, process.php, session.php, constants.php). The exact same code I am using is downloadable for free here: http://blog.geotitles.com/2011/07/php-login-script/ so you can see exactly how my code is formatted. I understand that's a lot of information and actually quite a bit of work for someone to look at and offer help, but if anyone is up to it, I would really appreciate any advice and help with this as I have been pulling out my hair trying to figure this out and it's going to completing a website that a lot of bands are waiting to sign up for! Thanks so much for your time! -David.
×
×
  • 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.