Jump to content

Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link reso


dingus

Recommended Posts

hello this is my second post in 24 hours but i am only new to php so please bare with me

i am trying to do a simple page to enter data in to a database

i cant find an error but i keep getting the message

"Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\norrisbak\test\admin.php on line 101"

i copy of my code is as follows if some one coukld please help me find a sulution it would be greatly appriceated

[code]<?
/*
this section is setting the veriables as they where typed above
*/
$Sub_Category = $_POST['Sub_Category'];
$Business_name = $_POST['Business_name'];
$Description = $_POST['Description'];
$Ph = $_POST['Ph'];
$Fax = $_POST['Fax'];
$Email = $_POST['Email'];
$Category = $_POST['Category'];
/*
print "$Sub_Category, $Business_name, $Description, $Ph, $Fax ,$Email  , $Category ";
*/

/*
this following section should load the data in to the table
*/

$query =
"INSERT INTO table1
VALUES ('$Category', '$Sub_Category', '$Business_name',
'$Description', '$Ph', '$Fax', '$Email')";




$result = mysql_query($query);


// Determine the number of enterys
$number =  mysql_affected_rows ($result); // <<<<<<<this is line 101
/*
if ($number == 0) {
  print "Sorry, there were no records matching those criteria";
} else {
  // Print the employee names
  for($i=0; $i<$number; $i++){
  $Code = mysql_result($result,$i,"Code");
  $Error_Message = mysql_result($result,$i, "Error_Message");
        print "$Code $Error_Message";
  }
}
*/
?>[/code]
Link to comment
Share on other sites

i know it probably looks realy silly posting again but i still cant get it right i am realy new to php ( only been codeing php for about 3 days now

the page i am working on is located here

http://149.135.37.223/norrisbak/test/admin.php

and a copy of the php code can be found here

http://149.135.37.223/norrisbak/test/admin.txt

if some one could please tell me what i am doing wrong it would be realy good because i kinda need to fix it realy soon thanks again for helping
Link to comment
Share on other sites

ok im sorry about that i wasnt aware a compleate copy of the code sance the database password is below

[code]
<!-- all this stuff generating the admin boxes -->
<form NAME="search" action="admin.php" method="post">

Sub_Category (Eg. new dealers, second hand dealers, etc.) <input type="text" name="Sub_Category"><br>
Business_name <input type="text" name="Business_name"><br>
Description <input type="text" name="Description"><br>
Phone Number <input type="text" name="Ph"><br>
Fax <input type="text" name="Fax"><br>
E-mail <input type="text" name="Email"><br>
<!--in short this section allows you to set the aria you want the data to be added under-->
<select name="Category">
<option value="Featured Listings">Featured Listings</option>
<option value="Home Repairs">Home Repairs</option>
<option value="Pets and Animals">Pets and Animals</option>
<option value="Medical Professionals">Medical Professionals</option>
<option value="Legal professionals">Legal professionals</option>
<option value="Tax and Accounting">Tax and Accounting</option>
<option value="Restaurants and Eateries">Restaurants and Eateries</option>
<option value="Computing">Computing</option>
<option value="Professional Drivers">Professional Drivers</option>
<option value="Adult Services">Adult Services</option>
<option value="Real Estate">Real Estate</option>
<option value="Hair and Beauty">Hair and Beauty</option>
<option value="Telecommunications">Telecommunications</option>
<option value="Car Sales">Car Sales</option>
<option value="General Retail">General Retail</option>
<option value="Car repair">Car repair</option>
<option value="Entertainment">Entertainment</option>
<option value="Accommodation">Accommodation</option>
<option value="Pubs and Clubs">Pubs and Clubs</option>
</select>
<input type="submit" value="submit" name="submit">
</form><p>


<?
// database infomationg
// this section setst daatbase veriables
$hostName = "127.0.0.1";
$userName = "root";
$password = "";
$dbName = "xsydney";
$TableName = "table1";

// this section uses the code above to connect to the database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");

mysql_select_db($dbName) or die("Unable to select database $dbName");

?>


<?
/*
this section is setting the veriables as they where typed above
*/
$Category = $_POST['Category'];
$Sub_Category = $_POST['Sub_Category'];
$Business_name = $_POST['Business_name'];
$Description = $_POST['Description'];
$Ph = $_POST['phone'];
$Fax = $_POST['Fax'];
$Email = $_POST['Email'];

print "$Sub_Category, $Business_name, $Description, $Ph, $Fax ,$Email  , $Category ";


/*
this following section should load the data in to the table
*/

$Link = mysql_connect ($hostName,$userName,$Password);

$Query = "insert into customer values ($Category, '$Sub_Category','$Business_name',$Ph, $Fax,'$email' )";


$result = mysql_db_query ($DBName, $Query, $Link) or die ("Insert failed");


print ("<h1>A customer has been added, Thankyou</h1>");



// Create a table


print ("<table border='1' width=\"50%\" cellspacing=2 cellpadding=2 align='center'>");
print ("<tr align=center valign=top>\n");
print ("<td align=center valign=top>cust_id</td>\n");
print ("<td align=center valign=top>cust_name</td>\n");
print ("<td align=center valign=top>cust_street</td>\n");
print ("<td align=center valign=top>cust_town</td>\n");
print ("<td align=center valign=top>cust_state</td>\n");
print ("<td align=center valign=top>phone</td>\n");
print ("<td align=center valign=top>email</td>\n");
print ("</tr>\n");

// Student details entered.


print ("<tr align='center' valign='top'>\n");
print ("<td align='center' valign='top'>[0]</td>\n");
print ("<td align='center' valign='top'>[1]</td>\n");
print ("<td align='center' valign='top'>[2]</td>\n");
print ("<td align='center' valign='top'>[3]</td>\n");
print ("<td align='center' valign='top'>[4]</td>\n");
print ("<td align='center' valign='top'>[5]</td>\n");
print ("<td align='center' valign='top'>[6]</td>\n");
print ("</tr>\n");

mysql_close ($Link);
print ("</table>\n");
?>
<h1><a href="index.html">Home</a></h1>
<?
/*
$result = mysql_query($query);


// Determine the number of enterys


if(mysql_affected_rows($result)) {
  $number =  mysql_affected_rows($result);
}
/*
if ($number == 0) {
  print "Sorry, there were no records matching those criteria";
} else {
  // Print the employee names
  for($i=0; $i<$number; $i++){
  $Code = mysql_result($result,$i,"Code");
  $Error_Message = mysql_result($result,$i, "Error_Message");
        print "$Code $Error_Message";
  }
}
*/
?>


<?
/*
}
  else
{
  print("Wrong password");
}
*/
?>
[/code]
Link to comment
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.