Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange processing message?

Status
Not open for further replies.

peterv6

Programmer
Sep 10, 2005
70
US
I'm running a query to display the number of rows returned from a select statement. (I know, it's simple, but I'm trying to learn this stuff from a book.) I get the desired message, but I also get the following message:

Record added

As far as I know, I shouldn't get that message when selecting data, because I'm not adding records. I've listed my code below, can someone explain why I'm getting this record added message?
Thanks:

<?php
// Wednesday, August 13, 2008 2:59:55 PM
// Connect to port 0000 on website.net.
$link = mysql_connect('website.net:0000', 'userid', 'testpw','testdb');
if (!$link) {
printf("Connect failed: %s\n", mysql_error());
exit();
} else {
include_once( 'add_record.php');
//
// select the database
$db_selected = mysql_select_db('testdb', $link);
if (!$db_selected) {
die ('Can\'t use testdb: ' . mysql_error());
}
//
$query ="select * from leadsTable";
// Perform Query
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
} else {
$number_of_rows = mysql_num_rows($result);
printf("Number of rows: %d.\n", $number_of_rows);
}
}
?>

Query output:

Record added. Number of rows: 9.

PETERV
Syracuse, NY &
Boston, MA
 
Forgot to mention:

According to the book, I should actually be getting this output:

Result set has 9 rows. Number of rows: 9.

PETERV
Syracuse, NY &
Boston, MA
 
The script you provided gives the output "Number of rows: 9.". The rest comes from the included file add_record.php. Based on the name of the file, I would expect a similar statement. Either:

a) you've made a mistake with the included file.
b) your included file has different code than you expect.

If the former, then just change the included file. If latter, you will need to show us the code of add_record.php so that we can examine it.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Vragabond,
I just found the include_once file, and that indeed is pointing to the wrong code. I commented that out, and it works correctly now. I'm very new to this, so please correct me if I'm mistaken, but I would only need to have the include_once statement in this script if I need to execute some lines of code that aren't in this script itself, is that correct? Thanks for your patience and assistance. :)

PETERV
Syracuse, NY &
Boston, MA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top