Jump to content

mike12255

Members
  • Posts

    439
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by mike12255

  1. Im grabbing this line from my database:

     

    pfd/Order Number.pdf

     

    I need to create a url like this:

     

    <a href = admin/pfd/Order Number.pdf>Link</a>

     

    to do this im using the following PHP code:

     

    <?php
    		  $sql = "SELECT * FROM catagories";
    		  $res = mysql_query($sql) or die (mysql_error());
    		  while ($row = mysql_fetch_assoc($res)){
    		  //echo "<a href= Admin/".$row['Name'].">".$row['wantedname']."</a><br>";
    		  echo "<a href=\"" . urlEncode($row['Name']) . "\">" . $row['wantedname'] . "</a><br >\n";
    		  }
    		  
    
    		  ?>

     

    unfortinatlly this outputs this:

     

    <a href="Admin/pfd/Order" number.pdf="">sdfas sdf asdf</a>

     

    anyone know how to fix the <a href part?

  2. well for example row['name'] of the first object in the db is:

     

    ../pfd/Martial Arts - Pressure Points - Military Hand To Hand Combat.pdf

     

    and row['wantedname'] is:

     

    Testing

     

    so the first link should be

     

    <a href= "../pfd/Martial Arts - Pressure Points - Military Hand To Hand Combat.pdf">Testing</a>

     

    however the source its outputting for it is:

     

      <a href="">Testing</a><br>

     

    its not linking it to anything

  3. im trying to use info from my db to create a link, but its just creating a link to the page its already on, anyone know why?

     

    <?php
      $sql = "SELECT * FROM catagories";
    		  $res = mysql_query($sql) or die (mysql_error());
    		  while ($row = mysql_fetch_assoc($res)){
    		  echo "<a href='".$row['name']."'>".$row['wantedname']."</a><br>";
    		  }
    ?>
    		  

  4. im trying to query something into my table that has an element called desc so when i query something in i use:

     

    <?php
    $sql8 ="INSERT INTO fourm_subcats (catid,name,'desc',admin)VALUES ('".$cat."','".$name."', '".$desc."', '".$row7['admin']."')";
    ?>

     

    but mysql is taking the desc name to be DESC(the descending function) and its causing an error, anyway to get around this?

  5. So im running a query and after it gets pased this line:

     

    $res6 = mysql_query($sql6) or die (mysql_error());

     

    it gives the following error:

     

    Table 'fourm.forum_subcats' doesn't exist

     

    The long line of code that the peice is in is:

     

     <?php
    
    if ($act == "create_subcat") {
    				if (!$_POST['submit']){
    					echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
                            echo "<form method = \"post\" action = \"admin.php?act=create_subcat\">\n";
                            echo "<tr><td>Forum Catagory</td><td><select name=\"cat\"><option value=\"0\">Please Choose...</option>";
                            $sql5 = "SELECT * FROM forum_cats ORDER BY id ASC";
                            $res5 = mysql_query($sql5) or die (mysql_error());
                            if (mysql_num_rows($res5) == 0){
                            	echo "</select><br><br>There are no catagories yet.";
                            	
                            }else{
                            	while ($row5 = mysql_fetch_assoc($res5)){
                            		echo "<option value=\"".$row5['id']."\">".$row5['name']."</option>";
                            		
                            	}
                            	
                            }
    					echo "</select></td></tr>";
    					echo "<tr><td>Sub Cat. Name</td><td><input type =\"text\" name=\"name\"></td></tr> ";
    					echo "<tr><td>Description</td><td><input type =\"textarea\" name=\"desc\" style =\"width:300px;height:60px;\"></td></tr>";
    					echo "<tr><td colspan =\"2\" align=\"right\"><input type=\"submit\" name= \" submit\" value = \"Add Forum Sub Cat.\"></td></tr>";
    					echo "</form></table>";
    
    				}else{
    
    					$cat = mss($_POST['cat']);
    					$name = mss($_POST['name']);
    					$desc = mss($_POST['desc']);
    
    
    					if ($cat && $name){
    
    						$sql6 = "SELECT * FROM forum_cats WHERE id ='".$cat."'";
    
    
    						$res6 = mysql_query($sql6) or die (mysql_error());
    
    					if (mysql_num_rows($res6)== 0){
    						die("est");
    						echo "<br>Please Select a Main Catagory.";
    					}else{
    						$sql7 = "SELECT * FROM forum_subcats WHERE name = '".$name."' AND cid ='".$cat."'";
    						$res7 = mysql_query($sql7) or die (mysql_error());
    						if (mysql_num_rows($res7) > 0){
    
    							echo "This sub catagory already exsists in the main catagory'".$cat."'";
    						}else{
    						if(strlen($desc)>255){
    							echo"Description must be under 255 characters.";
    						}else{
    							$row7 = (mysql_fetch_assoc($res6));
    
    							$sql8 ="INSERT INTO forum_subcats (cid,name,desc,admin)VALUES ('".$cat."','".$name."', '".$desc."', '".$row7['admin']."')";
    							$res8 = mysql_query($sql8) or die (mysql_error());
    							echo "The subcatagory <b>".$name."</b> has been sucsesfully created.";
    
    
    
    						}?>

    Did i screw up one of my queries?

  6. Im creating a form threw echo statments, however both my checkbox and button are text boxes i assume im missing an > but my old eyes cant catch it, can anyone else find my error??

     

     echo "<table border \"0\" cellspacing \"3\" cellpadding=\"3\">\n";
                            echo "<form method = \"post\" action = \"admin.php?act=create_cat\">\n";
                            echo "<tr><td>Catagory Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";
                            echo "<tr><td>Admin Only?</td><td><input type\"checkbox\" name=\"admin\" value =\"1\"></td></tr>\n";
    					echo "<tr><td colspan=\"2\" align=\"right\"><input type\"submit\" name=\"submit\" value=\"Create Catagory\"></td></tr>";
    					echo "</form></table>";

  7. I got the following code:

     

     

    if (isset($_POST['submit'])){
    $pic = $_FILES['imagefile']['name'];
    $wantedname = $_POST['name'];
    
    $target_path = "images\cat\images";
    
    $target_path = $target_path . basename( $_FILES['file']['name']); 
    
    $name = basename( $_FILES['file']['name']);
    

     

    So im putting $target_path into the database. The picture name is So cute.jpg when i look at in the database it shows this:

     

     

    imagescatimagesso cute.jpg

     

    Theres no slashes in it but there was before it went into the database. Anyone know why?

  8. i noticed the user issue before you replied actually, if you looks its been updated to an already declared variable.

     

    and I want to get my page working before i worry about protecting it.

     

    any idea on why it still dosnt work?

  9. Im making a sort of admin protected area on my site so after the user enters the info and clicks submit it runs this code:

     

    <?php
    include("Connect.php");
    
    if(isset($_POST['submit'])){
    $name = $_POST['name'];
    
    $pass = md5($_POST['password']);
    
    
    $sql = "SELECT * FROM accounts WHERE username = '$name' AND password = '$pass'";
    $result = mysql_query($sql);
    $row = mysql_num_rows($result);
    
    if ($row > 0){
    $_SESSION['user'] = $name;
    header("Location: index.php");
    
    }else{
    header("Location: login.php");
    }
    }
    
    ?>

     

    that runs fine and i get directed to the index.php page. When i click on one of the links to go to another page though it sends me back to the login page and acts as if there was no session. The code on these pages is:

     

    <?php
    
    session_start();
    if (!$_SESSION['user']){
    header("Location: login.php");
    }
    ?>

     

    anyone know why my users can login but not view the protected pages?

  10. So i got a script that should upload a resized image and then throw some data in a database however im getting the following error;

     

    Unknown column 'random' in 'field list'

     

    Im not sure what its doing this i tried running the query through phpmyadmin and i was able to do it. Also i dont know why its skippin the if statment that checks to see if file is null either because i went through browse and selected a file. Anyway heres the code:

     

    <?php
    include ("connect.php");
    
    if (isset($_POST['submit'])){
    $pic = $_POST['file'];
    $name = $_POST['name'];
    
    if ($_POST['file'] != NULL){
    
    $idir = "./images/";   // Path To Images Directory
    $tdir = "./images/thumbs/";   // Path To Thumbnails Directory
    $twidth = "125";   // Maximum Width For Thumbnail Images
    $theight = "84";   // Maximum Height For Thumbnail Images
    
     $url = $_FILES['imagefile']['name'];   // Set $url To Equal The Filename For Later Use
      if ($_FILES['imagefile']['type'] == "image/jpg" || $_FILES['imagefile']['type'] == "image/jpeg" || $_FILES['imagefile']['type'] == "image/pjpeg") {
        $file_ext = strrchr($_FILES['imagefile']['name'], '.');   // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php
        $copy = copy($_FILES['imagefile']['tmp_name'], "$idir" . $_FILES['imagefile']['name']);   // Move Image From Temporary Location To Permanent Location 
    $path = "$idir" . $_FILES['imagefile']['name'];
    $desc = $_POST['desc'];
        $thpath = "$tdir" . $_FILES['imagefile']['name'];
    
        if ($copy) {   // If The Script Was Able To Copy The Image To It's Permanent Location
         // print 'Image uploaded successfully.<br />';   // Was Able To Successfully Upload Image
          $simg = imagecreatefromjpeg("$idir" . $url);   // Make A New Temporary Image To Create The Thumbanil From
          $currwidth = imagesx($simg);   // Current Image Width
          $currheight = imagesy($simg);   // Current Image Height
          if ($currheight > $currwidth) {   // If Height Is Greater Than Width
             $zoom = $twidth / $currheight;   // Length Ratio For Width
             $newheight = 100;   // Height Is Equal To Max Height
             $newwidth = 150;   // Creates The New Width
          } else {    // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height)
            $zoom = $twidth / $currwidth;   // Length Ratio For Height
            $newwidth = 150;   // Width Is Equal To Max Width
            $newheight = 100;   // Creates The New Height
          }
          $dimg = imagecreate($newwidth, $newheight);   // Make New Image For Thumbnail
          imagetruecolortopalette($simg, false, 256);   // Create New Color Pallete
          $palsize = ImageColorsTotal($simg);
          for ($i = 0; $i < $palsize; $i++) {   // Counting Colors In The Image
           $colors = ImageColorsForIndex($simg, $i);   // Number Of Colors Used
           ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);   // Tell The Server What Colors This Image Will Use
          }
          imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);   // Copy Resized Image To The New Image (So We Can Save It)
          imagejpeg($dimg, "$tdir" . $url);   // Saving The Image
          imagedestroy($simg);   // Destroying The Temporary Image
          imagedestroy($dimg);   // Destroying The Other Temporary Image
    //  die($name);
    $sql = "INSERT INTO catagories (Name,picture,thumb) VALUES ('$name','$path','$thpath')";
    mysql_query ($sql) or die (mysql_error());?>
    <script type="text/javascript">
    <!--
    alert ("Item Added Sucsesfully.")
    // -->
    </script> <?php
        } else {
          print '<font color="#FF0000">ERROR: Unable to upload image.</font>';   // Error Message If Upload Failed
        }
      } else {
        print '<tr><td><font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is </td></tr>';   // Error Message If Filetype Is Wrong
        print $file_ext;   // Show The Invalid File's Extention
        print '.</font>';
      } 
    
    }else{
    //die($name);
    $sql = "INSERT INTO catagories (Name) VALUES ($name)";
    mysql_query($sql) or die (mysql_error());
    }
    
    }
    ?>

  11. I have an XML file that i need to read write and delete things from i've been looking around at tutorials but they all look really long and not really achomplish what i need is there an easier way??

     

    <?xml version="1.0" encoding="UTF-8"?>
    <slideshow maxImageWidth="480" maxImageHeight="480" textColor="0xFFFFFF" frameColor="0xFFFFFF" frameWidth="20" stagePadding="40" navPadding="40" thumbnailColumns="3" thumbnailRows="3" navPosition="left" vAlign="center" hAlign="center" title="C & A Steak House" enableRightClickOpen="true" backgroundImagePath="" imagePath="" thumbPath="">
    <image>
    <filename>tall.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>wide.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>tall.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>wide.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>tall.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>wide.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>tall.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>wide.jpg</filename>
    <caption></caption>	
    </image>
    <image>
    <filename>tall.jpg</filename>
    <caption></caption>	
    </image>
    </slideshow>

  12. Im getting the following error on a page:

     

    Warning: getimagesize(/images/product029.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/schoolw1/public_html/showproduct.php on line 111

     

    the url is: http://schoolworkanswers.com/showproduct.php?id=86 and if you add /images/product029.jpg after the schoolworkanswers.com/ it brings you to the picture so i dont know why its not working ill post my code below and i'd appriciate if somone could tell me what im doing wrong.

     

    <?php
    	//take the .. off the first slash in the path
    			$path = str_replace("..","",$pd_path);
    			//set the width and hight to vars
    			list($w, $h) = getimagesize($path);
    			//is the width bigger then our table?
    			if ($w < 660){
    	echo "<td align=center><img src=$pd_path width= height= alt=><td>";
    	}else{
    	//this one resizes the width of the pic so the table dosnt expand.
    echo "<td align=center><img src=$pd_path width=650 alt=><td>";		
    
    	}
    
    
    
    ?>

  13. So u want the admin to recive the email aswell, or just the admin to recive the email?

     

     

     

     

     

     

     

    This post is just simply for my eyes:

     

    <?php
    class Postman
    {
       var $mAdminEmail = ADMIN_EMAIL;
       
       function __construct()
       { }
    
       // Send a job post to a friend
       public function MailSendToFriend($friend_email, $my_email)
       {
          $subject = 'I\'m recommending you a job ad';
          $msg = $_SERVER['HTTP_REFERER'];
          $msg .= "\n\n---\nYou've received this e-mail from " . $my_email;
    
          if ($friend_email != '' && $my_email != '' && validate_email($friend_email) && validate_email($my_email))
          {
             if (mail($friend_email, $subject, $msg, 'From: ' . $my_email))
             {
                return true;
             }
             else
             {
                return false;
             }
          }
          else
          {
             return false;
          }
       }
       
       // Send email to company when applying online
       public function MailApplyOnline($data)
       {
          $extra = '\n\n---\nThis e-mail is an application sent from ' . $_SERVER['HTTP_REFERER'];
       
          $mail = new PHPMailer();
    
          $mail->From     = stripslashes($data['apply_email']);
          $mail->FromName = stripslashes($data['apply_name']);
    
        $mail->Body    = str_replace(array('\r\n', '\r', '\n'), '<br />', stripslashes($data['apply_msg']) . $extra);
        $mail->AltBody = $data['apply_msg'] . $extra;
          $mail->Subject = "[" . SITE_NAME . "] I wish to apply for '" . $data['job_title'] . "'";
        $mail->AddAddress($data['company_email'], $data['company_name']);
          if ($data['attachment_path'])
          {
           $mail->AddAttachment($data['attachment_path'], $data['attachment_filename']);
          }
    
          if ($mail->Send())
          {
             return true;
          }
          else
          {
             return false;
          }
       }
       
       // Send mail to admin when a job is posted
       public function MailPublishToAdmin($data)
       {
          $msg = '';
          $job_title = BASE_URL . 'job/' . $data['id'] . '/' . $data['url_title'] . '/';
          $subject = "[" . SITE_NAME . "]" . $job_title;
          
          if ($data['check_poster_email'] == 0)
          {
             $msg .= "Activate ad: " . BASE_URL . "activate/" . $data['id'] . "/" . $data['auth'] . "/";
             $msg .= "\n\n\n";
          }
          $msg .= $job_title;
          $msg .= "\n\n" . $data['title'] . " at " . $data['company'];
          $msg .= "\n\n" . $data['description'];
          $msg .= "\n\nURL: " . $data['url'];
          $msg .= "\n\n---\Published by: " . $data['poster_email'];
          $msg .= "\n---\nEdit: " . BASE_URL . "post/" . $data['id'] . "/" . $data['auth'] . "/";
          $msg .= "\nDeactivate: " . BASE_URL . "deactivate/" . $data['id'] . "/" . $data['auth'] . "/";
          $msg .= "\n\n---\nIP: " . $_SERVER['REMOTE_ADDR'];
          $msg .= "\nDate: " . $data['created_on'];
          mail(NOTIFY_EMAIL, $subject, $msg, "From: " . SITE_NAME . " <" . NOTIFY_EMAIL . ">");
       }
    
    ?>
    

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