Jump to content

[SOLVED] Why isn't php "seeing" the database?


matthewst

Recommended Posts

<?php
session_start();
include('db_con.php');
$tack_id = $_SESSION['track_id'];
$track_name = $_SESSION['track_name'];
?>

 

Would be more appropriate as you set the session values on the login page, this is where you call the session values. Than print $track_id to print the id. If this is confusing let me know.

Link to comment
Share on other sites

I'm Stumped(not that that is hard to do)

 

Once logged in my users are presented with a "control panel" where they can select a predefined web templet. New users of course won't have style yet. Any ideas?

 

Notice: Undefined variable: set_style_id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 50

 

<?php
session_start();
error_reporting(E_ALL);
function copyr($source, $dest)
{
     // Simple copy for a file
    if (is_file($source)) {
         return copy($source, $dest);
     }
  
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest);
     }
  
     // Loop through the folder
     $dir = dir($source);
     while (false !== $entry = $dir->read()) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
  
         // Deep copy directories
         if ($dest !== "$source/$entry") {
             copyr("$source/$entry", "$dest/$entry");
         }
     }
  
     // Clean up
     $dir->close();
     return true;
}
//INCLUDES
include('id.php');
include('db_con.php');





//CHECK LOGIN VS ID
if ($track_id!=$_SESSION['track_id']){

echo '<script type="text/javascript">
		location="index.php"
	      </script>';

}
//******HERE IS THE PROBLEM***************************************
if ($set_style_id!=""){
//****************************************************************
//GET SITE PATH

$get_root_folder=mysql_query("SELECT root_folder FROM rest_filesystem WHERE rest_id='$id'",$db_link);
$row=mysql_fetch_array($get_root_folder);
$root_folder=$row['root_folder'];
$root_folder_css=($root_folder."/css");
$root_folder_img=($root_folder."/images");

//GET THEME PATHS
$get_theme_path=mysql_query("SELECT css_doc FROM styles WHERE style_id='$set_style_id'",$db_link);
$row=mysql_fetch_array($get_theme_path);
$theme_path=$row['css_doc'];

$theme_path_css=($theme_path."CSS");
$theme_path_img=($theme_path."IMAGES");

$index_file=($theme_path."live_index.php");


copyr($theme_path_css, $root_folder_css);

copyr($theme_path_img, $root_folder_img);

//CHECK MYSQL FOR ALL PAGES AND NAMES - COPY:
//copy($index_file, $root_folder."/index.php");
//TO ALL FILE NAMES CONTAINED
//AND PUT IN PAGE ID WHERE IT'S SUPPOSED TO GO

	$getpages = mysql_query("SELECT cust_id, pg_id, pg_name, pg_addr FROM rest_pages where cust_id=$id", $db_link);
							while($row = mysql_fetch_array($getpages)) { 
								$row['pg_id'] != "";
								copy($index_file, $root_folder."/".$row['pg_addr']);

				$page_id=$row['pg_id'];

				$fh = fopen($root_folder."/".$row['pg_addr'], 'r+') or die("can't open file");

				$stringData = '<?php $page_id='. $page_id.';';
				fwrite($fh, $stringData);


				fclose($fh);

}


}

?>
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
	<meta name="generator" content="Adobe GoLive 5">
	<title>Admin Page :: Home</title>
</head>

<body bgcolor="#ffffff">
	<div align="center">
		<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo "$track_id"; ?><br>
			<br>
			<br>

				<table border="0" cellpadding="0" cellspacing="2" width="180">
					<tr height="19">
						<td colspan="2" height="19">
							<div align="center">
							<font size="3"><b>Actions:</b></font></div>
						</td>
					</tr>
					<tr>
						<td>Select Theme:</td>
						<td><a href="themes.php">Link</a></td>
					</tr>
					<tr>
						<td>Upload Images:</td>
						<td><a href="images.php">Link</a></td>
					</tr>
					<tr>
						<td>Manage Pages:</td>
						<td><a href="pages.php">Link</a></td>
					</tr>
					<tr>
						<td>Change Content:</td>
						<td><a href="content.php">Link</a></td>
					</tr>
					<tr>
						<td>View Page:</td>
						<td><a href="../">Link</a></td>
					</tr>
					<tr>
						<td colspan="2">
							<div align="center">
							</div>
						</td>
					</tr>
				</table>

		</font></div>
</body>

</html>

 

 

I've attached the styles table of my database

 

 

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

I'm also having trouble with my image upload and viewing page.

 

images.php:

<?php
session_start();
//INCLUDES
include('id.php');
include('db_con.php');


//CHECK LOGIN VS ID
if ($id!=$_SESSION['track_id']){

echo '<script type="text/javascript">
		location="index.php"
	      </script>';

}

//GET SITE PATH
$get_root_folder=mysql_query("SELECT root_folder FROM rest_filesystem WHERE rest_id='$id'",$db_link);
$row=mysql_fetch_array($get_root_folder);
$root_folder=$row['root_folder'];

$root_folder_img=($root_folder."/images");


if($submit) {

//BEGIN PICTURE UPLOAD CODE________________________________________________________________________________*


//user defined variables
$abpath=($root_folder_img); //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Do you want size limit, yes or no
$size = "2500000"; //What do you want size limited to be if there is one

//all image types to upload
$cert1 = "image/pjpeg"; //Jpeg type 1
$cert2 = "image/jpeg"; //Jpeg type 2
$cert3 = "image/gif"; //Gif type
$cert4 = "image/png"; //PNG type

$log = "";



//==================================================================begin upload 1===============================================================

//checks if file exists
if ($img1_name == "") {
$log .= "No file selected for upload 1<br>";
}
if ($img1_name != "") {


$image1nameext = $img1_name;
if ($image1nameext!=""){
//Checks if file is an image
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4) or($img1_type == $cert5)) {
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4)) {
if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3)) {
if (($img1_type == $cert1) or ($img1_type == $cert2)) {

}
if ($img1_type == $cert3) {

}
if ($img1_type == $cert4) {

}
if ($img1_type == $cert3) {

}
}
}
@copy($img1, "$abpath/$image1nameext") or $log .= "Couldn't copy file 1 to server - it may be too large, or the transfer may have been disrupted<br>";

if (file_exists("$abpath/$image1nameext")) {

$log .= "File 1 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> <img src="images/$image1nameext"></font><br>into any content area.<br><br>";
}
} else {
$log .= "File 1 is not an image$img1_name<br>";
}
}
}



//==================================================================begin upload 2===============================================================
//checks if file exists
if ($img2_name == "") {
$log .= "No file selected for upload 2<br>";
}
if ($img2_name != "") {


$image2nameext = $img2_name;
if ($image2nameext!=""){
//Checks if file is an image
if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3) or ($img2_type == $cert4) or($img2_type == $cert5)) {
if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3) or ($img2_type == $cert4)) {
if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3)) {
if (($img2_type == $cert1) or ($img2_type == $cert2)) {

}
if ($img2_type == $cert3) {

}
if ($img2_type == $cert4) {

}
if ($img2_type == $cert3) {

}
}
}
@copy($img2, "$abpath/$image2nameext") or $log .= "Couldn't copy file 2 to server - it may be too large, or the transfer may have been disrupted<br>";

if (file_exists("$abpath/$image2nameext")) {

$log .= "File 2 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> <img src="images/$image2nameext"></font><br>into any content area.<br><br>";
}
} else {
$log .= "File 2 is not an image$img1_name<br>";
}
}
}


//==================================================================begin upload 3===============================================================




//checks if file exists
if ($img3_name == "") {
$log .= "No file selected for upload 3<br>";
}
if ($img3_name != "") {


$image3nameext = $img3_name;
if ($image1nameext!=""){
//Checks if file is an image
if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3) or ($img3_type == $cert4) or($img3_type == $cert5)) {
if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3) or ($img3_type == $cert4)) {
if (($img3_type == $cert1) or ($img3_type == $cert2) or ($img3_type == $cert3)) {
if (($img3_type == $cert1) or ($img3_type == $cert2)) {

}
if ($img3_type == $cert3) {

}
if ($img3_type == $cert4) {

}
if ($img3_type == $cert3) {

}
}
}
@copy($img3, "$abpath/$image3nameext") or $log .= "Couldn't copy file 3 to server - it may be too large, or the transfer may have been disrupted<br>";

if (file_exists("$abpath/$image3nameext")) {

$log .= "File 3 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> <img src="images/$image3nameext"></font><br>into any content area.<br><br>";
}
} else {
$log .= "File 3 is not an image$img3_name<br>";
}
}
}




//==================================================================begin upload 4===============================================================



//checks if file exists
if ($img4_name == "") {
$log .= "No file selected for upload 4<br>";
}
if ($img4_name != "") {


$image4nameext = $img4_name;
if ($image4nameext!=""){
//Checks if file is an image
if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3) or ($img4_type == $cert4) or($img4_type == $cert5)) {
if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3) or ($img4_type == $cert4)) {
if (($img4_type == $cert1) or ($img4_type == $cert2) or ($img4_type == $cert3)) {
if (($img4_type == $cert1) or ($img4_type == $cert2)) {

}
if ($img4_type == $cert3) {

}
if ($img4_type == $cert4) {

}
if ($img4_type == $cert3) {

}
}
}
@copy($img4, "$abpath/$image4nameext") or $log .= "Couldn't copy file 4 to server - it may be too large, or the transfer may have been disrupted<br>";

if (file_exists("$abpath/$image4nameext")) {

$log .= "File 4 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> <img src="images/$image4nameext"></font><br>into any content area.<br><br>";
}
} else {
$log .= "File 4 is not an image$img4_name<br>";
}
}
}



//==================================================================begin upload 5===============================================================



//checks if file exists
if ($img5_name == "") {
$log .= "No file selected for upload 5<br>";
}
if ($img5_name != "") {


$image5nameext = $img5_name;
if ($image5nameext!=""){
//Checks if file is an image
if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3) or ($img5_type == $cert4) or($img5_type == $cert5)) {
if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3) or ($img5_type == $cert4)) {
if (($img5_type == $cert1) or ($img5_type == $cert2) or ($img5_type == $cert3)) {
if (($img5_type == $cert1) or ($img5_type == $cert2)) {

}
if ($img5_type == $cert3) {

}
if ($img5_type == $cert4) {

}
if ($img5_type == $cert3) {

}
}
}
@copy($img5, "$abpath/$image5nameext") or $log .= "Couldn't copy file 5 to server - it may be too large, or the transfer may have been disrupted<br>";

if (file_exists("$abpath/$image5nameext")) {

$log .= "File 5 was uploaded<br>It can be embedded by typing:<br><font size='-2' face='Verdana, Arial, Helvetica, sans-serif'> <img src="images/$image5nameext"></font><br>into any content area.<br><br>";
}
} else {
$log .= "File 5 is not an image$img5_name<br>";
}
}
}



//END PICTURE UPLOAD CODE__________________________________________________________________________________*
}
?>
<html>

<head>
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
	<meta name="generator" content="Adobe GoLive 5">
	<title>Admin Page :: Images</title>
</head>

<body bgcolor="#ffffff">
	<div align="center">
		<font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo "$track_id"; ?><br>
			<? echo $log; ?><br>
			<br>
			<table border="0" cellpadding="0" cellspacing="2" width="600">
				<form action="<?=$PHP_SELF;?>" method="post" enctype="multipart/form-data" name="FormName">
					<tr height="19">
						<td colspan="2" height="19">
							<div align="center">
								<font size="3"><b>Upload New Pictures:</b></font></div>
						</td>
					</tr>
					<tr>
						<td valign="top" width="150"><b>You may upload up to five pictures at a time.<input type="hidden" value="<?=$project;?>" name="project"><input type="hidden" value="hiddenValue" name="hiddenName"></b></td>
						<td>
							<p>Pictures to upload:<br>
								<input type=file name=img1 size=30><br>
								<input type=file name=img2 size=30><br>
								<input type=file name=img3 size=30><br>
								<input type=file name=img4 size=30><br>
								<input type=file name=img5 size=30><br>
							</p>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<div align="center">
								<input type="submit" name="submit" value="Upload"></div>
						</td>
					</tr>
				</form>
			</table>
		</font><font face="Verdana, Arial, Helvetica, sans-serif"><br>
			<?php
$mydir = ("$root_folder/images");
//$mydir = dir("rest/MattsBBQ_603/images") 


?><br>
		</font><font face="Verdana, Arial, Helvetica, sans-serif">
		<table width="650" border="0" cellspacing="2" cellpadding="0">
			<tr>
				<td colspan="3" align="center"><b>Your Pictures:</b><br>
						<font size="-2">Click to enlarge.</font></td>
			</tr>

			<?php while(($file = $mydir->read()) !== false) {


      if($file==".") {
       }else{
      if($file==".."){
      }else{
      if($file==".DS_Store"){
     }else{ 
        echo "<tr><td align='center'>$file</td></tr><tr><td align='center'><a href='../images/$file' target='_blank'><img width='150' border='0' src='../images/$file'></a></td></tr><tr><td align='center'><img src="images/$file"></td></tr>";
         }
         }
      }
   }
   $mydir->close();?>


		</table>
			<br>



		</font><font face="Verdana, Arial, Helvetica, sans-serif"><br>
			<a href="home.php">Admin Home</a></font></div>
</body>

</html>

 

It keeps giving me this error:

Fatal error: Call to a member function read() on a non-object in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/images.php on line 324

 

line 324 is:

<?php while(($file = $mydir->read()) !== false) {

 

php is greate but i'm going to go punch myself in the groin for a little while. it's less painful.

 

Link to comment
Share on other sites

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.