Jump to content

simple count


highaspen

Recommended Posts

I'm attempting to run a simple record count with the code below. It returns the die on the $rs
--------------------

<?php

include ("../global_vars.php");

$valid_user = $_POST['userid'];


#connect to MySQL
$conn=@mysql_connect("$dbserver", "$dbuser","$dbpass")
or die("Could not connect");

#select the specified database
$rs = @mysql_select_db("$dbtable", $conn)
or die("Could not select database");

#create the query
$sql="SELECT COUNT(*) FROM from members WHERE owner='$valid_user' ";

#execute the query
$rs=mysql_query($sql,$conn)
or die("Could not execute query");

$rs = mysql_fetch_array($rs);

?>
------------------------------

any ideas? I appreciate any insight... rather new at this. thanks.
Link to comment
https://forums.phpfreaks.com/topic/5374-simple-count/
Share on other sites

Always (at least while debugging your code) print out the mysql_error() on a die() clause.
[code]<?php
$conn=@mysql_connect($dbserver, $dbuser, $dbpass) or die('Could not connect. Error: ' . mysql_error());

#select the specified database
$rs = @mysql_select_db($dbtable, $conn) or die('Could not select database. Error: '. mysql_error());
?>[/code]

Also, you don't need the double quotes around the variable names.

Ken
Link to comment
https://forums.phpfreaks.com/topic/5374-simple-count/#findComment-19163
Share on other sites

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.