Jump to content

bobicles2

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by bobicles2

  1. Select * FROM "Patient" INNER JOIN "GP" ON Patient.GP_Name = GP.GP_Name ORDER BY Patient.Name My Tables are Patient ( "N.I.Number" character varying(100) NOT NULL, "Name" character varying(100) NOT NULL, "Address" character varying(200) NOT NULL, "GP_Name" character varying(100) NOT NULL, GP "ID" serial NOT NULL, "GP_Name" character varying(100), "Practice" character varying(100), CONSTRAINT "GP_pkey" PRIMARY KEY ("ID") Want to create a query that produces an alphabetic list of all patients for a GP been stuck for hours now thanks
  2. This is my table Admissions - ID , Patient_Name, Institute_Name, Ward, Surgeon, Date im trying to find out which patients have been admitted to the same ward more than once....so Patient_Name and Ward need to both occur more than once and display. i think i need to use COUNT and HAVING but really unsure of how to tackle this Query Thanks Rob
  3. Eerm...the report its for says "The implementation should include appropriate use of the advanced features of PostgreSQL" But ive just implemented the tables using phpmyadmin? so im not 100% of the differences? perhaps this could be something i may need to learn more about?
  4. Thes are my Tables Patient - ID, Name, Address, GP GP - ID, Name, Hospital Specialisation Looking to produce a query that selects all the Patients for a particular GP, im not sure how to Query Multiple tables Thanks Rob
  5. i enjoy it as much as its humanly possible to enjoy a programming language haha! i think i enjoy it because i understand it! at university ive had to learn things like haskell/prolog/java and i could never properly get my head around them whereas with php i have.
  6. function clean($input) { $input = @trim($input); if(get_magic_quotes_gpc()) { $input = stripslashes($input); } return mysql_real_escape_string($input); } i orginally had this function, shown above to clean up my inputs and prevent SQL injection. However, Magic_quotes_gpc is no longer supported. and this method although clear to me seems a little long winded! is there an easier way for me to clean up my inputs thoroughly? and to avoid SQL injection thanks rob
  7. Regular users may have noticed over the past couple of months i have consistently been posting in this particular forum looking for PHP help, and as expected you guys have continued to give me fantastic support and help me through doing my final year project! My project and documentation is now complete and my understanding of PHP has improved ten fold! on top if this im not actually starting to enjoy PHP since i am getting an understanding for it To the point ; i would like to say a massive thank you to the users here, if it wasn't for your help i wouldn't of gotten to where i am and i thank you all for continually taking the time to help me, and others like me! some of us want to learn but don't know where to begin! and your help i know is appreciated by not only myself but obviously a lot of other posters here THANK YOU!
  8. Actually, it's saying if the variable does not NOT contain any text, then perform the code. It's essentially the same as if( !empty($login) ) now it makes perfect sense, so long as the field has an entry, we check the database for multiple entries thanks man!
  9. How would this have any reference to this script though, because if the login field which is defined as $login has no text, then it has nothing to look up in the database and compare against (as the script below is designed to checked for duplicate log in names) if($login != '') { $qry = "SELECT * FROM members WHERE login='$login'"; $result = mysql_query($qry); if($result) { if(mysql_num_rows($result) > 0) { $errmsg_arr[] = 'Login ID already in use'; $errflag = true; } @mysql_free_result($result); } else { die("Query failed"); }
  10. if($login != '') what is this saying? its the last part im unsure about thanks in advance rob
  11. slightly confused, so your revised version should work fine?
  12. The code below after Inserting into my table echos either "error:" or "Thank you.." where have i gone wrong here? the intention was to echo an error if there was one...otherwise if it works fine and adds to the table echo "Thanks etc" $sql="INSERT INTO Events (Event, Genre, Date, Price, Venue, Tickets, Postcode) VALUES ('$event','$genre','$date','$price','$venue','$tickets','$postcode')"; $result = mysql_query($sql, $con); if ($result) { echo "Error :" . mysql_error(); } else { echo "Thank You, Your Event has now been added to our Records"; } mysql_close($con);
  13. sorry i meant it to mean it doesnt work... but when i used Select * From Events it works fine.. so theres a problem with the query ive solved this now though using a different method..i have a field for ID which is set to auto increment so just changed it to display the 10 highest ID's (which are obviously the most recently added events) thanks for the help though much appreciated!
  14. mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM Events ORDER BY timestamp DESC LIMIT 10"; $result=mysql_query($query); $num=mysql_numrows($result); i use this, and it works and echo's everything fine when i used the query SELECT * FROM Events but doesnt work with the new query despite me having a timestamp field in my database having the default as timestamp i checked my databse and when i add an entry the timestamp is added so im not sure whats going wrong
  15. just adding the field now, does it need any particular variables, or will it be added naturally ive set the field type to TIMESTAMP
  16. Is this possible? im looking to display the top 10 most recently added items to my table on the homepage any ideas? thanks
  17. Unless you are a girl, no thanks. A "thank you" will suffice. What is the error? if ($result) { echo "Error :" . mysql_error(); it echo's "Error :" so i presume its mysql_error but i dont know much about that
  18. Gone over it and it all works however, sometimes when i click submit it comes up error: then i hit back and hit submit again and it works? why the loss in data anyone know?
  19. I honestly could kiss you, the genre still doesnt insert but the date works fine (i think theres a problem in my form which is why genre isnt inserting will take a look now, thank you thank you thank you thank you you sir are a legend @@@@@@@@@@@@@@@@@
  20. Fantastic, ive been wondering how to use the real_escape_string properly for ages unfortunatly tho when i fill out the form and hit submit i get this error Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'teamrend'@'localhost' (using password: NO) in /home/teamrend/public_html/insert.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/teamrend/public_html/insert.php on line 4 i get both of these errors for lines 4-8 which are where $event-$genre are defined
  21. i have a HTML form to register users to my website, when i fill the form out however, the username and email are not send to the database...although the password is...below is the php code and ive enclosed the form as well as a screenshot of my database incase thats the problem, where am i going wrong! php is cracking my brains thanks rob <?php $con = mysql_connect("localhost","?????","??????"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teamrend_rwowen", $con); $sql="INSERT INTO Members (Username, Password, Email) VALUES ('$_POST[username]','$_POST[Password]','$_POST[Email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank You, You are now a registered user"; mysql_close($con) ?> <form name="form2" method="post" action="registerphp.php"> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> <tr> <td colspan="3"><p align="center"><strong>Please Register </strong></p> <p> </p></td> </tr> <tr> <td width="78">Username </td> <td width="6">:</td> <td width="294"><input type="text" name="Username" id="Username"/></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type="text" name="Password" id="Password" /></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input type="text" name="Email" id="Email" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table></td> </form> Here is my database set up[, and below is a screenshot of my attemps to register. the ID auto increments as normal, the username and email stays blank but for some reason password goes in just fine
  22. I have a drop down menu shown below as you can see it has multiple fields which i want to add to the same entry into my database (as one complete date) this was my attempt $date = $_POST['Year'] . '-' . $_POST['Month'] . '-' . $_POST['Day']; $sql="INSERT INTO Events (Event, Genre, Date, Price, Venue, Tickets) VALUES ('$_POST['Event']','$_POST['Genre']','$date','$_POST['Price']','$_POST['Venue']','$_POST['Tickets']')"; Unfortunatly this doesnt work and gives me this error ; Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/teamrend/public_html/insert.php on line 23 The Full code is posted below thanks in advance for any help!im really struggling to find a way past this here is my html form <form name="form2" method="post" action="insert.php"> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> <tr> <td colspan="3"><p align="center"><strong>Add Event </strong></p> <p> </p></td> </tr> <tr> <td width="59">Event</td> <td width="4">:</td> <td width="239"><input type="text" name="Event" /></td> </tr> <tr> <td>Genre</td> <td>:</td> <td><select name="genre" id="genre"> <option selected="selected" value="none">Genre</option> <option value="Rock">Rock</option> <option value="Pop">Pop</option> <option value="Indie">Indie</option> <option value="Electro">Electro</option> </select> </td> </tr> <tr> <td>Date</td> <td>:</td> <td> <select name="Year"> <option selected="selected">Year</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> <option value="2021">2021</option> <option value="2022">2022</option> <option value="2023">2023</option> <option value="2024">2024</option> <option value="2025">2025</option> <option value="2026">2026</option> <option value="2027">2027</option> <option value="2028">2028</option> <option value="2029">2029</option> <option value="2030">2030</option> </select> <select name="Month"> <option selected="selected">Month</option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <select name="Day"> <option selected="selected">Day</option> <option value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> </td> </tr> <tr> <td>Price</td> <td>:</td> <td><input type="text" name="Price" /></td> </tr> <tr> <td>Tickets</td> <td>:</td> <td><input type="text" name="Tickets" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table></td> </form> and this is insert.php <?php $date = $_POST['Year'] . '-' . $_POST['Month'] . '-' . $_POST['Day']; $con = mysql_connect("localhost","teamrend_rwowen","291Aug89"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teamrend_rwowen", $con); $date = $_POST['Year'] . '-' . $_POST['Month'] . '-' . $_POST['Day']; $sql="INSERT INTO Events (Event, Genre, Date, Price, Venue, Tickets) VALUES ('$_POST['Event']','$_POST['Genre']','$date','$_POST['Price']','$_POST['Venue']','$_POST['Tickets']')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank You, Your Event has now been added to our Records"; mysql_close($con) ?>
  23. i have a HTML form to register users to my website, when i fill the form out however, the username and email are not send to the database...although the password is...below is the php code and ive enclosed the form as well as a screenshot of my database incase thats the problem, where am i going wrong! php is cracking my brains thanks rob <?php $con = mysql_connect("localhost","?????","??????"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teamrend_rwowen", $con); $sql="INSERT INTO Members (Username, Password, Email) VALUES ('$_POST[username]','$_POST[Password]','$_POST[Email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank You, You are now a registered user"; mysql_close($con) ?> <form name="form2" method="post" action="registerphp.php"> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> <tr> <td colspan="3"><p align="center"><strong>Please Register </strong></p> <p> </p></td> </tr> <tr> <td width="78">Username </td> <td width="6">:</td> <td width="294"><input type="text" name="Username" id="Username"/></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type="text" name="Password" id="Password" /></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input type="text" name="Email" id="Email" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table></td> </form> Here is my database set up[, and below is a screenshot of my attemps to register. the ID auto increments as normal, the username and email stays blank but for some reason password goes in just fine
  24. thanks a lot, how do i pre-load the images?
  25. $date = $_POST['Year'] . '-' . $_POST['Month'] . '-' . $_POST['Day']; $sql="INSERT INTO Events (Event, Genre, Date, Price, Venue, Tickets) VALUES ({$_POST['Event']},{$_POST['Genre']},{$date},{$_POST['Price']},{$_POST['Venue']},{$_POST['Tickets']})"; i changed it to that and got this error Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2027-03-22,30,,www.ticketmaster.com)' at line 3 i know i need to look at adding the real escape string but im not entirely sure what to do with it (being a php novice) so i want to get everything working first then do some reason and edit that into it, any idea where this is going wrong?
×
×
  • 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.