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
generating all possible random letters
hi'
how can i randomize the letters a,b,c,d,e all possible ways, and i want to print the res
Does design fit in FPGA ?
Hi all,
I've made a large HCC-Design. Because of the program-size the compile process with th
Images in email problem
I found this script for sending emails, it works but if the email has <img src="image.jp
Call to undefined function mysql_fetch_accoc()
New to php/mysql coding. What's wrong with this sequence, or am I
just not seeing to obvious?
using file_get_contents??
okay how would i create a script using file_get_contents() in php have it grab search pages 1-20 and
Calculus Help (and by help I mean homework)
Hrmmm, I hate posting about math homework, partly because it's homework, and partly because I hate w
mysql VARCHAR acting like INT
Hi, All.
I have a table that contains a varchar(10) column named weird_field. In this column
help removing unwanted graphic
How do I remove the small elongated rectangular shape between the "Latest post" and "
search function
HI guys,
if anyone could point us in the right direction of how to do this, or provide some t
php global variable
how can we create global variable so we can use its value in any form.. Please give example to