Note that there are some explanatory texts on larger screens.

plurals
  1. POGreater understanding of PHP and SQL
    primarykey
    data
    text
    <p>I have used to use PHP and MySQL a lot "back in the day" to create all kinds of websites including text-based games.</p> <p>Back when I was creating these project I was using such code as:</p> <pre><code>$query = 'SELECT user FROM users WHERE user_id = 1'; $result = mysql_query($query); </code></pre> <p>To get results from the database. I realise that this is a very bad way to be doing it, my questions is what is the best way to now do SELECT, UPDATE, DELETE etc. As these will be used all over the website should I be making functions in one file and so on. I would like to know the "best/safest" way to do about doing this. I understand having SQL statements on one line is bad as they are open to SQL injections, I would like to know what this means exactly and how to get around this problem safely.</p> <p>Its mainly handling the database that I seem to not understand. As I have not been paying attention to PHP for a few years now I see many things have moved on from when I had created my projects. </p> <p>I have looked around the net and have found W3Schools to be a useful resource but I would like to hear it from people that are using this everyday to find out how I should be doing things. </p> <p>Overall, how do I go about safely connecting a database and how can I grab data form the database safely for the whole website to use.</p> <p>This includes:</p> <ul> <li>Connecting a database</li> <li>Getting database from the database</li> <li>Echo the data from the database onto a page</li> </ul> <p>And anything else that you can think of to help me understand how to structure a "safe" website.</p> <p>Thanks to anyone that replies to this/these questions, I will be very active in comments for this asking more questions about things I do not full understand. </p> <p>Side Note: this website will be created using HTML, JavaScript, PHP and using a MYSQL database. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload