Jump to content
Old threads will finally start getting archived ×

rik72

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rik72's Achievements

Member

Member (2/5)

0

Reputation

  1. Okay, since earlier i am still stuck with it all. <h2>Current Orders</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE order_status != 3"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client ID</th> <th>Client Name</th> <th>Invoice Number</th> <th>Status</th> <th width='300px'>Notes</th> <th>Deadline</th> <th>Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='20px'>" . $row['client_id'] . "</td>"; echo "<td width='100px'>" . $row['client_name'] . "</td>"; echo "<td width='100px'>" . $row['invoice_number'] . "</td>"; echo "<td width='200px'>"; echo "<select name='order_status' id='order_status'>"; $result2 = mysql_query("SELECT * FROM order_status"); while($row2 = mysql_fetch_array($result2)) { echo "<option value='$row2[status_id]'"; if($row2['status_id'] === $row['order_status']) { echo "selected='selected'"; } echo "> $row2[order_status] </option>"; } echo "</select></td>"; echo "<td width='300px'><textarea name='notes'>" . $row['notes'] . "</textarea></td>"; echo "<td width='100px'>" . $row['deadline'] . "</td>"; echo "<td><input name='delete' type='checkbox' value='del' /></td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> <input type="submit" name="update" id="button" value="Update Orders" /> </form> This all works but i basically need an update statement so that i can change order_status's and notes within the table. If someone could point me in the right direction of how to go about it, that would be fantastic.
  2. Error: Query was empty Thanks,
  3. I dab into PHP probably once a year for small projects and i've gone very rusty! <?php if(isset($_POST['update'])) { $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); mysql_query("UPDATE order_manager SET order_status='$_POST[order_status]'"); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<div id='red'>order updated!</div>"; mysql_close($con); } ?> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE active='1'"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client Name:</th> <th>Invoice Number:</th> <th>Status:</th> <th>Notes:</th> <th>Deadline:</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['client_name'] . "</td>"; echo "<td>" . $row['invoice_number'] . "</td>"; echo "<td>"; echo "<select name='order_status' id='order_status'>"; echo "<option value='" . $row['status'] . "' selected='selected'>Payment Received</option>"; echo "<option value='Payment Received'>Payment Received</option>"; echo " <option value='Awaiting Payment'>Awaiting Payment</option>"; echo " <option value='Stock Ordered'>Stock Ordered</option>"; echo " <option value='Awaiting Digitising'>Awaiting Digitising</option>"; echo " <option value='Processing Order'>Processing Order</option>"; echo " <option value='Waiting for email from client'>Waiting for email from client</option>"; echo "</select></td>"; echo "<td>" . $row['notes'] . "</td>"; echo "<td>" . $row['deadline'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <input type="submit" name="update" id="button" value="Submit" /> </form> I know my dropdown box isn't ideal, but I'll work on that later on, i'm basically trying to make my table update the status when i hit submit. It's an internal system so it doesn't need to be perfect, but i'm currently just getting errors.
  4. I have spent a further 20mins looking online and managed to solve my issue. This website had a good article on how to solve it! http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site
  5. Hi, I am currently writing a code to rename my pages so index.php?page=product becomes /product etc. For this i found a snippet online which seems to work great. RewriteEngine on RewriteRule ^([^/\.]+)/?$ index.php?page=$1 My problem is, i would also like to extend this so that http://url.com/product/t-shirts does not have to be http://url.com/product&product=t-shirts, i have a column in my database called product_seo which has a url friendly version of each products title which is how "t-shirts" is pulling the information on t-shirts etc. Any help would be greatly appreciated! Rik
  6. Thanks a lot, i've sorted the issue, the only thing i had to do is put mysql_close($db_handle); after the $emailCount function and it worked.
  7. It's always going to 3, it's not adding to database. I changed the code to this since then (to try and self-troubleshoot it); $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if ('$SQL2' == '$_GET[email]') { echo 3; } else { $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } Now it's getting stuck at 1 (success), but it's not checking if the email address is already in the table, which is 3. Although it is doing error check 2 successfully.
  8. Echo 1, 2, 3 is changed when it comes to the page... if (theResponse == 1) { $(".successBalloon").fadeIn("slow"); $(".successBalloon").animate({opacity: 1.0}, 3000); $(".successBalloon").fadeOut(1500); $(".resultText").html(successMessage); } if (theResponse == 2) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(invalidMailError); } if (theResponse == 3) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(duplicateMailError); }
  9. Hi, i'm basically having problems with this code, its for a newsletter script which added the email address into a file, i'm trying to convert it to work with mysql but having a few problems; I've edited the last bit, the code just basically doesn't add it to the database even though i thought i had done it right... any help is very much appreciated! If email is not valid the script is letting me know; if email is valid it says "already added to the list" no matter what. old script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $f = fopen($newsletterFileName, 'a+'); $read = fread($f,filesize($newsletterFileName)); If (strstr($read,"@")) { $delimiter = ";"; } if (strstr($read,$email)) { echo 3; } else { fwrite($f, $delimiter . $email); echo 1; } fclose($f); } else { echo 2; } ?> edited script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter WHERE email = '$_GET[email]'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if (strstr($SQL2,$email)) { echo 3; } else { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } ?>
  10. In think from this bit of code you can see what i am trying to achieve, im just not achieving it. $cont = load_template("main-content"); if ($_GET['content_id']="") { $contid = "about"; } else { $contid = $_GET['content_id']; }; thanks in advance for any help!
  11. Anyone have any ideas on my original post?
  12. Hi, on the upload of an image, im trying to add the image into 2 databases, one needs adding, one needs updating; Im using this; $sql1 = "UPDATE ".TBL_USERS." SET photo = '$pass' WHERE username = '$username'"; $sql2 = "INSERT INTO user_images (photo, username) VALUES ('$pass', '$username'"; mysql_query($sql1); mysql_query($sql2); sql1 works fine, but sql2 is doing nothing, any ideas?
  13. I have an image uploader which is causing images to stretch when they are being resized, which i do not want. I need the image to be resized 3 times and moved into 3 different folders, but i do not want the image to be scaled up if it is too big. Here is the code i'm working with; <?php include('include/session.php'); if($session->logged_in){ ini_set("session.gc_maxlifetime","10800"); ini_set("upload_max_size","4194304"); $default = $_POST["default"]; $username = $session->userinfo['username']; if(isset($_FILES)) { $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; }} # $query = "INSERT INTO track9_userphotos (pictureurl, username, caption) VALUES('$pass', '$username', '$caption')"; # mysql_query($query) or die(mysql_error()); if ( $default == 1 ) { mysql_query("UPDATE ".TBL_USERS." SET photo = '$pass' WHERE username = '$username'"); } else { echo ""; } ?> <h8>Your Uploaded Picture</h8><p><div id='header2'> <br><br> <table border="0" width="700" cellspacing="0" cellpadding="0"> <tr> <td width="200" valign="top"> <p align="center"><? echo "<img src='thimg/$pass'>"; ?></p> <p></td> <td> <p align="center"> <p align="center"> </p> </form> <p></td> </tr> </table> </div>
  14. I'm currently creating a new site out of old code and came across an old script i need help fixing; Here's what i've got; (code wise) <?php include('include/session.php'); if($session->logged_in){ ini_set("session.gc_maxlifetime","10800"); ini_set("upload_max_size","4194304"); $default = $_POST["default"]; $username = $session->userinfo['username']; if(isset($_FILES)) { $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; }} # $query = "INSERT INTO track9_userphotos (pictureurl, username, caption) VALUES('$pass', '$username', '$caption')"; # mysql_query($query) or die(mysql_error()); if ( $default == 1 ) { # $query = "UPDATE altshop_hocsite SET photo='$pass' WHERE username='$username'"; # mysql_query($query) or die(mysql_error()); } else { echo ""; } ?> <h8>Your Uploaded Picture</h8><p><div id='header2'> <br><br> <table border="0" width="700" cellspacing="0" cellpadding="0"> <tr> <td width="200" valign="top"> <p align="center"><? echo "<img src='thimg/$pass'>"; ?></p> <p></td> <td> <p align="center"> <p align="center"> </p> </form> <p></td> </tr> </table> </div> Here's what i've got; (error wise) Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/altshop/public_html/new/uploader.php on line 47 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/altshop/public_html/new/uploader.php on line 55 Your Uploaded Picture
  15. I'm getting this error; sprintf() [<a href='function.sprintf'>function.sprintf</a>]: Too few arguments in <b>/home/altshop/public_html/new/useredit.php</b> on line <b>132</b><br />
×
×
  • 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.