Jump to content

Search the Community

Showing results for tags 'mysql_select_db()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. For some reason my query is not working, mysql_select_db("UPDATE tbl_products SET p_feat='y',P_title=iPad Case, p_desc='Over the years since the launch of the iPhone and the iPad a whole ecosystem of cute little cases and stickers has sprung up to cover the svelte outlines of the Apple gadgets. Whether the case are to protect the devices, customise them or - in the case of the iPhone 4 - improve the antennae reception, Apple has always encouraged cases.' WHERE p_id='1'"); for some reason it will not update the record in the table, it does connect to the database as the rest of the page is doing what it needs to. here is the entire page code <?php session_start(); // if session is not set redirect the user if(empty($_SESSION['u_name'])) header("Location:index.html"); //if logout then destroy the session and redirect the user if(isset($_GET['logout'])) { session_destroy(); header("Location:index.html"); } else { //Connect to database from here $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_name"); } if(isset($_SERVER["REQUEST_METHOD"])=="POST") if(!isset($_GET['p_feat'])) $feat = "n"; else $feat = "y"; { mysql_select_db("UPDATE tbl_products SET p_feat='".$feat."',P_title=".$_GET['p_title'].", p_desc='".$_GET['p_desc']."' WHERE p_id='".$_GET['P_ID']."'"); } $result = mysql_error(); if (isset($_POST["Delete"])) { $file = $_REQUEST['imgfile']; $filemain = $_REQUEST['imgfilemain']; $num_files=count($file); $num_filesmain=count($filemain); for($i=0;$i<$num_files;$i++) { unlink ("$file[$i]"); unlink ("$filemain[$i]"); } } if (!is_dir('../uploads/'.$_GET['P_ID'].'')) { mkdir('../uploads/'.$_GET['P_ID'].''); } if (!is_dir('../uploads/'.$_GET['P_ID'].'/thumbs')) { mkdir('../uploads/'.$_GET['P_ID'].'/thumbs'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/admin-main.css" rel="stylesheet" type="text/css"> <link href="css/jquery.validate.css" rel="stylesheet" type="text/css"> <link href="css/style.css" rel="stylesheet" type="text/css"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script src="js/jquery.validate.js" type="text/javascript"></script> <script src="js/validatefields.js" type="text/javascript"></script> </head> <body> <div class="container"> <div class="logo"> <img src="images/logo.png" /> </div> <div class="content"> <div class="left"> <?php $result = mysql_query("SELECT * FROM tbl_cats"); while($row = mysql_fetch_array($result)) { echo "<a href='secure.php?CAT_ID=" . $row['cat_id'] . "'>" . $row['cat_title'] . "</a>"; echo "<br />"; } ?> </div> <div class="page-modify"> <?php if(isset($_GET['CAT_ID'])) { $result = mysql_query("SELECT * FROM tbl_cats inner join tbl_products p on p.p_catlink = " . $_REQUEST['CAT_ID'] . " where cat_id = P_catlink and cat_id = " . $_GET['CAT_ID'] . ""); while($row = mysql_fetch_array($result)) echo "<p><a href='secure.php'><u>Main</u></a> > <a href='secure.php?CAT_ID=" . $_REQUEST['CAT_ID'] . "'><u>" . $row['cat_title'] . "</u></a> > " . $row['p_title'] . "</p>"; echo "<p><b>Step 2: Product Images</b></p>"; echo "<div class='TabBody'>"; if (isset($_POST["submit"])) { if (isset($_POST["submit"])) { $uploadpath = "../uploads/".$_GET['P_ID']."/"; $uploadpath = $uploadpath.basename($_FILES["imgfile"]["name"]); if (!move_uploaded_file($_FILES["imgfile"]["tmp_name"], $uploadpath)) die("There was an error uploading the file, please try again!"); $image_name = "../uploads/".$_GET['P_ID']."/".$_FILES["imgfile"]["name"]; list($width,$height) = getimagesize($image_name); $new_image_name = "../uploads/".$_GET['P_ID']."/thumbs/thumb_".$_FILES["imgfile"]["name"]; if ($width > $height) { $ratio = (75/$width); $new_width = round($width*$ratio); $new_height = round($height*$ratio); } else { $ratio = (75/$height); $new_width = round($width*$ratio); $new_height = round($height*$ratio); } $image_p = imagecreatetruecolor($new_width,$new_height); $img_ext = $_FILES['imgfile']['type']; if ($img_ext == "image/jpg" || $img_ext == "image/jpeg") { $image = imagecreatefromjpeg($image_name); } else if ($img_ext == "image/png") { $image = imagecreatefrompng($image_name); } else if ($img_ext == "image/gif") { $image = imagecreatefromgif($image_name); } else { die('this is no valid image resource'); } imagecopyresampled($image_p,$image,0,0,0,0,$new_width,$new_height,$width,$height); imagejpeg($image_p,$new_image_name,100); } imagecopyresampled($image_p,$image,0,0,0,0,$new_width,$new_height,$width,$height); imagejpeg($image_p,$new_image_name,100); } ?> <form method="post" enctype="multipart/form-data"> Please select a picture to upload:<br /> <input type="file" name="imgfile" /> <br /> <input type="submit" name="submit" value="Add Image" /> </form> <hr /> <form method="post" action=""> <?php //lets assign the folder name in $title //You can assign any name $title= "../uploads/".$_GET['P_ID']; /*$directory corresponds to whole path. Edit to your preference. (i assume u store your images in directory named "images") */ $directory = "$title"; //The array specifies the format of the files $allowed_types=array('jpg','jpeg','gif','png'); $file_parts=array(); $ext=''; $title=''; $i=0; $dir_handle = @opendir($directory) or die("There is an error with your image directory!"); while ($file = readdir($dir_handle)) { if($file=='.' || $file == '..') continue; $file_parts = explode('.',$file); $ext = strtolower(array_pop($file_parts)); $title = implode('.',$file_parts); $title = htmlspecialchars($title); $nomargin=''; if(in_array($ext,$allowed_types)) { if(($i+1)%4==0) $nomargin='nomargin'; echo' <div id="picture" style="float:left;"> <img src="../uploads/'.$_GET['P_ID'].'/thumbs/thumb_'.$file.'"><br> Select <input type="checkbox" value="'.$directory.'/'.$file.'" name="imgfile[]"> <input type="hidden" value="'.$directory.'/thumbs/thumb_'.$file.'" name="imgfilemain[]"> </div>'; } $i++; } closedir($dir_handle); //Now we have the list of images within form elements ?><div class="clearboth"><br /></div> <input type="submit" value="Delete" name="Delete"> </form> <div class="clearboth"></div> <?php echo "</div>"; echo "</div>"; echo "</div>"; } ?> <div class="clearboth"></div> </div> </div> <div id="footer"><a href="secure.php?logout"><b>Logout</b></a></div> </body> </html> im not getting any errors or anything its just not updating the database, any ideas?
×
×
  • 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.