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="backgrou nd-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_Represent ative";
$result = mysql_query($sq l, $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_arr ay($result);
Print "Employee_n o: " . $row["Employee_N o"] . "<br>\n";
Print "Last_Name: " . $row["Last_Name"] . "<br>\n";
Print "First_Name : " . $row["First_Name "] . "<br>\n";
Print "Commission : " . $row["Commission "];
?>
</body>
</html> 11 2254
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
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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
>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 "Administra tor" 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_Represen tative";
Wrong. This query should be "delete from Sales_Represent ative where Spams_Sent > 0".
$result = mysql_query($sq l, $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_arr ay($result); Print "Employee_n o: " . $row["Employee_N o"] . "<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
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.p hp on line 13
Notice: Undefined variable: root in C:\development_ site\Database.p hp on
line 13
Notice: Undefined variable: killer in C:\development_ site\Database.p hp
on line 13
Warning: mysql_pconnect( ) [function.mysql-pconnect]: Access denied for
user 'ODBC'@'localho st' (using password: NO) in
C:\development_ site\Database.p hp on line 13
Warning: mysql_select_db (): supplied argument is not a valid MySQL-Link
resource in C:\development_ site\Database.p hp on line 16
Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in C:\development_ site\Database.p hp on line 20
Warning: mysql_num_rows( ): supplied argument is not a valid MySQL
result resource in C:\development_ site\Database.p hp on line 22
Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL
result resource in C:\development_ site\Database.p hp on line 30
Employee_no:
Last_Name:
First_Name:
Commission:
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.p hp 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.p hp 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'@'localho st' (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.p hp 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.p hp 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.p hp 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_arr ay(): supplied argument is not a valid MySQL result resource in C:\development_ site\Database.p hp 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.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool
>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.p hp on line 13
Notice: Undefined variable: killer in C:\development_ site\Database.p hp 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'@'localho st' (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.p hp 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.p hp 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.p hp on line 22
Your query failed, so you didn't get a result. Fix previous error first.
Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource in C:\development_ site\Database.p hp 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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 code. All other lines are
written. Is there some trick I need to do?
The script file src1.js :
function selectFile() {
var pdbFile =...
|
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 complete the document load, these errors keep
reoccurring as the mouse passes over a menu on the site, for example.
In IE, the option, "Disable Script...
|
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
allocate 12288 bytes) in
/home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageToSquare.php
on line 82
How can I...
|
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 lost, but not frequently. However, since
the past 2 weeks, I am noticing an alarming increase of such session
variables lost cases. My application log...
|
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()
| |
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 someone please help me out with this it is for a contact form for a webpage that I am making for a class project but I decided to add in this contact...
|
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 the script, I
get a 404 error: http://forboden.com/cgi-bin/wp.py
I also tried running them from another directory and giving the
directory its...
|
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 on a server
that handles a fairly demanding site. The defaults, in php.ini, have all
been cranked fairly high: scripts get 180 seconds to run, and...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |