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 9249505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:12:30+00:00 2026-06-18T10:12:30+00:00

I’ve been working on a project for school where I have you search for

  • 0

I’ve been working on a project for school where I have you search for a string, and it wil query a database and return all of the words which are in that string of letters. For that, I have to use strtoupper(), which works fine if you have a string of all uppercase or lowercase letters. If you enter AAB or aab into the search, everything will work fine, and it will return the two anagrams, ABA and BAA. However, if you type in aAB, it will return nothing.
So it is getting the post data from the input, named alpha, and then it is alphabetizing the word, so if you typed in ABA, it would return AAB, and then making it uppercase.

<title>Scrabble</title>
<?php
require 'connect.inc.php';
if (isset($_POST['al'])){
    $al=$_POST['al'];
    $al=alpha($al);
    $al=trim(strtoupper($al));
    $query="SELECT * from Words WHERE alpha='$al'";
    if ($query_run = mysql_query($query)){

        while ($query_row = mysql_fetch_assoc($query_run)){
            $alpha = $query_row['alpha'];
            $ana = $query_row['word'];

            echo "<strong>$ana</strong> $alpha<br>";

        }
    }


}
function alpha($word){
    $array=array();
    for($x=0;$x<strlen($word);$x++){
        $char=substr($word,$x,1);
        $array[$x]=$char;


    }
    sort($array);
    $alpha=implode('',$array);
    return $alpha;

}
?>
<form action='scrabble.php' method='POST'>
Enter text to anagram. Please use either all uppercase or all lowercase<input type='text'                   name='al'>
<input type='submit'>
</form>

he link is here
http://newdev.shodor.org/~amalani/newdev/scrabble.php
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-06-18T10:12:32+00:00Added an answer on June 18, 2026 at 10:12 am

    Multiple issues:

    PHP’s sort function returns a boolean for whether it was successful or not. In your code you have:

    $array=sort($array);
    

    When it should just be:

    sort($array);
    

    You have a syntax error near the top:

    $alphagram=trim(strtoupper($al);
    

    Should probably be:

    $alphagram = trim(strtoupper($alphagram));
    

    I also noticed that on your website, you use:

    name='al'
    

    And then in the script try to access the POST variable alpha. You should be using:

    $_POST['al']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a jquery bug and I've been looking for hours now, I can't
I would like to run a str_replace or preg_replace which looks for certain words
This could be a duplicate question, but I have no idea what search terms
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have been unable to fix a problem with Java Unicode and encoding. The
I have a reasonable size flat file database of text documents mostly saved in

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.