Hey guys,
Just familiarizing myself with PHP and MySQL. I am following along in the O'Reilly book that addresses both topics and has the platypus on the cover.
At any rate, I tried typing in chapter 6 exercise 1 and the script did not work. I then downloaded the example code from the books website and found out what I typed was identical and actually tried the downloaded script and had THAT not work.
Other PHP scripts are working, so I know it's not the system. For instance phpinfo.php does it's thing, as do my other scripts so far.
Here is the code from the downloaded example:
Code: [Select]<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Wines</title>
</head>
<body>
<pre>
<?php
// (1) Open the database connection
$connection = mysql_connect("localhost","fred","shhh");
// (2) Select the winestore database
mysql_select_db("winestore", $connection);
// (3) Run the query on the winestore through the connection
$result = mysql_query ("SELECT * FROM
wine", $connection);
// (4) While there are still rows in the result set, fetch the current
// row into the array $row
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
// (5) Print out each element in $row, that is, print the values of
// the attributes
foreach ($row as $attribute)
print "{$attribute} ";
// Print a carriage return to neaten the output
print "n";
}
?>
</pre>
</body>
</html>
I am running a Mac OS X 10.6 (Snow Leopard) system and have put the script in the same place that my other PHP scripts are working : Mac HD -> Library -> WebServer -> Documents
This simple script is meant to access a MySQL db and print it's contents in a web browser. Obviously the db login here is fake. But in the 'real' script I have tried a user that should have rights and even tried it with root which I KNOW has rights. I am able to access the db from the command line interpreter using both the user and with root. The script and the browser are running locally on my machine and being served by apache (which has been restarted both with apachectl and with the GUI tools).
Thanks!
include problem
I have my root folder as:Code: $root = $_SERVER["SITE_HTMLROOT"]; // the server rootWhy does this not work when I want to include a php file:Code: include "$root/form.php";But the
array_count_values question?
ok i'm trying to create a top ten list from a database of listed favorite movies.the following code yields me the correct order and number of votes for each movie$compare = array_count_values
Login page problems
I developed a website a few months ago and I am now having an issue with logging into it. The place that it is hosted just did some upgrades to their servers and for some reason, now my login page
MySQL query problem
When I try to run the following piece of code, I get this error:QuoteWarning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/muskelmann098/public_html/build.php on line
Points for Wiki contribution
Hi everyone,
Converting RGB values to HEX
Code: <?PHP$file_handle = fopen("colors/rgb.csv", "r");while (!feof($file_handle) ) {$line_of_text = fgetcsv($file_handle, 1024);print $line_of_text[2] . $line_of_text[3] .
need to add "sizes" to shopping cart
Hey guys, I am trying to figure out a way to add a "size" selector on to this bit of code. I added a way to view it in the "zoom.php" page and also to select a size from the sizes
Needing Youtube thumb nail fix.
I have a script on a site that pulls in you-tube videos,The problem is, that the thumb nails for the site, no longer show up.I have tried to add codes to remove the line causing the problem but this
Need Reporting Advice
My SQL server doesn't support MS SQL reporting services that comes with SQL Enterprise or Express. Then the administrator suggested that I google for alternatives. I'm a newbie and don't even know
Optimize Code
Just started getting into the use of cookies. The following code will redirect users to a set URL should they view a preset number of pages. I'm a little concerned with the speed in which this