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

Running External Scripts
I am very new to PHP and am not even sure what I'm asking is possible. I have just installed mediaW

Cannot Connect to Database
I am writing an application to do annual reviews. I cannot get my script to work. Whenever it runs I

send message to the java application
Oracle 10g with Windows platform.

I have a java application that periodically pings the d

PHP hyperlinks generator - HELP plz
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

Intrastat Report Config in ECC 6.0 - goods Movement in EU countries
Colleagues, need ur help to understand the changes require in ECC 6 standard Report configuration se

GIS appliction help
I found some tutorials in the internet to develop a map application I don't want to use google maps

quick basic question, hopefully not dumb
I don't know how to search for this, so forgive me if it's been covered...

I often see an exa

PHP Include not working
The website is http://www.grlistingservices.com

The code block is as follows:

<

Blocking video streaming
Hello everyone,

I post a message here because i didn't find any solution yet.
I just finis

update 2 columns by doing inner 2-column query
Hi,
is something like this possible?

update contract_all set col1,col2 =
(

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