Jump to content

azukah

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by azukah

  1. I have 2 tables (see code below) (1) "tbl_users" has all users info, including "user_alias" (VARCHAR) and "user_id" (INT and PRIMARY KEY) (2) "tbl_projects" has all project info, including "project_client" (INT) which i linked to "user_id" from "tbl_users" and displays "user_alias" CREATE TABLE `tbl_users` ( `user_id` int(11) NOT NULL auto_increment, `user_first` varchar(25) NOT NULL, `user_last` varchar(25) NOT NULL, `user_email` varchar(35) NOT NULL, `user_pw` varchar(12) NOT NULL, `user_role` int(1) NOT NULL, `user_alias` varchar(35) NOT NULL, PRIMARY KEY (`user_id`) ) CREATE TABLE `tbl_projects` ( `project_id` int(11) NOT NULL auto_increment, `project_client` int(1) NOT NULL, PRIMARY KEY (`project_id`) ) So... I managed to display all users and all projects but I want to show all users with ONLY their projects assigned. I mean, when I click on a user, I want to see his or hers contact info and all the projects that specific user is linked to. For instance, i might have project 1, project 2, project 3 and project 4. Project 1, 2 and 4 are linked to user 1 so when i click on user 1 i see projects 1, 2 and 3 (not 4). <?php require_once('config.php'); mysql_select_db($database, $makeconnection); //this displays all projects $sql_get_projects="SELECT * FROM tbl_projects ORDER BY project_id ASC"; $get_projects = mysql_query($sql_get_projects, $makeconnection) or die(mysql_error()); $row_get_roles = mysql_fetch_assoc($get_projects); $totalRows_get_projects = mysql_num_rows($get_projects); //this displays all users $sql_find_users = "SELECT * FROM tbl_users WHERE user_id = $user_id"; $find_users = mysql_query($sql_find_users, $makeconnection) or die(mysql_error()); $row_get_users = mysql_fetch_assoc($find_users); $totalRows = mysql_num_rows($find_users); ?> Any help would be great!!
  2. I had my quotes all wrong .. fixed it ) <?php require('cms/config.php'); mysql_select_db($database, $makeconnection); $sql_get_reviews = "SELECT * FROM tbl_reviews WHERE review_pending='0' ORDER BY review_stamp DESC LIMIT 7"; $get_reviews = mysql_query($sql_get_reviews, $makeconnection) or die(mysql_error()); $row_get_reviews = mysql_fetch_assoc($get_reviews); $totalRows_get_reviews = mysql_num_rows($get_reviews); echo '<?xml version="1.0" encoding="UTF-8"?> <xmlList err="0" str="">'; do { $name = $row_get_reviews['review_shampoo']; $type = $row_get_reviews['review_brand']; $img = $row_get_reviews['review_img']; ; echo '<item review="'.$name.'" desc="'.$type.'" img="'.$img.'"/>'; }while ($row_get_reviews = mysql_fetch_assoc($get_reviews)); mysql_close(); echo '</xmlList>'; ?>
  3. i'm trying to get this php file show as xml and... the echo part is not coming up correct. it all comes as one thing instead of 3 attributes <item review='.$subject.' desc='.$short_description.' img='.$review_img.'/> here's teh complete code... <?php require_once('cms/config.php'); mysql_select_db($database, $makeconnection); $sql_get_reviews = "SELECT * FROM tbl_reviews WHERE review_pending='0' ORDER BY review_stamp DESC LIMIT 7"; $get_reviews = mysql_query($sql_get_reviews, $makeconnection) or die(mysql_error()); $row_get_reviews = mysql_fetch_assoc($get_reviews); $totalRows_get_reviews = mysql_num_rows($get_reviews); echo '<?xml version="1.0" encoding="UTF-8"?> <xmlList err="0" str="">'; do { $subject = $row_get_reviews['review_shampoo'].' reviewed by '.$row_get_reviews['review_author']; $description = $row_get_reviews['review_desc']; $description = str_replace ("&amp","",htmlspecialchars(strip_tags($description))); //clean the description $short_description = substr($description,5) . "..."; $review_img = $row_get_reviews['review_img']; ; echo ' <item review='.$subject.' desc='.$short_description.' img='.$review_img.'/> '; }while ($row_get_reviews = mysql_fetch_assoc($get_reviews)); mysql_close(); echo '</xmlList>'; ?>
  4. this code works but wondering if there's an easier/cleaner way. the code redirect to 2 pages based on the user_role and if credentials r wrong it sends u back to the same login screen with a msg. <?php if (!isset($_SESSION)) { session_start();} require_once('config.php'); $now=time(); $message= $_GET['message']; if (isset($_POST['user_email'])) { $user_email=$_POST['user_email']; $user_pw=$_POST['user_pw']; mysql_select_db($database, $makeconnection); $admin="SELECT * FROM tbl_users WHERE user_email='$user_email' AND user_role='1' AND user_pw='$user_pw'"; $client="SELECT * FROM tbl_users WHERE user_email='$user_email' AND user_role='6' AND user_pw='$user_pw'"; //check that at least one row was returned $adminresult=mysql_query($admin); $admincount = mysql_num_rows($adminresult); $clientresult=mysql_query($client); $clientcount = mysql_num_rows($clientresult); //if found, start session & redirect if($admincount> 0){ $_SESSION['session_user_email'] = $user_email; $_SESSION['session_start'] = time(); header( "Location: index.php" ); } else if($clientcount> 0){ $_SESSION['session_user_email'] = $user_email; $_SESSION['session_start'] = time(); header( "Location: test.php" ); //wrong credentials redirect } else { header("Location: login.php?message=loginfailed"); } } ?>
  5. @jcbones - I tried both ways and didn't work
  6. i have this code to change $greeting based on the URL. if the URL contains ../es or ../it, $greeting will change to the appropriate language greeting. <?php switch( dirname( $_SERVER['PHP_SELF'])) { case '/es': $greeting = 'Hola!'; break; case '/it': $greeting = 'Ciao!'; break; default: $greeting = 'Hello!'; break; } ?> //here's the actual line where I call $greeting <li><a class="home" href="index.php"><?php echo $greeting; ?></a></li> the code shows "Hello!" which is the default only. regardless of the folder I am in (".../es" or ".../it").. ay ideas??
  7. what's the best way to have a website in 2 languages? I already have the website duplicated in the 2nd language but I'm thinking on the best way to do the language change. should I just append variables to the URL when clicking on the flag icon on each page to change to the 2nd language? any other ideas??
  8. you are right . I missed it. i'm GETting 'quote' from another page and i misspelled it - thanks !!!
  9. i get errors n the value fields in the form (where i'm echoing) <br /> <b>Notice</b>: Undefined variable: row in <b>/hermes/web03/b443/moo.azukah/project_dorimingu/cms/cms_quote/quote_modify.php</b> on line <b>70</b><br /> <br /> <b>Notice</b>: Undefined variable: row in <b>/hermes/web03/b443/moo.azukah/project_dorimingu/cms/cms_quote/quote_modify.php</b> on line <b>72</b><br />
  10. hi - i'm trying to update mysql databse but not working... any ideas??? [code=php:0] <?php ob_start(); require_once('../xconfig.php'); if(isset ($_GET['quote'])&& $_GET['quote']!=""){ $quote_id=$_GET['quote']; mysql_select_db($database, $makeconnection); $sql_find_quote = "SELECT * FROM tbl_quote WHERE quote_id = $quote_id"; $find_quote = mysql_query($sql_find_quote, $makeconnection) or die(mysql_error()); $row = mysql_fetch_assoc($find_quote); $totalRows = mysql_num_rows($find_quote); $quote_author = $_POST['quote_author']; $quote_desc = $_POST['quote_desc']; if (isset($_POST['submitted'])&&($_POST['submitted'] == "yes")) { $register_query = "SELECT quote_desc FROM tbl_quote WHERE quote_desc='$quote_desc'"; mysql_select_db($database, $makeconnection); $register_check=mysql_query($register_query, $makeconnection); $register_found_quote = mysql_num_rows($register_check); if($register_found_quote>1){ header ("Location: quote_modify.php?error=quoteexists&quote=$quote_id"); }else{ $sql_modify = "UPDATE tbl_quote SET quote_desc = '$quote_desc' quote_author = '$quote_author' WHERE quote_id = '$quote_id'"; } mysql_select_db($database, $makeconnection); $Result1 = mysql_query($sql_modify, $makeconnection) or die(mysql_error()); header ("Location: quote.php"); } } ob_flush(); ?> [/code] here's my HTML form <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <p> <input name="quote_author" type="text" class="active-field" id="quote_author" value="<? echo $row['quote_author'];?>"/> <br /> <input name="quote_desc" type="text" class="active-field" id="quote_desc" value="<? echo $row['quote_desc'];?>" /> <br /> <input name="submitted" type="hidden" id="submitted" value="yes" /> <input name="submit" type="submit" id="submit" class="submit-button" value="modiy"/> <br /> </p> </form>
  11. no, i actually typed it all (no copy+paste). no idea what was wrong.i just moved it all to a new page and it works fine - thanks all for ur help!!
  12. i did check that one too and nothing... i guess i'll check again tomorrow with fresh eyes. i can't find anything right now - thanks for the help mate! cheers.
  13. that's what i don't get ... line 1 of my index is <?php require_once('xie.php');?>
  14. yes, i did and i have no spaces or extra characters.
  15. i'm trying to use this code to detect if the browser of the user is IE (any version) and id true (if it is IE), then it's redirected to an error page; otherwise, it's ok and sent ot the index. I get the following error... Warning: Cannot modify header information - headers already sent by (output started at /index.php:1) in /xie.php on line 13 any ideas.. ??? <?php function ae_detect_ie() { if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; } if (ae_detect_ie()) { header("Location: error.php"); } else { header("Location: index.php"); } ?>
  16. would anyone know how to not only detect the browser but redirect to a different page?... once redirected to a different page, show the browser and its version and based on that, offer a link to upgrade to the newest version of that browser??? if the users have the latest version of whatever browser they are using, then no problem, they can go to the index BUT if users have earlier versions , they they are redirected to a page that offers them to upgrade to the latest of what they are using...??? Also, if mobile user, then will just use a different CSS
  17. does anybody know a way to use PHP to search a database inside specific folders and subfolders. i'm doing a knowledgebase type site and it will let users choose categories & subcategories. once those are chosen, i want to let them search with keywords inside the categories or subs (taht are actually the same as the folders and thier subs) ...?? any ideas???
  18. great! i like your version better .. thanks mate! :D
  19. i think i solved it .... i submitted a couple of times with big images and i haven't received any emails.. [code=php:0] <?php define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $errors=1; // added here $error = "<p>Sorry... only jpg, jpeg, gif and png formats are accepted!</p><p><a href='postRequest.php'>Please try again!</a></p>"; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { $errors=1; // moved it here $error = "<p>Sorry... You have exceeded the image size limit!</p><p><a href='postRequest.php'>Please try again!</a></p>"; } $image_name=time().'.'.$extension; $newname="images_board/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $errors=1; // moved it here $error = "<p>Sorry... there has been an upload error.</p><p><a href='postRequest.php'>Please try again!</a></p>"; }}}} if(isset($_POST['Submit']) && !$errors) { $error = "<p>Thank You!</p><p>Your request has been submitted</p>"; } //for email... /// $studentName=$_POST['studentName']; $studentId=$_POST['studentId']; $studentEmail=$_POST['studentEmail']; $studentPhone=$_POST['studentPhone']; $postSubject=$_POST['postSubject']; $postDescription=$_POST['postDescription']; $to='email@email.com'; $subject="Bulletin Board Request: $postSubject"; $mainbody.="Student Name: $studentName<br/><br/>"; $mainbody.="Student Id: $studentId<br><br/>"; $mainbody.="Contact email: $studentEmail<br/><br/>"; $mainbody.="Contact Phone: $studentPhone<br/><br/>"; $mainbody.="Subject: $postSubject<br/><br/>"; $mainbody.="Description: $postDescription<br/><br/>"; $mainbody.="Image: $newname<br/>"; $headers="MIME-Version: 1.0\r\n"; $headers.="Content-type:text/html;charset=utf-8\r\n"; $headers.="From: $studentName"; mail($to,$subject,$mainbody,$headers); ?> [/code]
  20. hi- I have this form that works fine: if an image is not the right format or it's too big, it tells the user the error msg and redirects them back to the form BUT it still sends the email... how do i go about sending the email ONLY if the image is the right format & it's within the size limit..??? <?php define ("MAX_SIZE","100"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $errors=0; if(isset($_POST['Submit'])) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $error = "<p>Sorry... only jpg, jpeg, gif and png formats are accepted!</p><p><a href='postRequest.php'>Please try again!</a></p>"; } else { $size=filesize($_FILES['image']['tmp_name']); if ($size > MAX_SIZE*1024) { $error = "<p>Sorry... You have exceeded the image size limit!</p><p><a href='postRequest.php'>Please try again!</a></p>"; $errors=1; } $image_name=time().'.'.$extension; $newname="images_board/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $error = "<p>Sorry... there has been an upload error.</p><p><a href='postRequest.php'>Please try again!</a></p>"; $errors=1; }}}} if(isset($_POST['Submit']) && !$errors) { $error = "<p>Thank You!</p><p>Your request has been submitted</p>"; } //for email... /// $studentName=$_POST['studentName']; $studentId=$_POST['studentId']; $studentEmail=$_POST['studentEmail']; $studentPhone=$_POST['studentPhone']; $postSubject=$_POST['postSubject']; $postDescription=$_POST['postDescription']; $to='email@email.com'; $subject="Bulletin Board Request: $postSubject"; $mainbody.="Student Name: $studentName<br/><br/>"; $mainbody.="Student Id: $studentId<br><br/>"; $mainbody.="Contact email: $studentEmail<br/><br/>"; $mainbody.="Contact Phone: $studentPhone<br/><br/>"; $mainbody.="Subject: $postSubject<br/><br/>"; $mainbody.="Description: $postDescription<br/><br/>"; $mainbody.="Image: $newname<br/>"; $headers="MIME-Version: 1.0\r\n"; $headers.="Content-type:text/html;charset=utf-8\r\n"; $headers.="From: $studentName"; mail($to,$subject,$mainbody,$headers); ?>
  21. thanks a lot mate ..it works!! and thanks for the heads up on the code tags. i won't forget again!
  22. i checked again and i actually get the product added with the generic.jpg image BUT.... i still get an error msf on this line: $dimensions = getimagesize($originalFile['tmp_name']) if i comment the line out i don't get the error and everything is fine but the code doesn't work when i do select an image bcz i need the dimensions ...help, please?
  23. hi- this code which works fine when i select and image to upload but it doesn't work when no image is selected. the code is supposed to upload the product even if no image is selected becasue it insert the "generic.jpg" image whenever no image is selected ... make sense?? any ideas would be greatly appreciate it! i <?php function upload_prod_img(){ $originalFile= $_FILES['prod_img']; $shortname=substr($originalFile['name'], 0, -4); $timestamp=substr(time(), -4, 4); $imageNewName = $shortname.$timestamp; $dimensions = getimagesize($originalFile['tmp_name']); $desiredW= 300; if($dimensions[0]>0){ $desiredH= number_format($dimensions[1] /$dimensions[0] *$desiredW); $dest= imagecreatetruecolor($desiredW, $desiredH); imageantialias($dest, TRUE); switch($dimensions[2]) { case 1: $src = imagecreatefromgif($originalFile['tmp_name']); break; case 2: $src = imagecreatefromjpeg($originalFile['tmp_name']); break; case 3: $src = imagecreatefrompng($originalFile['tmp_name']); break; default: return false; break; } imagecopyresampled($dest, $src, 0, 0, 0, 0, $desiredW, $desiredH, $dimensions[0], $dimensions[1]); $imageNewName = strtolower($imageNewName); $imageNewName =str_replace(" ", "_",$imageNewName); $imageNewName=$imageNewName.".jpg"; $destURL="../../images/products/".$imageNewName;//PATH imagejpeg($dest,$destURL, 80); }else{ $imageNewName="generic.jpg"; } return $imageNewName; } ?>
×
×
  • 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.