Jump to content

Recommended Posts

mysql_select_db($database_newdb, $newdb);
$query_Recordset5 = "SELECT * FROM counting";
$Recordset5 = mysql_query($query_Recordset5, $newdb) or die(mysql_error()); 

I'm getting-

Warning: mysql_select_db() expects parameter 2 to be resource, null given in C:\xampp\xampp\htdocs\cag\index.php on line 7

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\xampp\htdocs\cag\index.php on line 9

 

What have I got wrong?

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/196223-cant-connect-to-database/
Share on other sites

I've put this now-

mysql_connect("localhost","root");
mysql_select_db("people"); 
$query_Recordset5 = "SELECT * FROM newtable";
$Recordset5 = mysql_query($query_Recordset5, $gary) or die(mysql_error());
$result = mysql_query($query_Recordset5);
$row_Recordset5 = mysql_fetch_assoc($Recordset5);
$c = $row_Recordset5['visitor'];
$c=$c+1;
echo $c;
$totalRows_Recordset5 = mysql_num_rows($Recordset5);

 

I'm getting no errors now but I'm getting a blank page now. why?

 

$gary = mysql_connect("localhost","root") or die("Error connecting to database<br /><br />".mysql_error());
mysql_select_db("people") or die("Error selecting database<br /><br />".mysql_error());
$query_Recordset5 = "SELECT * FROM newtable";
$Recordset5 = mysql_query($query_Recordset5, $gary) or die("Error querying database<br /><br />".mysql_error());
$row_Recordset5 = mysql_fetch_assoc($Recordset5);
$totalRows_Recordset5 = mysql_num_rows($Recordset5);

do {
$c = $row_Recordset5['visitor'];
$c=$c+1;
echo $c."br />";
} while($row_Recordset5 = mysql_fetch_assoc($Recordset5));

 

Give that a try... I saw you were providing the var $gary as a connection resource in the query but were not declaring it anywhere. I also assumed since you were using mysql_num_rows() that you were getting multiple results so I added the loop for the output.

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.