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
44
Other forums
links using header()
Hi All
I'm not sure where to ask for help on this but I hope someone can offer some. I'm at
Header is not working in IE
Hi ! header function is not working in IE but it works in FF, Safari, Chrome. any help please. :
My query is being run with no results.
I have this.
Code: function DropUser($duser_id, $user_email, $user_username) {
http to https
Hi,
Is there any specific method/condition to move an http:// page to https:// ?
User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo
pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n
mysql query with single quotes in a variable
$sitedetails = "INSERT INTO vars (address, sitename, description, ownername, theme) VALUES ('$u
How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.
H
browse folder only
hi,
is there a way i can browse or get the directory or folder only and not the file?
i just w
string to currency format
Hi guys...
Actually I chunk out some data from txtfile and one of the data contains amount va