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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:40:40+00:00 2026-06-08T06:40:40+00:00

I have a little test project set up so that when you click a

  • 0

I have a little test project set up so that when you click a wolves’s name, it takes them to a page that I want to use to personalize information concerning whichever wolf they clicked on. The page is called wolf.php. I’m trying to using passing variable the $_GET method to assign the URL the wolves id, i.e http://www.testsite.com/wolf.php?id=1 but the page then displays nothing even though I do not get an error.

Here’s the home page (home.php)

<?php
$username = $_SESSION['username'];
$result = @mysql_query("SELECT * FROM wolves WHERE owner = '$username'");
while($wolf = mysql_fetch_array($result))
{
echo "<a href= wolf.php?id=$wolf[id]>$wolf[name]</a>";
};
?>

Clicking this link takes me to http://www.testsite.com/wolf.php?id=1 (or whatever the id was). On wolf.php I have this:

<?php
$id = $_GET['id'];
$result = @mysql_query("SELECT name FROM wolves WHERE id = '$id'") or die("Error: no  
such wolf exists");
echo .$result['name'].
;
?>

I’m not sure where I went wrong but this doesn’t seem to be working. No information regarding the id of the wolf shows up. Thanks for help in advance.

  • 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-08T06:40:41+00:00Added an answer on June 8, 2026 at 6:40 am

    Turn on error reporting with error_reporting(E_ALL); ini_set('display_errors', 1); in development so you see the fatal syntax errors in your code. It is also recommended to remove @ error suppression operator from your mysql_*() calls.

    You have syntax problems on the last line. Unexpected . concatenation operators:

    // Wrong:
    // Parse error: syntax error, unexpected '.'
    echo .$result['name'].
    ;
    
    // Should be:
    echo $result['name'];
    

    Next, you have not fetched a row from your query:

    // mysql_query() won't error if there are no rows found.  Instead you have to check mysql_num_rows()
    $result = mysql_query("SELECT name FROM wolves WHERE id = '$id'") or die("Query error: " . mysql_error());
    // Zero rows found, echo error message.
    if (mysql_num_rows($result) < 1) {
      echo "No such wolf.";
    }
    else {
      // Row found, fetch and display.
      $row = mysql_fetch_assoc($result);
      echo $row['name'];
    }
    

    Note that this script is wide open to SQL injection. At a minimum, call mysql_real_escape_string() on your query input variables.

    $id = mysql_real_escape_string($_GET['id']);
    

    Ultimately, think about using PDO or MySQLi instead of the old mysql_*() functions, as they support prepared statements for greater security over manually escaping variables. The mysql_*() functions are planned for deprecation.

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

Sidebar

Related Questions

I have a unit test that contains several test cases. I set them up
I have created a little test project to try to resolve a problem I
I have a little JUnit-Test that export an Object to the FileSystem. In the
I have a little foundation tool test (Objective-C) that I am playing with and
Can I get a little help with this? In a test project, I have
I have this little rake task: namespace :db do namespace :test do task :reset
i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I have a little trouble getting gettext to work. I made a simple test
I'm trying to set up UI automation for Silverlight 3. I have a little
As the title says, I want to have a build tool that quite much

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.