Problem with DB connection
Posted on
16th Feb 2014 07:03 pm by
admin
Hello there! I'm new to this forum and I'm new to PHP coding also. I wrote something that doesn't make exactly what I thought it will. Can you give me a hand please. There we go:
Code: [Select] <?php
error_reporting(E_ALL);
$Host = "***";
$User = "***";
$PassWord = "****";
$DataBaseName = "***";
$TableName = "products";
mysql_connect($Host, $User, $PassWord);
mysql_select_db($DataBaseName);
if (isset($_GET['id'])) {
$id = (int)$_GET['id'];
// $select = "SELECT id FROM" . $TableName;
if ($id > 0) {
$select = "select description from" . $TableName . "WHERE id = " . $id;
$result = mysql_query($select);
echo $result;
echo $id;
}
else {
echo "id not > 0";
}
}
else {
echo "ID not set;
}
?>
<p><a href="proba.php?id=1" name="id=1"> Find out more about it. </a></p>
<a href="proba.php?id=2" name="id=2"> Find out more about it. </a></p>
<a href="proba.php?id=3" name="id=3"> Find out more about it. </a></p>
That's a testing page only. What happens here is that only the ID is displayed.
The funny thing is when i add this code to the original page, my apache gives errors on the localhost and i get Quote Premature end of script headers. Obviously I'm doing something wrong, but I don't know what it is. oh, when i run this code on the original page but remove the password, apache is not shoting..
No comments posted yet
Your Answer:
Login to answer
237
36
Other forums
Script not running properly
Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work
please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php
List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab
question about header() security
is is safe to just use the header() function to redirect someone if they are, say, not logged in? or
using explode() to fill in checkboxes
Hi
I have a field stored in a table that contains regions in the UK separated by commas. Ther
Unidentified index error in a simple form
I have been trying to make an HTML form that is handled by a PHP script. So far my attempts to get i
updating a single value to multiple non consecutive rows
I need to update the same value to multiple non consecutive rows. I need to add an experation date t
Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been
how to get IP address?
hey guys,
i have this code which is supposed to get me the IP address of my site visitors:
PHP and MySQL Question/Help
I have a MySQL db with all my servers and all their details like server name, IP, OS, RAM etc etc 26