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 Like 44 Dislike
Previous forums Next forums
Other forums

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

no idea what to do...
I'm fed up. I had issues with code that I have working on a different site that didn't work on my cu

phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:

Code: [Select]$mailer = new PHPMailer();
$mailer-&

SCRIPT ERROR
Here is the CONTACT FORM I made for our website:

<form id="form1" name="

(sub)screen resize modification doesn't work after ECC 6 EhP 4 installation
Hello,

We have previously extended the size of the custom data tab on PO transaction ME23

IP Based Cron Jobs
I run cronjobs on my website. After one of my visitors got curious and tinkered around he realized h

comparing tables across databases sql refinement ideas required
Hi all

Via pl/sql I need to ensure that data between tables in different databases match

unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect

Working with Dates, help.
Sooo to make a long story short, here's what im trying to accomplish.

I need to create a drop

Filtering Tables
Hello Thanks for any help any one can give Im very new to PHP..

I need to pull data for clien

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