Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7415435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:18:11+00:00 2026-05-29T07:18:11+00:00

<?php session_start(); $user = $_SESSION[‘login’]; $mysql_connect = mysql_connect(localhost, root, ); $mysql_select_db = mysql_select_db(site); $sql

  • 0
    <?php
    session_start();
    $user = $_SESSION['login'];
    $mysql_connect = mysql_connect("localhost", "root", "");
    $mysql_select_db = mysql_select_db("site");
    $sql = "SELECT * FROM `msg_inbox` WHERE `to` = '$user'";
    $result = mysql_query($sql) or die(mysql_error());
    while ($row = mysql_fetch_array($result)) {    
            $mysql_connect = mysql_connect("localhost", "root", "");
            $mysql_select_db = mysql_select_db("site");
            $query = ("UPDATE msg_inbox  SET unread = 0 WHERE id= ".$row['id']);
            $result = mysql_query($query);
    }

And I receive error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in on line 8
Can you help me?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:18:12+00:00Added an answer on May 29, 2026 at 7:18 am

    You have reassigned $result in your loop. After the first iteration, the variable $result will hold a boolean indicating the success or failure of your UPDATE statement.

    Change:

    $result = mysql_query($query);
    

    To:

    $result2 = mysql_query($query);
    

    Or just:

    mysql_query($query);
    

    And be careful of SQL injection holes.

    EDIT actually, your whole code could and should be shortened to:

    <?php
    
      session_start();
      $user = $_SESSION['login'];
      // A blank password for root? Really?
      $mysql_connect = mysql_connect("localhost", "root", "");
      $mysql_select_db = mysql_select_db("site");
      $sql = "
        UPDATE `msg_inbox`
        SET `unread` = 0
        WHERE `to` = '".mysql_real_escape_string($user)."'
      ";
      // Don't show the result of mysql_error() in a production environment!
      $result = mysql_query($sql) or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the code <?php session_start(); if(!isset($_SESSION['user_name'])) { header('Location: login.php'); } $conn = mysql_connect(localhost,
PHP session_start(); $username = $_POST['regduser']; $userpass = md5($_POST['regdpass']); $sql = $sql->prepare(SELECT * from Students
<?php session_start(); if(isset($_POST['username']) && ($_POST['password'])) { $con=mysql_connect(localhost,root,); if(!$con) { die('Could Not Connect:'.mysql_error()); } mysql_select_db(tcs,$con);
<?php session_start(); // After user logged in session_regenerate_id(); $_SESSION['logged_in'] = 1; $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
To login I use: <?php session_start(); if($_POST){ $csUSER='USERNAME'; $csPASS='PASSWORD'; $user=$_POST['user']; $pass=$_POST['pass']; if ($user==$csUSER) {
I have the following pages: page1.php <?php if (isset($_GET['link'])) { session_start(); $_session['myvariable'] = 'Hello
my code for the php page displaying the divs <?php session_start(); require_once(classlib/mainspace.php); if (isset($_SESSION['username'])==FALSE)
I have a PHP application where I set $_SESSION['user']=logged once a user is authenticated.
$sql=mysql_query(SELECT b.book_id,u.user_id,user_name,book_name,review_date,book_rating,review FROM tbl_books b,tbl_user u,tbl_book_reviews br WHERE b.book_id=br.book_id AND u.user_id=br.user_id AND moderated='n' ORDER
I'm trying to make a basic user login. In the PHP page that logs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.