[Solved] How to print info from mysql db [closed]

If I understand your question correctly you could try something like the following. Edit: taken into account you already have a connection in config.php In config.php make sure you have the following. <?php $con=mysqli_connect(“hostname”,”username”,”password”,”database”); if (mysqli_connect_errno()) { echo “Failed to connect to MySQL: ” . mysqli_connect_error(); } ?> And then on the page where you … Read more

[Solved] Use Php dropdown values to select mysql tables

This worked the magic for me. <?php $dbLink = mysqli_connect(‘localhost’, ‘usr’, ‘passd’); mysqli_select_db(‘edudata’, $dbLink); $mytableselect=$_POST[‘mytableselect’]; $sql = “SELECT * FROM $mytableselect”; $result = mysqli_query($sql) or die(mysqli_error()); // Print the column names as the headers of a table echo “<table><tr>”; for($i = 0; $i < mysqli_num_fields($result); $i++) { $field_info = mysqli_fetch_field($result, $i); echo “<th>{$field_info->name}</th>”; } // … Read more

[Solved] MySQL SELECT and ORDER BY [closed]

Consider the following data set… DROP TABLE IF EXISTS results; CREATE TABLE results (id_competitor INT NOT NULL ,score INT NOT NULL ,id_route INT NOT NULL ,PRIMARY KEY(id_competitor,id_route) ); INSERT INTO results VALUES (1,100,2), (2,100,2), (3,60,2), (4 ,60,2), (1,70,1), (2,80,1), (3,70,1), (4,100,1); SELECT * FROM results; +—————+——-+———-+ | id_competitor | score | id_route | +—————+——-+———-+ | … Read more

[Solved] Order by DESC not working for custom variable $how

You currently have a function that defaults to showing 15 rows sorted by added. You can change this one of two ways: Change the function itself. This will make the DEFAULT value be site_views: function list_videos($how = ‘site_views’, $limit=”15″) { // newest, top views, etc etc etc Now if you call list_videos(), you will get … Read more

[Solved] How do I import info from a database to my website? [closed]

$query = “SELECT * FROM ‘users’”; <?php $servername = “localhost”; $username = “username”; $password = “password”; $dbname = “myDB”; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die(“Connection failed: ” . $conn->connect_error); } $sql = “SELECT * FROM users”; $result = $conn->query($sql); if ($result->num_rows > 0) { … Read more

[Solved] Connect to Database and Insert data – Php & MySQL –

Try die() like following in your php file: $connection = mysqli_connect($host,$user,$password,$database); /* check connection */ if (mysqli_connect_errno()) { die(“Connect failed: “, mysqli_connect_error()); } $query=”insert into users(firstname, lastname)VALUES(‘”.$_REQUEST[‘nome’].”‘,'”.$_REQUEST[‘cognome’].”‘)”; if ($result = mysqli_query($connection ,$query)) { print(“Success!”); } 3 solved Connect to Database and Insert data – Php & MySQL –

[Solved] One Update query for all updates [closed]

UPDATE table1 a CROSS JOIN lookup b SET a.ADRES = REPLACE(a.ADRES, b.`WRONG`, b.`RIGHT`), gender=”$sex”, dob = ‘$dob’, reg_date=”$reg_date” WHERE a.ADRES LIKE CONCAT(‘%’, b.`WRONG`, ‘%’) OR id = ‘$id’ the query is vulnerable with SQL Injection, please see the article below to lear how to protect from it, How can I prevent SQL injection in PHP? … Read more

[Solved] Access denied with localhost [closed]

open “config.inc.php” on your PMA folder. add this line to prompt the authentication before login $cfg[‘Servers’][$i][‘auth_type’] = ‘cookie’; /* $cfg[‘Servers’][$i][‘user’] = ‘root’; */ /* $cfg[‘Servers’][$i][‘password’] = ”; */ OR manually define your authentication by this line $cfg[‘Servers’][$i][‘auth_type’] = ‘config’; $cfg[‘Servers’][$i][‘user’] = ‘root’; $cfg[‘Servers’][$i][‘password’] = ‘yourpassword’; solved Access denied with localhost [closed]