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
Problem with umlauts and UTF-8
Hello every1,
I'm creating my own little CMS at the moment and got some problems with the cha
unexpected T_SL without a shift left token
Nothing too see here, I'm an idiot and resolved the problem.
Check Digits and extracting digits
I think I can figure out the code for this but I am having a very hard time getting past the first s
Displaying different page content, depending on the logged in user.
Hi all, I am new to ASP.net (and web development in general), and have a question about how I can di
image upload script not working with png
The basic process of this php code is to take the submitted file, convert it to a small JPG thumbnai
Preloading images
Posting this question here because I am not sure where this should belong.I am building an asp.net a
Transferring session variables into MySQL
I am trying to transfer $_SESSION variables into MySQL. However there is an error in my MySQL statem
Recording popularity by day, week.. all time?
Hey everyone, I'm creating a site designed around users uploading music. How can I implement a syste
PHP & MS Access - Line Break
Hey Guys!
I'm pulling records from an MS Access database and listing them using PHP and I'm r
please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda