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

  • Home
  • SEARCH
  • 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 6330845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:56:40+00:00 2026-05-24T17:56:40+00:00

Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I’m having

  • 0

Possible Duplicate:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

I’m having a problem with this mysql code. I presume its a basic error in the $sqlx… line but I’m slightly lost.

The code basically prints messages from a db
Here is the code:

$sqls="SELECT username FROM social WHERE `adder`='$username'";
$results=mysql_query($sqls);
$resulti= mysql_num_rows($results);
if ($resulti==0) {
echo "You haven't added anyone yet. Find some <a   href=\"/social/suggestions\">suggestions</a>";
}
$row=mysql_fetch_array($results);

$sqlx="SELECT * FROM messages WHERE `sender` IN ($row)";
$resultx= mysql_query($sqlx); 
$resultz= mysql_num_rows($resultx);
if ($resultz==0){
echo "No messages at all!!";
}
else {
$finished="false";
$r=0;
While(($rowx=mysql_fetch_assoc($resultx))&&($finished=="false")) {
//echo off messages

$username is got further up the file.

Here is the error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/user/public_html/social/iframe/index.php on line 34

Line 34 is $resultz= mysql_num_rows($resultx);
But like i said the error is probably the line two up from that.

One interesting happens. “No messages at all!!” is echoed out which means the result of the mysql_query is 0. This is why I am convinced it is the line 32, ($sqlx)

Any idea??

Have I done the mysql_fetch_array wrong when getting $row??
thanks

  • 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-24T17:56:41+00:00Added an answer on May 24, 2026 at 5:56 pm
    $row=mysql_fetch_array($results);
    
    $sqlx="SELECT * FROM messages WHERE `sender` IN ($row)";
    

    This will create the following query:

    SELECT * FROM messages WHERE `sender` IN (Array)
    

    This is obviously not a valid MySQL query. You have to process the array.

    $sqlx = "SELECT * FROM `messages` WHERE `sender` IN ("; // start of query
    
    foreach($row as $r)
        $sqlx .= "'".$r['username']."',"; // insert all returned usernames
    
    $sqlx = substr($sqlx,0,-1).')'; // substract the last comma and close the query
    

    Or, as RiaD pointed out in the comments:

    $sqlx = "SELECT * FROM `messages` WHERE `sender` IN (".
            implode(',',array_map(function($x){return "'".$x['username']."'"; }, $row)).
            ")";
    

    PS: Riad, it should be $x['username'] instead of $x and you forgot the semicolon 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result This is
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result what is
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I have
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result Warning: mysql_fetch_assoc():
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I have
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result $err =
Possible Duplicate: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result I tried
Possible Duplicate: Warning: mysql_query(): 3 is not a valid MySQL-Link resource I don't know
Possible Duplicate: “Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given” error while
Possible Duplicate: What's the point of valid CSS/HTML? This is a over-asked question, but

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.