Jump to content

Chessica

New Members
  • Posts

    3
  • Joined

  • Last visited

Chessica's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi again! First of all, I need help understanding what's wrong. I'm using a uniformserver, and some features maybe won't work, but I'm nos interested in make a installation of apache+php+mysqyl while I'm pending for the final hosting. I have added the example code in my php webpage and still doesn't work. No errors are shown. I have put a screencapture, I hope you like colours... Top left: Validation message when you connect ok to DB (Bienvenido cliente!). The rest: HTML plain code. If I use the next sentece before my DB connection procedure, the webpage stops working... It get stuck ("esta pagina no funciona....). mysqli_report(mysqli_report_error | mysqli_report_strict); Otherwise, nothing from my query is returned... as I stated in my first post. If I use my query with (') instead of (""), it stops to work too: Here, the modified php+html code. Any help about it with explanation will be good. <?php session_start(); // Change this to your connection info. $DATABASE_HOST = 'localhost'; $DATABASE_USER = 'myuser'; $DATABASE_PASS = 'mypassword'; $DATABASE_NAME = 'mydb'; // Try and connect using the info above. //mysqli_report(mysqli_report_error | mysqli_report_strict); $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME); if (mysqli_connect_errno()){ // If there is an error with the connection, stop the script and display the error. //Doesn't work, why is the server unable to process it? echo('Failed to connect to MySQL: ' . mysqli_connect_errno()); $con->close(); session_destroy(); exit(); } else{ session_regenerate_id(); $_SESSION['loggedin'] = TRUE; $_SESSION['name'] = $DATABASE_USER; $_SESSION['id'] = $id; echo 'Bienvenido ' . $_SESSION['name'] . '!'; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Listas</title> <link href="./CSS/basic_style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="titulo"> <h1>Cursillos disponibles</h1> </div> <div class="content"> <form action="comprar.php" name="comprar" method="post"> <table name="contents" width="100%"> <tr> <th>Título</th> <th>Subtítulo</th> <th>Descripción</th> <th>Importe (€)</th> <th>Adquirir</th> </tr> <?php //$resultado = $con->excute_query("SELECT * FROM cursillo where cursillo.activo='0'", MYSQLI_USE_RESULT); $query="SELECT * FROM cursillo where cursillo.activo='0'"; $resultado = $con->excute_query($query, ['DEU']); foreach ($resultado as $fila) { echo $fila[1]; ?> </td> <td> <?php echo $fila[2]; ?> </td> <td> <?php echo $fila[3]; ?> </td> <td> <?php echo $fila[4]; ?> </td> <td> <input type="submit" name="pagar" value="<?php $fila[0] ?>"> </td> </tr> <?php } mysql_free_result($resultado); $con->close(); ?> </table> </form> </div> </body> </html>
  2. Hello. Can you explain me how I should use mysqli::execute_query in my case instead of only tell me that is wrong used, please? As I tell you in my initial post, no errors are shown, and this is why I have no clue of what's happening or what I'm doing wrong. How I can fix it? I'm running a uniformserver (last version), so any useful help will be apreciated. I can only see the HTML and the welcome user message displayed when I connect to DB. No data is returned. Do you want a screen? Thanks.
  3. Hello!!! Well, here I am, 10 years after my last php script, trying to execute a simple SQL query in a DB... and I'm not able to know why it doesn't work. I'm very conscious that there are lots of errors, but I will be glad if you can tell me them and make a bit of explanation to understand them. Lots of years without upgrading my knowledge and I'm very lost. As you can see, it's a single web that try to do the following: Session is active when you can do a connection to my DB with a determinated user who has a few rights over certain tables (this works, but I can't detect when the connection fails, it gets stuck, seems that errno doesn't work as it should do). After that, I want to retrieve every single register of a table with a certain flag (SQL query works OK directly in server, and in the future I'll do a more acurate version), and show some fields of each registry, while I want maintain hidden the id to pass it through a form button. I cannot retrieve the data stored in the DB, NO ERROR APPEARS, it's very frustrating and I don't know why. Can you help me, please? Thanks. <?php session_start(); // Change this to your connection info. $DATABASE_HOST = 'localhost'; $DATABASE_USER = 'myuser'; $DATABASE_PASS = 'hispassword'; $DATABASE_NAME = 'mydb'; // Try and connect using the info above. $con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME); if (mysqli_connect_errno()){ // If there is an error with the connection, stop the script and display the error. //Doesn't work, why is the server unable to process it? echo('Failed to connect to MySQL: ' . mysqli_connect_errno()); $con->close(); session_destroy(); exit(); } else{ session_regenerate_id(); $_SESSION['loggedin'] = TRUE; $_SESSION['name'] = $DATABASE_USER; $_SESSION['id'] = $id; echo 'Bienvenido ' . $_SESSION['name'] . '!'; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Listas</title> <link href="./CSS/basic_style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="titulo"> <h1>Cursillos disponibles</h1> </div> <div class="content"> <form action="comprar.php" name="comprar" method="post"> <table name="contents" width="100%"> <tr> <th>Título</th> <th>Subtítulo</th> <th>Descripción</th> <th>Importe (€)</th> <th>Adquirir</th> </tr> <?php $resultado = $con->excute_query("SELECT * FROM cursillo where cursillo.activo='0'", MYSQLI_USE_RESULT); foreach ($resultado as $fila) { echo $fila[1]; ?> </td> <td> <?php echo $fila[2]; ?> </td> <td> <?php echo $fila[3]; ?> </td> <td> <?php echo $fila[4]; ?> </td> <td> <input type="submit" name="pagar" value="<?php$fila[0]?>"> </td> </tr> <?php } mysql_free_result($resultado); $con->close(); ?> </table> </form> </div> </body> </html>
×
×
  • 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.