Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.