SQL Query/echo not working
Posted on
16th Feb 2014 07:03 pm by
admin
Hey all,
I'm trying to run (what I thought) was a simple operation and it isn't working. I haven't coded anything in about 2 years, and I'm self taught at that so I know I've got quite a few gaps in my knowledge base.
Did you know?Explore Trending and Topic pages for more stories like this.
Here's what is running right now:
Code: <?php
$con = mysql_connect("localhost","adminaccount","adminpassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mornin14_idiot2009", $con);
$id = $_GET['id'];
$query = "SELECT * FROM idiot WHERE index = '15'"; //I want this to say WHERE index = $id, but I'm testing this with just a #
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
for ($x=0; $x<$numrows; $x++){
$result_row = mysql_fetch_row($result);
echo $result_row[0];
echo "<br />";
echo $result_row[1];
echo "<br />";
echo $result_row[3];
echo "<br />";
echo $result_row[5];
echo "<br />";
}
?>
Now it should only be returning one row since I'm checking for a specific index #.
When I just do a basic select * from idiot and omit the where clause, it works fine and dumps the whole table in the for loop. But if I try a specific where, it falls apart. Any help would be greatly appreciated.
No comments posted yet
Your Answer:
Login to answer
196
44
Other forums
highlighting search terms
well, I started this in the regular PHP section, but it no longer fits there. Suffice it to say, I'm
Day of week
I am using PHP version 5.0.5
I have a varaible ($DATE (date format yyyy-mm-dd)) that is being inc
Basic Question Regarding PHP Includes
Hi
Just starting out with PHP.
Working on a site that uses some basic includes, these
void* and sizeof()
Hi,
Using void* and sizeof is it possible to get the value of the object ?
I understan
Calculating a rating by adding number of points and dividing by number of items
I have a site that users can post links to files to download. They can rate these files on a 1-5 sca
Displaying pictures
i have worked my way through storing images in directory and storing the location in mySQL db.Now i
read integers that returns a negative or prints the average
Im trying to finish this homework assignment by tommarow afternoon and I keep getting stuck.
Wr
Need a fuction to count entries in a field
Hi
I need a fuction to count how many times a email address is entered in to a field.
I ma
why preg_match_all does not return the number of matches
My regex looks like
X[^x{4e00}-x{9fa5}]*Y
(where X and Y are two Chinese characters)
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan