Jump to content

jose

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jose's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Are you actually using any 5.3 specific features? As far as I know Variable Static Calls and I had to download the MySQL Native Driver into my windows extensions.
  2. My website is dynamic and I need a database environment (XAMPP or MAMP). XAMPP provides only PHP 5.3.1 version. To make matters worst web hosts only support certain versions of PHP. I think, there is a problem of development and applications. And PHP 6 sooner or later will appear.
  3. Hi there. Here a theoretical question. I am building a dynamic website using a 5.3.1 version. Some web hosts do not support this version. I know that PHP 6 is coming. This situation provokes really a mess. Websites become obsolete, etc, etc. I would like to know more about this topic. Thanks
  4. Thank you guys for your help. The eventual solution is this: // Retrieve the user data from MySQL $query = "SELECT user_id, first_name FROM user WHERE first_name IS NOT NULL ORDER BY join_date DESC LIMIT 5"; $result = mysqli_query($dbc, $query); // Loop through the array of user data, formatting it as HTML echo '<h4>Latest members:</h4>'; echo '<table>'; while ($row_cnt = $result->num); { The old script is // Retrieve the user data from MySQL $query = "SELECT user_id, first_name FROM user WHERE first_name IS NOT NULL ORDER BY join_date DESC LIMIT 5"; $result = mysqli_query($dbc, $query); // Loop through the array of user data, formatting it as HTML echo '<h4>Latest members:</h4>'; echo '<table>'; while ($row = mysqli_fetch_array($row)) {
  5. I tried this option, row for result. I get a similar message: boolean given in instead of null given in
  6. I have a problems with this script: I get this warning message: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C. I would appreciate any suggestions about how to solve it, manuals, source of information, since this message is very common. Thanks a lot in advance. J <?php require_once('connectvars.php'); // Generate the navigation menu if (isset($_COOKIE['username'])) { echo '&#10084; <a href="viewprofile.php">View Profile</a><br />'; echo '&#10084; <a href="editprofile.php">Edit Profile</a><br />'; echo '&#10084; <a href="logout.php">Log Out (' . $_COOKIE['username'] . ')</a>'; } else { echo '&#10084; <a href="login.php">Log In</a><br />'; echo '&#10084; <a href="signup.php">Sign Up</a>'; } // Connect to the database $dbc = mysqli_connect('localhost', '****', '*****', '*****') or die ('Error connecting to MySQL server'); // Retrieve the user data from MySQL $query = "SELECT user_id, first_name FROM user WHERE first_name IS NOT NULL ORDER BY join_date DESC LIMIT 5"; $result = mysqli_query($dbc, $query); // Loop through the array of user data, formatting it as HTML echo '<h4>Latest members:</h4>'; echo '<table>'; while ($row = mysqli_fetch_array($row)) { if (isset($_SESSION['user_id'])) { echo '<td><a href="viewprofile.php?user_id=' . $row['user_id'] . '">' . $row['first_name'] . '</a></td></tr>'; } else { echo '<td>' . $row['first_name'] . '</td></tr>'; } } echo '</table>'; mysqli_close($dbc); ?>
  7. Thank you Thorpe, I removed the comma, but the message persists.
  8. Any suggestion indicating the solution of this problem? Appreciate, thanks <?php require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect(localhost, root, zam, entrepreneur); // Retrieve the user data from MySQL $query = "SELECT user_id, first_name, FROM user WHERE first_name IS NOT NULL ORDER DESC LIMIT 5"; $data = mysqli_query($dbc, $query); // Loop through the array of user data, formatting it as HTML echo '<h4>Latest members:</h4>'; echo '<table>'; while ($row = mysqli_fetch_array($data)) { if (isset($_SESSION['user_id'])) { echo '<td><a href="viewprofile.php?user_id=' . $row['user_id'] . '">' . $row['first_name'] . '</a></td></tr>'; } else { echo '<td>' . $row['first_name'] . '</td></tr>'; } } echo '</table>'; mysqli_close($dbc); ?>
  9. the rest of the code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title> Entrepre - Sign Up</title> <link rel="stylesheet" type="text/css" href="style.css" /> <?php require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect('localhost', 'root', 'zamb', 'entrepreneuria') or die ('Error connecting to MySQL server'); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM entrepreneurial_user WHERE username = '$username'"; $result = mysqli_query($dbc, $query); if ($result->num_rows == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO entrepreneurial_user (username, password1) VALUES ('username', SHA ('password1'))"; $row_cnt = $result->num; // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> <style type="text/css"> <!-- body,td,th { font-size: 16px; font-family: Tahoma, Geneva, sans-serif; } #wrapper { width: 860px; margin-right: auto; margin-left: auto; padding: 10px; background-color: #FFF; font-size: 12px; } body,td,th { font-family: Tahoma, Geneva, sans-serif; color: #000; background-color: #FFF; } body { background-color: #E6FFFE; .regist { font-weight: bold; } .regist { font-weight: bold; font-size: 18pt; } .u { font-size: 12pt; } .user { font-size: 12px; } .user { font-size: 12pt; } .signup { font-size: 12pt; font-weight: bold; } </style></head> <body> <div id="wrapper"> <p><img src="images/entrepreneurs banner.jpg" width="860" height="60" alt="banner" /></p> <?php // If the cookie is empty, show any error message and the log-in form; otherwise confirm the log-in if (empty($_COOKIE['user_id'])) { echo '<p class="error">' . $error_msg . '</p>'; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend class="sign">Sign Up </legend> <table width="400" border="0"> <tr> <td class="user" style="font-size: 12pt"><label for="username">Username:</label></td> <td><input name="username" type="text" value="<?php if (!empty($user_username)) echo $user_username; ?>" size="25" maxlength="15" /> <br /></td> </tr> <tr> <td class="user" style="font-size: 12pt"><label for="password1">Password:</label></td> <td><input type="password" id="password1" name="password1" /> <br /></td> </tr> <tr> <td class="user" style="font-size: 12pt"><label for="password2">Password (retype):</label></td> <td><input type="password" id="password2" name="password2" /> <br /></td> </tr> <tr> <td> </td> <td><input type="submit" value="Sign Up" name="submit" /></td> </tr> </table> </fieldset> </form> <table width="662" border="0"> <tr> <?php } else { // Confirm the successful log-in echo('<p class="login">You are logged in as ' . $_COOKIE['username'] . '.</p>'); } ?> </body> </html>
  10. Hi there, Anybody can tell why it is not possible to insert any data in MySql database? It is located in my machine, apparently everything is fine, but something is wrong and I cannot localize it. Here the script: <?php require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect('localhost', 'root', 'zam', 'entrepreneurial') or die ('Error connecting to MySQL server'); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1'])); $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2'])); if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM entrepreneurial_user WHERE username = '$username'"; $result = mysqli_query($dbc, $query); if ($result->num_rows == 0) { // The username is unique, so insert the data into the database $query = "INSERT INTO entrepreneurial_user (username, password1) VALUES ('username', SHA ('password1'))"; $row_cnt = $result->num; // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> Thanks
  11. if ($result = $mysqli->query) { was the problem. if ($result->num_rows == 0) { works! (for now) Thanks, guys!
  12. Hi there, No matter what "username" and "password" type in my machine to test my code, the program replays: An account already exists for this username. that's the code: <?php require_once('connectvars.php'); // Connect to the database $dbc = mysqli_connect('localhost', 'root', 'zambullo', 'entrepreneurial groups') or die ('Error connecting to MySQL server'); if (isset($_POST['submit'])) { // Grab the profile data from the POST $username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $password = mysqli_real_escape_string($dbc, trim($_POST['password'])); $repeatpassword = mysqli_real_escape_string($dbc, trim($_POST['repeatpassword'])); if (!empty($username) && !empty($password) && !empty($repeatpassword) && ($password == $repeatpassword)) { // Make sure someone isn't already registered using this username $query = "SELECT * FROM Entrepreneurialgroups_user WHERE username = '$username'"; $result = mysqli_query($dbc, $query); if ($result = $mysqli->query) { // The username is unique, so insert the data into the database $query = "INSERT INTO entrepreneurialgroups _user (username, password) VALUES ('$username', '$password')"; $row_cnt = $result->num; // Confirm success with the user echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>'; mysqli_close($dbc); exit(); } else { // An account already exists for this username, so display an error message echo '<p class="error">An account already exists for this username.</p>'; $username = ""; } } else { echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>'; } } mysqli_close($dbc); ?> I appreciate your help
  13. Great, cb I changed procedural for OO following your suggestions and IT WORKS!! Thanks a lot Jose
×
×
  • 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.