If thats the WHOLE code of the file, make sure you're including the file which contains your database information.
If thats the WHOLE code of the file, make sure you're including the file which contains your database information.
WOW that code is SO insecure.
By having a GET variable directly inputted into a query is suicide.
That easily allows SQL injection and could delete the whole of your database.
TOTAL FIX + SECURITY FIX:
Rep if this works :rolleyes:PHP Code:<?php
if(empty($_GET['category']) == true) {
echo "<a href="products.php?category=soccer">Soccer Trophies</a><br />"; }else{
$cat = addslashes($_GET['category']);
$query = mysql_query("SELECT * FROM catalogue WHERE category = '$cat'");
if(mysql_error()) {
print(mysql_error());
}
while($row = mysql_fetch_array($query)) {
echo("
<table border='1'>
<tr>
<td><img src='images/".$row[item_number].".JPG'></td>
</tr>
<br>
<tr>
<td>Item Number: ". $row['item_number']."</td>
</tr>
</tr><br>
<tr><td>".$row[price]." GBP (Great Brittish Pounds)</td></tr>
<br>
</table>
<br>
");
}
?>
Last edited by *; 22-07-2007 at 05:13 PM.
PHP Code:<?php
$conn = mysql_connect("localhost","USERNAME","PASSWORD");
mysql_select_db(DATABASENAME) or die(mysql_error());
if(empty($_GET['category']) == true) {
echo "<a href="products.php?category=soccer">Soccer Trophies</a><br />"; }else{
$cat = addslashes($_GET['category']);
$query = mysql_query("SELECT * FROM catalogue WHERE category = '$cat'");
if(mysql_error()) {
print(mysql_error());
}
while($row = mysql_fetch_array($query)) {
echo("
<table border='1'>
<tr>
<td><img src='images/".$row[item_number].".JPG'></td>
</tr>
<br>
<tr>
<td>Item Number: ". $row['item_number']."</td>
</tr>
</tr><br>
<tr><td>".$row[price]." GBP (Great Brittish Pounds)</td></tr>
<br>
</table>
<br>
");
}
?>
No they would have to inculde the config.PHP Code:<?php
$conn = mysql_connect("localhost","USERNAME","PASSWORD");
mysql_select_db(DATABASENAME) or die(mysql_error());
if(empty($_GET['category']) == true) {
echo "<a href="products.php?category=soccer">Soccer Trophies</a><br />"; }else{
$cat = addslashes($_GET['category']);
$query = mysql_query("SELECT * FROM catalogue WHERE category = '$cat'");
if(mysql_error()) {
print(mysql_error());
}
while($row = mysql_fetch_array($query)) {
echo("
<table border='1'>
<tr>
<td><img src='images/".$row[item_number].".JPG'></td>
</tr>
<br>
<tr>
<td>Item Number: ". $row['item_number']."</td>
</tr>
</tr><br>
<tr><td>".$row[price]." GBP (Great Brittish Pounds)</td></tr>
<br>
</table>
<br>
");
}
?>
yeh but i was just showing -.- so neh![]()
Create a file with this and include all the configs, etc.
If this returns nothing then there is a problem on the MySQL side, is it returns all the tables in the current database there is a problem with your script.PHP Code:<?php
require_once('myconfig.php');
$query = "SHOW TABLES;";
$res = mysql_query($query) or die (mysql_error());
$rows = mysql_fetch_assoc($res);
do {
var_dump($rows);
} while($rows = mysql_fetch_assoc($res));
?>
Jamie why take my code :S
i adapted it actually![]()
Want to hide these adverts? Register an account for free!