PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
These are the results of our user poll
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/whosyour/public_html/viewresults.php on line 53
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/whosyour/public_html/viewresults.php on line 54
yeah I had that but it returns no results and I definately have COX entered in as canchoice in my database for a user.. am i going about what I want wrong
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]
maybe this will help:
[quote="4Boredom"]
<?php
$conn = mysql_connect("localhost", "mysql_user", "mysql_password");
if (!$conn) {
echo "Unable to connect to DB: " . mysql_error();
exit;
}
if (!mysql_select_db("mydbname")) {
echo "Unable to select mydbname: " . mysql_error();
exit;
}
$result = mysql_query("SELECT * FROM userbase WHERE canchoice = 'COX'");
if (!$result) {
echo "Could not successfully run query ($sql) from DB: " . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
echo $row["field1"];
echo $row["field2"];
echo $row["field3"];
}
mysql_free_result($result);
?>
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]
$result = mysql_query("SELECT count(*) FROM `userbase` WHERE `canchoice` = 'COX'") or die(mysql_error());
echo mysql_result($result, 0); //should print the number who selected cox
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.