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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:10:50+00:00 2026-05-18T21:10:50+00:00

My sql script is not returning a value ‘sid’ when I use it with

  • 0

My sql script is not returning a value ‘sid’ when I use it with php, but when I run it against the actual database it returns the value. I cannot figure out where my error is. My tables are as follows:

Song
aid (1)
sid (999)
title (Moonlight Sonata)
surl

Album
aid (1)
artist (Beethoven)
genre (Classic)
album

Here is my code:

$sql="SELECT S.title, S.surl, S.sid, A.aid, A.album, A.artist FROM challenge C, 
    song S, album A WHERE C.fid = '$uid' AND uid = '$user' AND date = '$date' 
    AND C.sid = S.sid AND S.aid = A.aid";

$result=mysql_query($sql);

if (mysql_num_rows($result) != 0){
    while($row=mysql_fetch_array($result)){
    $title = $row[title];
    $album = $row[album];
    $surl = $row[surl];
    $artist = $row[artist];
    $aid = $row[aid];
    $sid = $row[sid];

echo "Album: $album Artist: $artist Title: $title Song: $surl SongID: $sid";
    }
}

Everything is printing except the value ‘sid’ – it should be printing 999. Any help would be greatly appreciated!!

  • 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-18T21:10:51+00:00Added an answer on May 18, 2026 at 9:10 pm

    $row[title] is not the syntax you’re looking for. If you’d enable error reporting you’d see warnings about undefined constants. Just writing title makes PHP look for a constant called “title”, which does not exist. Only then does it fall back onto strings and tries if you maybe meant the string 'title'. SID happens to be a predefined constant, so that’s the only time it’s using the value of the constant, and there’s no index in the array with the value of that constant.

    Quote your strings! Write $row['title'] and $row['sid'].

    Please read “Why is $foo[bar] wrong?”.
    Furthermore read the article about SQL injection and escape your input!

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

Sidebar

Related Questions

When writing a T-SQL script that I plan on re-running, often times I use
When I run a particular SQL script in Unix environments, I see a '^M'
How to create a database using T SQL script on a specified location? Let's
I have a SQL script that inserts data (via INSERT statements currently numbering in
I have a migration that runs an SQL script to create a new Postgres
I want to construct a transact sql script that will stop specified people from
I encountered the following ddl in a pl/sql script this morning: create index genuser.idx$$_0bdd0011
Currently, if I want to output a SQL script for a table in my
I'm looking for a tool to enforce coding styles, validation check for T-SQL script.
We have an sql build script, with oracle 10.2. At the end of the

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.