Jump to content

Recommended Posts

I have multiple scripts that I need help integrating into my site. They all work fine but they need some teaking here and there.

 

If anyone has a good experience with PHP, and would like to help me please add me to MSN;

 

djtim2005@gmail.com

 

All help is greatly appreciated :)!

 

--

DJ

Link to comment
https://forums.phpfreaks.com/topic/52290-need-help-with-scripts/
Share on other sites

Alright, here is the code. Maybe someone can help me :)!

 

This is a script for Shops;

<?php
include("layout.php");
include("database.php");
$username = $_COOKIE['username'];

if (!$username) {
echo "You cannot view this page unless you are logged in!";
include("database.php");
die("");
}

$id = $_GET['id'];

if ($id==0) {
echo "This shop has been closed due to restocking bugs.";
include("database.php");
die("");
}

$res1 = mysql_query("SELECT * FROM infoshop WHERE id='$id' LIMIT 1");
while ($row1=mysql_fetch_array($res1)) {
$shopkeeper = $row1['shopkeeper'];
$saying = $row1['greets'];
}

echo "<center>$shopkeeper welcomes you as you enter the shop: '$saying'<P><a href='?id=$id'>Refresh</a>";

echo "<table style='border:0px solid black' cellpadding=4>";
$i = 0;
$res = mysql_query("SELECT * FROM shopstock WHERE shop='$id'");
while ($row=mysql_fetch_array($res)) {
$i += 1;
if ($i==5) {
	echo "</tr>";
	$i = 1;
}
if ($i==1) {
	echo "<tr style='border:0px solid black'>";
}
$item = $row['item'];
$eitem = base64_encode($item);
$res2 = mysql_query("SELECT * FROM items WHERE item='$item' LIMIT 1");
while ($row2=mysql_fetch_array($res2)) {
	$pic = $row2['pic'];
	$cost = $row2['ocost'];
	if ($prem=="yes") {
		$costoff = $cost * .10;
		$cost -= $costoff;
		$cost = round($cost);
	}
	$high = $row2['high'];

	$descrip = $row2['descrip'];
}
$sstock = $row['id'];
$qty = $row['qty'];
echo "
<td style='border:0px solid black' width='25%'><a href='buyitem.php?id=".$sstock."&ssid=$eitem'> <center><img src='$pic'></a><BR><b>$item</b><BR>$qty in stock <BR> Cost: $cost OP</td>";
}
if (mysql_num_rows($res)==0) {
echo "<tr><td style='border:0px solid black' bgcolor=red>This shop is out of stock!</td></tr>";
}
echo "</table>";

include("database.php");
?>

 

There is the code. I keep getting the error You need to be logged in to view this page. I am logged in and it's still not working.

 

--

DJ

I'm not exactly sure but you are called database.php a lot. If it's already called and not within an if statement, shouldn't you be able to use it at any time? And, if not, shouldn't you close the connection if you want it to connect later in the script?

 

I'm just learning too so sorry if I'm not much of a help.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.