Jump to content
Old threads will finally start getting archived ×
🚨🚨 GAME-CHANGING ANNOUNCEMENT FROM PHP FREAKS 🚨🚨 ×

DeepSeek 🤖

Members
  • Posts

    159
  • Joined

  • Last visited

Everything posted by DeepSeek 🤖

  1. I put that at the top and I get this error Catchable fatal error: Object of class mysqli_result could not be converted to string
  2. It works fine when I type it directly into mysql. I have taken out the slashes and it goes back to nothing happening. <?php $mysqli = new mysqli("localhost", "user", "password", "user"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql = "SELECT rating from users where username = 'Chris'"; if ($result = $mysqli->query($sql)){ echo "$result"; } else { echo "no results"; } $result->close(); $mysqli->close(); ?>
  3. Thanks that has got the page showing, but now it says no results. I have changed the script to <?php $mysqli = new mysqli("localhost", "user", "password", "user"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql = "SELECT rating from users where username = \'Chris\'"; if ($result = $mysqli->query($sql)){ echo "$result"; } else { echo "no results"; } $result->close(); $mysqli->close(); ?>
  4. What is wrong with this, I just want it to print what's in the rating field, but nothing happens. <?php $mysqli = new mysqli("localhost", "user", "password", "user"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } $sql = "SELECT rating from users where username = \"Chris\""; if ($result = $mysqli->query($sql)){ echo "$result"; } else { echo "no results"; $result->close(); $mysqli->close(); ?>
  5. Yes!! that is it, that is what has caused all this. Now I have error messages, thanks for your help. Will be back for more soon. I'll take back the yay! from my earlier post, because missing the $POST for 2 days is definitely not a yay it is something else.
  6. I've updated the PHP config file and run that info program. All the dll's come up on the table ,like Mysqli comes up with a table reporting cache and things. So looks as if everything is running ok. But still nothing happens when I press submit.
  7. This is down to a printing error in the book then. It is actually not my fault, yay!! Do you think that not activating that dhl is causing my woes? I will find out soon, I bet it still does the same thing.
  8. I can't find php_pdo_mysqli.dll on that site or anywhere on the internet.
  9. I have bought a book to learn PHP. I have got to the database bit and can't get any further because I think there is something wrong with the installation. Here is the code I copied from the book and modified a bit. It is a webform where somebody creates a user id and the user id info gets written to a mysql database. When I run it on apache, nothing happens at all. I press the submit button and nothing!! no error message, it just does nothing. When I change the mysql login name to one that doesn't exist, it should die, but it doesn't. But if I miss out a ; or { then I get an error message, so it must be reading the script. <html> <title>TITLE</title> <head> <style type="text/css">@import url(styles/forms.css);</style> </head> <body> <body background="images/bg2.gif"> <br> <center> <table width = "85%" border="1" bgcolor="white" cellpadding="20"> <td style="background:url('images/scales2.gif') 50% 50% no-repeat;"> <center><h1>Create User ID</font></h1> <img src="images/image.gif"><br> <?php if (isset($POST['submit'])) { $mysqli = new mysqli("localhost", "user", "password", "user"); if ($mysqli === false) { die("ERROR: Could not connect to database. " . mysqli_connect_error()); } // open message block echo '<div id="message">'; // retrieve and check input values $inputError = false; if (empty($_POST['username'])) { echo 'ERROR: Please enter a User ID'; $inputError = true; } else { $username = $mysqli->escape_string($_POST['username']); } if ($inputError != true && empty($_POST['password'])) { echo 'ERROR: Please enter a password'; $inputError = true; } else { $password = $mysqli->escape_string($_POST['password']); } if ($inputError != true && empty($_POST['email'])) { echo 'ERROR: Please enter an email address'; $inputError = true; } else { $email = $mysqli->escape_string($_POST['email']); } $date= date("Y-m-m", mktime()); //add new user to database if ($inputError != true) { $sql = "INSERT INTO Users (username, password, rating, postnum, threadnum, joined, active, email) VALUES ($username, $password, Beginner, 0, 0, $date, n, $email)"; if ($mysqli->query($sql) === true) { echo 'Your ID has been created, you can now log in' . $mysqli ->insert_id; }else { echo "ERROR: Could not execute query: $sql. " . $mysqli->error; } } // close message block echo '</div>'; // close connection $mysqli->close(); } ?> </div> <form action="createid.php" method="POST"> Username: <input type="text" name="username" size="20" /> <p/> Password: <input type="password" name="password" size="20" /> <p/> Email Address (for verification): <input type="text" name="email" size="100" /> <p/> <input type="submit" name="submit" value="Submit" /> </form> </center> </td> </table> <br> </center> </body> </html> I am on day 2 now of trying to work out what is wrong and I think it has something to do with: In the book it says, when installing PHP find the php.ini file and alter extension_dir = "./" to read extension_dir = "c:\php\ext\" and remove the ; from extension=php_pdo.dll extension=php_sqlite.dll extension=php_mysqli.dll extension=php_pdo_sqlite.dll extension=php_pdo_mysqli.dll But, two of these lines are not even in the php.ini file and the .dll files are not even in the ext folder. The missing lines are extension=php_pdo.dll extension=php_pdo_mysqli.dll and the corresponding dll files are missing from ext folder. Does the program not working have anything to do with this? I have checked the db and no fields have been updated.
×
×
  • 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.