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 Like 44 Dislike
Previous forums Next forums
Other forums

How to copy a part of a vector in a raw memory
Hi,

How can I copy a part of a vector into a memory:

1
2
3
4
5

How do i use vars in an array
Hiya peeps!

How do I use a var in an array. You will see $id but it isnt working.


Gridview Not updating in Update Panel
I have a gridview, three dropdown list boxes, and a button on my form. What is displayed in the gri

search function
HI guys,

if anyone could point us in the right direction of how to do this, or provide some t

Logic question
im wondering what's the best method to do the above list:

it is for alliance @ MMORPG game

Values disappear from my array :( HELP!
hey all, I have a lil mysql/php/apache script that queries a database
and pulls put 5 integers.

Display thumbnails as square while retaining aspect ratio
I am trying to figure out a way to make an image display as a square, for example 80x80 pixels, when

Else statement screws up all css
Does anyone know what goes wrong in the process with this php code?
This code seems to be causing

Renaming a file that a user uploads to site?
My site allows for registered users to upload images to the site under their own gallery. Currently

PHP/Database issue
My friend is helping me make a database where you go to a certain webpage of my site and the page wi

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash