gaah, results from mysql

A

Anonymous

Guest
okay what is going wrong here, I used the exact same code to pull out a link from a database, now I just want it to pull out all fields in that row I ask for and did this:

Code:
$result = mysql_query("SELECT * FROM horses WHERE ID = $id");
	$result_data = mysql_fetch_array($result);
	//$url_link = $result_data["url"];
	$name = $result_data["name"];
	$regnr = $result_data["regnr"];
	$owner = $result_data["owner"];
	$breeder = $result_data["breeder"];
	$gender = $result_data["gender"];
	$picturelink = $result_data["picturelink"];
	$id = $result_data["ID"];
	$text = $result_data["text"];
	$a1 = $result_data["a1"];
	$a1reg = $result_data["a1reg"];
	$b1 = $result_data["b1"];
	$b1reg = $result_data["b1reg"];
	$a2 = $result_data["a2"];
	$a2reg = $result_data["a2reg"];
	$b2 = $result_data["b2"];
	$b2reg = $result_data["b2reg"];
	$c2 = $result_data["c2"];
	$c2reg = $result_data["c2reg"];
	$d2 = $result_data["d2"];
	$d2reg = $result_data["d2reg"];

but it is no work, what can I do to get it to work? please help, in a hurry here hehe, need it to work TODAY

Godiwa
 
Just saying "it doesn't work" isn't indicative of a problem. You need to tell us what it's doing or not doing, if your'e getting an error, and perhaps what happens when you echo the query and paste it into the MySQL console.
 
here is the error it cam with:

Code:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/beastyzoo.com/httpdocs/viewhorse.php on line 12

and this is line 11, 12 and 13:

Code:
$result = mysql_query("SELECT * FROM horses WHERE ID = $id");
	$result_data = mysql_fetch_array($result);
	//$url_link = $result_data["url"];

maybe that can help you, to help me

Godiwa
 
Well, then, your query probably isn't returning any rows. echo it and paste it into MySQL and see what error it gives you, or use mysql_error().
 
aah phew got it working ;)

was to minor errors

the $id was accidently written as $ID in the test var section

and the while loop only covered the variable conversion but not the actual document and therefor didn't fill out the vars and showed them

but atleast it works now

Godiwa
 
Back
Top