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.

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

php mysql script to find record
Hi,

Currently I have a simple table with 4 columns. A, B, C, D

If I want to find all

Help With editting and deleting form
Hallo !!

So look at this image :

http://img194.imageshack.us/img194/8272/snapshot5f.pn

Get value from Select menu
Hi!

Have tried to find the solution on the web. Don't know if there is an easy one. A descrip

shoping cart issues
i´ve wrote this and works when i add an item to, my cart, but when i want to add othrer item just

sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields.

fie

retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell

Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I

problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

Appending GET data with form submition
Okay, what I'm trying to do is to use a form to append an already existing GET data string.

I

The control with ID 'ace' requires a ScriptManager on the page
I'm trying to add a simple AlwaysVisibleControlExtender to my page, but it's not working. I get the

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