Jump to content

why would i be getting this error?


ballhogjoni

Recommended Posts

Notice: Use of undefined constant localhost - assumed 'localhost' in /home/realfina/public_html/freeCart/db.php on line 6

 

My connection code is:

<?php
$username="xxxxx";
$password="xxxxx";
$database="xxxxx";

$login = mysql_connect(localhost, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);
?>

 

Link to comment
https://forums.phpfreaks.com/topic/63827-why-would-i-be-getting-this-error/
Share on other sites

I have some more Notices. They all just started all the sudden. I have been running these scripts a few weeks now and have never run into these issues.

 

Notice: Undefined index: title in /home/realfina/public_html/freeCart/add-edit.php on line 9

 

Notice: Undefined index: desc in /home/realfina/public_html/freeCart/add-edit.php on line 10

 

Notice: Undefined index: price in /home/realfina/public_html/freeCart/add-edit.php on line 11

 

this is the code that is making these notices.

 

<?php 
session_start(); 
include('db.php'); 
include('functions.php'); 
checkLogin('1 2');
$query = mysql_query("SELECT * FROM users WHERE ID = '{$_SESSION['user_id']}'");
$row = mysql_fetch_array($query) or die(mysql_error());
$Username = $row['Username'];
$title = $_POST['title'];
$desc = $_POST['desc'];
$price = $_POST['price'];
$title_checked = strip_tags($title);
$desc_checked = strip_tags($desc);
if (isset($title_checked) && isset($desc_checked) && isset($price)) {
if (!empty($title_checked) && !empty($desc_checked) && !empty($price)) {
if (strlen($title_checked) > 20 || strlen($desc_checked) > 30) {
		$leng = 'Please check the length of your Title and Description. Title is 20 Characters Max and Description is 30 Characters Max.';
} elseif (strlen($title_checked) <= 20 && strlen($desc_checked) <= 30) {
    		mysql_query("INSERT INTO products (Username, title, description, price) VALUES ('$Username','$title_checked','$desc_checked','$price')") or die(mysql_error());
		$verbage = '<span class="style5">Your product has been saved.</span>';
		unset($title,$desc,$price);
}
} else {
	$verbage = '<span class="style5">Product has NOT been Saved. Please enable Javascript & be sure to fill in all fields</span>';
	unset($title,$desc,$price);
}
}
?>

 

<form action="" onsubmit="return validateFormOnSubmit(this)" method="POST">
		<div align="center">This form requires javascript to be enabled</div>
		<table align="right">
			<tr>
				<td align="right" class="style6">Title:</td>
				<td class="style6"><input type="text" name="title" /></td>
			</tr>
			<tr>
				<td align="right" class="style6">Description:</td>
				<td class="style6"><input type="text" name="desc" /></td>
			</tr>
			<tr>
				<td align="right" class="style6">Price:</td>
				<td class="style6"><input type="text" name="price" /></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input class="style6" type="submit" value="Add Product" /></td>
			</tr>
		</table>
		</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.