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
Multi Dimensional Array Append
Hi Guys
I have a function that returns a multidimentional array eg
$result = functio
PHP hyperlinks generator
Hi
I need some help to get this done using php:
1 - I have few hyperlinks say 500
PHP/PKI
I am trying to set up a web application that uses pki. does anyone have a good tutorial to set this
Embedding flash object in Else statement
This is my first major project in PHP and I'm having some trouble embedding a flash object in an Els
login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php
mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id
GMail like Chat in ASP.NET
Hi,Can anyone suggest me, how to incorporate GMail like chat in my existing ASP.Net application.I wa
PO Release Strategy Issue
Hi Experts,
I am facing an issue related to PO release strategy. The details are-
<
Writing Windows Device Drivers with C
Yes: one of the nice features of C is void*. You can put anything there and get anything out. Very
Remove values in array2 from array1
I have two arrays.
Array 1 is where the array key holds various different numbers. For exampl