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
Auto fill in input value based on User_ID
Hello,
I'm looking form some input on the following problem.
User loads page ->
Passing vars to the DB
I have 3 small testing tables:
ID TYPE
1 pepperoni
2 C. bacon
3 taco
ID TY
Display Database
I need to create a shopping cart. I found this code online: http://conceptlogic.com/jcart/
Unfort
need a script for 3 pages
I have a customer who wants me to set up a site with a number of pages with the following requiremen
Expandable Post Code
Hi,
Hope you can help. Which currently I haven't upgraded to connect to a mysql server, so i
Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?
$playern
SQL query not working well
Hi,
I made a small table with 5 rows and want to make them an sql consult using rownum
[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorad
dropdown menu
Hello everbody,
I am php newbie.
I need to develop a program that once click the drop do
Backflush
I am looking for a report in SAP that would give me a list of all parts that are populated with a ba