Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi All,
Glad to find other skilled web designers that are willing to share tips, code, and problems.
I've been using php for a little over 6 months now and it has been my first language. The entire time I have been having all kinds of troubles with the mysql query function. I'm trying to use the mysql count() function to tally up the rows then store that value in a variable. My script did not work. I then broke my code down with some if statements and echos to confirm the query was working. It stated the query is successful however when I echo my result I usually get one of these 2:
Resource id#3
Resource id#5
?????????????
Heres the code:Code: Select all
$link = mysql_connect('localhost', 'joe');
if (!$link) {
die('could not connect to catalog' . mysql_error());
}
echo "<center><font color=#aa0000><i>you have connected to the catalog.</i></font></center>";
echo "<a href='/main.html'>MAIN MENU</a>";
mysql_select_db('db_one', $link);
$tmp = $_FILES['userfile']['tmp_name'];
$sql = "insert into {$_POST['type']} (id, name, seasonal, quantity, description, price, ext, pic_id) values (0, '{$_POST[name]}', default, {$_POST['quantity']}, '{$_POST[description]}', {$_POST['price']}, '$mimeType', LAST_INSERT_ID())";
$result = mysql_query($sql);Code: Select all
$sql = "select count() from {$_POST['type']}";
$result = mysql_query($sql);
$id = mysql_result($result);
echo $id; // this is what always displays Resource id#3 || #5
$folder = $_POST['type'];
$destination = "uploads\\" . $folder . "\\" . $id . "." . $mimeType;Mantis_61
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]