473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Getting slew of errors when running php script

Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.

Here is the script.

I appreciate any light that could be shed on the script and why I would
get the errors.

Thank you,

Mike
---------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Sample PHP Script</title>

</head>

<body style="font-family:Arial, Helvetica, sans-serif"
style="background-color:#CC9966">

<?php
// Define connection string
$host = "localhost";
$user = "root";
$pass = "*******";

//open a persistant connection to the database
$connect = mysql_connect($host, $user, $pass);

//Select the database
mysql_select_db("myfirstdb", $connect);

//Set and run the query
$sql = "Select Employee_no, Last_name, First_name, Commission from
Sales_Representative";
$result = mysql_query($sql, $connect);

$x = mysql_num_rows($result);

//If the tenth row exists, go straight to it
if ($x >= 10) {
mysql_data_seek($result, 9);
}

//Return the data from the 10th row
$row = mysql_fetch_array($result);
Print "Employee_no: " . $row["Employee_No"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name: " . $row["First_Name"] . "<br>\n";
Print "Commission: " . $row["Commission"];

?>

</body>
</html>

Jul 17 '05 #1
11 2238
mikey_boy said the following on 07/06/2005 21:03:
Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.

Here is the script.

I appreciate any light that could be shed on the script and why I would
get the errors.


What are the error-messages you get? (if you post the error messages,
it'll be easier for people to work out the problem then having to go
through your code looking for syntax errors, etc.)

--
Oli
Jul 17 '05 #2
On 7 Jun 2005 13:03:54 -0700, "mikey_boy" <mb*****@gmail.com> wrote:
I appreciate any light that could be shed on the script and why I would
get the errors.


What errors?

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3
>Hello! Curious if anyone could give me a hand. I wrote this PHP
script with makes a simple connection to a mysql database called
firstdb and just pulls back the results and displays on the webpage.

Here is the script.
WHERE ARE THE ERRORS?
I appreciate any light that could be shed on the script and why I would
get the errors.
WHERE ARE THE ERRORS? Well, I'll just have to guess what's wrong.
$host = "localhost";
This is wrong. Your hostname should be in the .nsa.gov top-level domain.
And if you don't have clearance, they'll kill you.
$user = "root";
Wrong. This should be "Administrator" or "Al Gore".
$pass = "*******";
Your password is incorrect, and too easy to guess.
//open a persistant connection to the database
mysql_connect() does not open a *PERSISTENT* connection.
$connect = mysql_connect($host, $user, $pass);

//Select the database
mysql_select_db("myfirstdb", $connect);
You don't check whether this worked. Also, it's MyFristDB (as in
the Senator).

//Set and run the query
$sql = "Select Employee_no, Last_name, First_name, Commission from
Sales_Representative";
Wrong. This query should be "delete from Sales_Representative where Spams_Sent > 0".
$result = mysql_query($sql, $connect);

$x = mysql_num_rows($result);

//If the tenth row exists, go straight to it
if ($x >= 10) {
mysql_data_seek($result, 9);
}

//Return the data from the 10th row
$row = mysql_fetch_array($result);
Print "Employee_no: " . $row["Employee_No"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name: " . $row["First_Name"] . "<br>\n";
Print "Commission: " . $row["Commission"];
Isn't "print", not "Print" what you are trying to do here?
?>

</body>
</html>


Gordon L. Burditt
Jul 17 '05 #4
Here is the errors that display. I work in the IT field, I should've
know to post the errors...MY BAD!!
---------------------------------------------------------------------------------------------------------
Notice: Undefined variable: discovery in
C:\development_site\Database.php on line 13

Notice: Undefined variable: root in C:\development_site\Database.php on
line 13

Notice: Undefined variable: killer in C:\development_site\Database.php
on line 13

Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for
user 'ODBC'@'localhost' (using password: NO) in
C:\development_site\Database.php on line 13

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 16

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 20

Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 22

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 30
Employee_no:
Last_Name:
First_Name:
Commission:

Jul 17 '05 #5
On 7 Jun 2005 14:48:59 -0700, "mikey_boy" <mb*****@gmail.com> wrote:
Here is the errors that display. I work in the IT field, I should've
know to post the errors...MY BAD!!
---------------------------------------------------------------------------------------------------------
Notice: Undefined variable: discovery in
C:\development_site\Database.php on line 13
This didn't come from the script you posted. It didn't contain "$discovery".
Notice: Undefined variable: root in C:\development_site\Database.php on
line 13
This didn't come from the script you posted. It didn't contain "$root".
Notice: Undefined variable: killer in C:\development_site\Database.php
on line 13
This didn't come from the script you posted. It didn't contain "$killer".
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for
user 'ODBC'@'localhost' (using password: NO) in
C:\development_site\Database.php on line 13
How about posting either:

(a) The errors from the script you posted, or
(b) The script that produced these errors.

Because they aren't the same. The one you posted used mysql_connect, and on a
different line number.
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 16
Because you didn't check for errors on the mysql_pconnect.
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 20
Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 22
Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db nor on the mysql_query.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 30
Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db nor on the mysql_query nor mysql_num_rows.
Employee_no:
Last_Name:
First_Name:
Commission:


You haven't got any data so they're all blank.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #6
>Here is the errors that display. I work in the IT field, I should've
know to post the errors...MY BAD!!
---------------------------------------------------------------------------------------------------------
Notice: Undefined variable: discovery in
C:\development_site\Database.php on line 13

Notice: Undefined variable: root in C:\development_site\Database.php on
line 13

Notice: Undefined variable: killer in C:\development_site\Database.php
on line 13
I recommend fixing these, if necessary by using isset() on the variable
before using its value. But the big problem comes next:
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for
user 'ODBC'@'localhost' (using password: NO) in
C:\development_site\Database.php on line 13
Here you have a serious problem: you can't connect to your
database. Test the login information using a command-line
client. And you really ought to have a password on your database,
even if it's only accessible via localhost.
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 16
Your connect failed, so you can't select a database. Fix previous
error first.
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 20
Your connect failed, so you can't do queries. Fix previous error first.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 22
Your query failed, so you didn't get a result. Fix previous error first.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 30
Your query failed, so you didn't get a result. Fix previous error first.
Employee_no:
Last_Name:
First_Name:
Commission:


Gordon L. Burditt
Jul 17 '05 #7

<<<< 13 >>>>

Jul 17 '05 #8
Gordon Burditt wrote:
<snip>
Print "Commission: " . $row["Commission"];


Isn't "print", not "Print" what you are trying to do here?


Isn't PHP case-insensitive?

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #9
R. Rajesh Jeba Anbiah said the following on 08/06/2005 17:18:
Gordon Burditt wrote:
<snip>
Print "Commission: " . $row["Commission"];


Isn't "print", not "Print" what you are trying to do here?

Isn't PHP case-insensitive?


Indeed. PHP is case-insensitive for function names. But case-sensitive
for variable names.
P.S. Please fix your signature. It should start dash-dash-space to be
automatically trimmed.
--
Oli
Jul 17 '05 #10
Oli Filth wrote:
R. Rajesh Jeba Anbiah said the following on 08/06/2005 17:18: <snip>
Isn't PHP case-insensitive?


Indeed. PHP is case-insensitive for function names. But case-sensitive
for variable names.


Yeah, thanks:)
P.S. Please fix your signature. It should start dash-dash-space to be
automatically trimmed.


It's not me, but GG.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Jul 17 '05 #11
Andy-

I made the mistake and posted the wrong error message. I altered the
script a bit, but posted the orginal error message. I will post the
new error message that I get when I try running the new altered script.
Again sorry for the hassle.

I will keep you all posted.

Thanks for everyone's assistance.

Mike

Andy Hassall wrote:
On 7 Jun 2005 14:48:59 -0700, "mikey_boy" <mb*****@gmail.com> wrote:
Here is the errors that display. I work in the IT field, I should've
know to post the errors...MY BAD!!
---------------------------------------------------------------------------------------------------------
Notice: Undefined variable: discovery in
C:\development_site\Database.php on line 13


This didn't come from the script you posted. It didn't contain "$discovery".
Notice: Undefined variable: root in C:\development_site\Database.php on
line 13


This didn't come from the script you posted. It didn't contain "$root".
Notice: Undefined variable: killer in C:\development_site\Database.php
on line 13


This didn't come from the script you posted. It didn't contain "$killer".
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for
user 'ODBC'@'localhost' (using password: NO) in
C:\development_site\Database.php on line 13


How about posting either:

(a) The errors from the script you posted, or
(b) The script that produced these errors.

Because they aren't the same. The one you posted used mysql_connect, and on a
different line number.
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 16


Because you didn't check for errors on the mysql_pconnect.
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in C:\development_site\Database.php on line 20


Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db.
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 22


Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db nor on the mysql_query.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\development_site\Database.php on line 30


Because you didn't check for errors on the mysql_pconnect nor on the
mysql_select_db nor on the mysql_query nor mysql_num_rows.
Employee_no:
Last_Name:
First_Name:
Commission:


You haven't got any data so they're all blank.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool


Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: JeffFinnan | last post by:
I can get a source file to write html code fully in Iexplorer. However, in Netscape 4.8, I cannot get it to write this particular line: <SCRIPT LANGUAGE="JavaScript" SRC="src1.js"></script> in the...
2
by: gene kelley | last post by:
I'm using the VB2005 WebBrowser control. On occasion, a page that is navigated to contains script errors. These errors keep displaying a message box asking if I want to debug. If I manage to...
4
by: lawrence k | last post by:
I've a jpeg image that is 514k, which doesn't strike me as very large. Yet I'm running out of error when I try to resize it: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to...
2
by: maxkumar | last post by:
Hi, I am running a ASP.NET 1.1 site on Win Server 2003 with IIS 6.0. The website has been running for about 1.5 years now. In the past, we used to have random cases of session variables getting...
6
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
8
by: illuzion | last post by:
ok I keep getting this error: Parse error: syntax error, unexpected T_VARIABLE in /home/illuzion/public_html/BAMF/contactus.php on line 38 and this error is possibly on other lines could...
0
by: Yansky | last post by:
Hi, I'm having a lot of problems getting any Python scripts to run on my website. I have put them in the cgi-bin directory and chmodded both the directory and files to 755. But when I try to access...
15
by: Lawrence Krubner | last post by:
Does anything about this script look expensive, in terms of resources or execution time? This script dies after processing about 20 or 25 numbers, yet it leaves no errors in the error logs. This is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.