Jump to content

[SOLVED] Resorce ID instead of data from database


Navajo

Recommended Posts

When I'm returning to the screen I'm getting resorce ID 5 instead of the value I want from the datdabase?

 

My code:

 

	$getDes = mysql_query("SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'");


echo "$getDes";

 

I'm clearly being a bit thick :(

 

 

Ok so I'm trying:

 

	$getDes = mysql_query("SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'");

$row =  mysql_fetch_assoc($getDes);

echo "$row";

 

This returns the word Array, instead of ResorceID5, what am I doing wrong?

mysql_fetch_assoc returns an array. Your code should read....

 

<?php

$sql = "SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'";
if ($result = mysql_query($sql)) {
  if (mysql_num_rows($result)) {
    $row =  mysql_fetch_assoc($getDes);
    echo $row['vchar_description'];
  }
}

?>

 

ps: Theres a link to a free book (hudzilla) that should get you started, this is pretty basic stuff.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.