Posted: Sat Mar 05, 2005 1:41 am
Post the current version of the script.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?
if ((isset($_GETї'uname']) == true) && (isset($_GETї'poem']) == true))
{
// Tell the user it has been submitted (optional)
echo('Your comment has been posted.');
// Set Mysql Variables
$host = 'localhost';
$user = '***';
$pass = '***';
$db = 'haunted_poetry';
$table = 'dbpoems';
// Set global variables to easier names
$username = $_GETї'username'];
$poem = $_GETї'poem'];
// Connect to Mysql, select the correct database, and run teh query which adds the data gathered from the form into the database
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$add_all = "INSERT INTO $table values("$username","$poem")";
echo $add_all;
mysql_query($add_all) or die(mysql_error());
}
else
{
echo $add_all;
// If the form has not been submitted, display it!
?>
<form method='get' action='<? echo $PHP_SELF; ?>'>
Username: <input type='text' name='username'><br><br>
Poem: <input type='text' name='poem'><br><br>
<input type='submit' value='Post your poems'>
</form>
<?
}
?>Your comment has been posted.
Warning: mysql_connect(): Access denied for user: 'user@localhost' (Using password: YES) in /home/haunted/public_html/Poetry/poetry.php on line 20
Access denied for user: 'user@localhost' (Using password: YES)
Code: Select all
<?php
// This function makes the alphabetic list which the links.
function drawAddressList() {
$seperator = "-";
// Loop through all 26 characters.
for ($i = 1; $i <= 26; $i++) {
$letter = chr($i + 64);
echo $seperator . "<a href='{$_SERVERї'PHP_SELF']}?letter={$letter}'>{$letter}</a>";
}
echo $seperator . '<br />';
}
// This function gets a parameter or the default.
function getParm($VariableName, $Default = '') {
return (isset($_GETї$VariableName])) ? $_GETї$VariableName] : $Default;
}
drawAddressList();
// Connect to MySQL - use your user name and password.
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Connects to the database that has the user table.
$db_selected = mysql_select_db('db', $link);
if (!$db_selected) {
die ('Can''t use table : ' . mysql_error());
} else {
$letter = getParm('letter');
if ($letter != '') {
$letter_query = "SELECT * FROM `table` WHERE `username` REGEXP '^$letter.*' ORDER BY `username`";
$letter_result = mysql_query($letter_query);
if ($letter_result != false) {
while ($letter_row = mysql_fetch_assoc($letter_result)) {
// Do something in here with the rows you get.
// Maybe use the information from the user table to fill another recordset with the poems.
}
}
}
}
?>Code: Select all
// Connect to MySQL - use your user name and password.
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Connects to the database that has the user table.
$db_selected = mysql_select_db('db', $link);
if (!$db_selected) {
die ('Can''t use table : ' . mysql_error());
} else {
$letter = getParm('letter');
if ($letter != '') {
$letter_query = "SELECT * FROM `table` WHERE `username` REGEXP '^$letter.*' ORDER BY `username`";
$letter_result = mysql_query($letter_query);
if ($letter_result != false) {
while ($letter_row = mysql_fetch_assoc($letter_result)) {
// Do something in here with the rows you get.
// Maybe use the information from the user table to fill another recordset with the poems.
}<?php
// This function makes the alphabetic list which the links.
function drawAddressList() {
$seperator = "-";
// Loop through all 26 characters.
for ($i = 1; $i <= 26; $i++) {
$letter = chr($i + 64);
echo $seperator . "<a href='{$_SERVER['PHP_SELF']}?letter={$letter}'>{$letter}</a>";
}
echo $seperator . '<br />';
}
// This function gets a parameter or the default.
function getParm($VariableName, $Default = '') {
return (isset($_GET[$VariableName])) ? $_GET[$VariableName] : $Default;
}
drawAddressList();
// Connect to MySQL - use your user name and password.
$link = mysql_connect('localhost', 'username', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// Connects to the database that has the user table.
$db_selected = mysql_select_db('db', $link);
if (!$db_selected) {
die ('Can''t use table : ' . mysql_error());
} else {
$letter = getParm('letter');
if ($letter != '') {
$letter_query = "SELECT * FROM `table` WHERE `username` REGEXP '^$letter.*' ORDER BY `username`";
$letter_result = mysql_query($letter_query);
if ($letter_result != false) {
while ($letter_row = mysql_fetch_assoc($letter_result)) {
// Do something in here with the rows you get.
// Maybe use the information from the user table to fill another recordset with the poems.
}
}
}
}
?>
but since i did ti looks like this-A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z-
Warning: mysql_connect(): Access denied for user: 'username@localhost' (Using password: YES) in /home/haunted/public_html/Poetry/test.php on line 23
Could not connect: Access denied for user: 'username@localhost' (Using password: YES)
here is both links so you can see for yourself-A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z-