Jump to content

gigido

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by gigido

  1. ah.. that makes sence... thanks!
  2. hi, i have a mysql query that returns a list of names . I want to make it so when you click the name, it brings you to another page and displays the reset of the information stored in the database for that name. Just wanted to know the process of making that happen.
  3. perfect, thanks for the insight.... very helpful.
  4. hi, i have this statement ("SELECT * FROM `listings` WHERE year= \"".$_POST['year']."\" or type =\"".$_POST['type']."\" and title LIKE \"". $_POST['title'] ."\"") now these values are populated by an html form with 2 drop down menus and one title text search field. the issue is getting the results to search for all the entries when the drop down isnt selected. As of now its been searching for value ="" I basicaly am trying to give the user 3 ways of searching, and the ability to use all 3 options at once to get more refined results. Im not sure if the "OR" is the right thing to be using in this situation. thanks.
  5. Thanks all for the help.. problem solved...
  6. im starting to think its the way im handling and displaying my results... when i remove the while ($row = mysql_fetch_array($sql)) { $title2 = $row['title'] ; echo "<b>title:</b> $title2 <br>"; } or only have my retrieval statement the errors go away.
  7. arrr... nope... really doesnt make much sence why it wouldnt. but same error .
  8. hmmm negative.. this comes up with that same error.
  9. un certain, but will give it a try, however just to be sure i took out searching for title and using LIKE until i can isolate the cause. But with taking out the title line, i still get that same error.
  10. makes perfect sence. thank you for clarifying. umm... still getting an error of "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" heres what the code is: $result = mysql_query ("SELECT * FROM `listings` WHERE number= ".$_POST['number']." or state =".$_POST['state']." and title LIKE ". $_POST['title'] .""); while ($row = mysql_fetch_array($result)) { $title = $row['title'] ; echo "<center>title: <b>".$row['title']."</b></center>"; } also changed it to just $row = mysql_fetch_array($result)) as opposed to the while statement, and also had an error.
  11. there are no null values in my database, but are you saying when i us the "or" it will ignore any fields that are left blank? cause if it was "select from the table where title= 1 or number = 2"... I would only want the value returned that would have the same number and title.... not values that have 1 or the other.
  12. hi, i dont see a need for java or validation. its a drop down menu, so its okay to have an empty value <select name="state" id="state"> <option value=""></option> <option value="ma">ma</option> <option value="ca">nh</option> <option value="nh">nh</option> <option value="vt">vt</option> </select> number: <select name="number" id="number"> <option value="*"></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input name="title" type="text" id="title" /> <input name="Search" type="submit" id="Search" value="search" /> </div> </label> </form> the php $result = mysql_query ("SELECT * FROM listings WHERE state= ".$_POST['state']." and number =".$_POST['number]." and title = ".$_POST['title']."" ); so you have option to select a state, number from a drop down menu, as well as search via the text search .. so if you just want to search by state you select state from the drop down menu and the other values remain empty. so for my query to search the database i get an error if the values are empty. so how do a make it so when the drop down menu is empty that its not searching for an empty value in my database.
  13. hi i have 3 drop down fields, when a drop down is left blank (which i have given no value, so "") i seem to get an error on my search results. how do i make it so when there is no value in one of the fields that all values are retrieved for that particular drop down menu, so that its not searching for "" .
  14. Hi i have a page where i want 3 links for instance. option 1, option 2, option 3 . Whats the best way to have it so when you click option 1 , that a particuar MYSQL search occurs displaying certain information on the page, and when option 2 is clicked it would display something else , and so on.... I take it i need to attach a hyperlink to the text? if thats being the case how abouts does that work, i'm unfamiliar with making a variable or mysql link like so. thanks!
  15. um, not sure if that work for what im doing.. i just gave it a shoot and doesnt seem to fit my situation. Any other ways of doing this that you can suggest? thanks!
  16. Hi, i have an html page that is displaying the results of my query from a .php file. the results are displayed on the html page as while ($row = mysql_fetch_array($result)) { echo $row['title']."; } My question is if i were to pass along that data to another php page thats linked from this current html page, how would i pass the variable on? I tried doing a $titleresults = $row['title'] but that doesnt seem to work. any direction on how to do this would be appreciated. thanks.
  17. how about anything after the 15... anything jump out by chance?
  18. line 14-16 } // the user want to logout heres a link to a pastebin to help identify the line numbers: http://pastebin.com/m4653905e and here is the code without: <?php /* Check if a session user id exist or not. If not set redirect to login page. If the user session id exist and there's found $_GET['logout'] in the query string logout the user */ function checkUser() { // if the session id is not set, redirect to login page if ($_SESSION['isadmin'] != 1) { header('Location: ' . WEB_ROOT . 'admin/login.php'); exit; } // the user want to logout if (isset($_GET['logout']) { doLogout(); } } /* */ function doLogin() { // if we found an error save the error message in this variable $errorMessage = ''; $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // first, make sure the username & password are not empty if ($userName == '') { $errorMessage = 'You must enter your username'; } else if ($password == '') { $errorMessage = 'You must enter the password'; } else { // check the database and see if the username and password combo do match $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password = PASSWORD('$password')"; $result = dbQuery($sql); if (dbNumRows($result) == 1) { $row = dbFetchAssoc($result); $_SESSION['isadmin'] = $row['isadmin']; // log the time when the user last login $sql = "UPDATE tbl_user SET user_last_login = NOW() WHERE user_id = '{$row['user_id']}'"; dbQuery($sql); // now that the user is verified we move on to the next page // if the user had been in the admin pages before we move to // the last page visited if (isset($_SESSION['login_return_url'])) { header('Location: ' . $_SESSION['login_return_url']); exit; } else { header('Location: index.php'); exit; } } else { $errorMessage = 'Wrong username or password'; } } return $errorMessage; } /* Logout a user */ function doLogout() { if (isset($_SESSION['isadmin'])) { unset($_SESSION['isadmin']); session_unregister('isadmin'); } header('Location: login.php'); exit; } /* Generate combo box options containing the categories we have. if $catId is set then that category is selected */ function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<optgroup label=\"$name\">"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= ">{$child['name']}</option>\r\n"; } $list .= "</optgroup>"; } return $list; } /* If you want to be able to add products to the first level category replace the above function with the one below */ /* function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<option value=\"$key\""; if ($key == $catId) { $list.= " selected"; } $list .= ">$name</option>\r\n"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= "> {$child['name']}</option>\r\n"; } } return $list; } */ /* Create a thumbnail of $srcFile and save it to $destFile. The thumbnail will be $width pixels. */ function createThumbnail($srcFile, $destFile, $width, $quality = 75) { $thumbnail = ''; if (file_exists($srcFile) && isset($destFile)) { $size = getimagesize($srcFile); $w = number_format($width, 0, ',', ''); $h = number_format(($size[1] / $size[0]) * $width, 0, ',', ''); $thumbnail = copyImage($srcFile, $destFile, $w, $h, $quality); } // return the thumbnail file name on sucess or blank on fail return basename($thumbnail); } /* Copy an image to a destination file. The destination image size will be $w X $h pixels */ function copyImage($srcFile, $destFile, $w, $h, $quality = 75) { $tmpSrc = pathinfo(strtolower($srcFile)); $tmpDest = pathinfo(strtolower($destFile)); $size = getimagesize($srcFile); if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } elseif ($tmpDest['extension'] == "png") { $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } else { return false; } switch($size[2]) { case 1: //GIF $src = imagecreatefromgif($srcFile); break; case 2: //JPEG $src = imagecreatefromjpeg($srcFile); break; case 3: //PNG $src = imagecreatefrompng($srcFile); break; default: return false; break; } imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); switch($size[2]) { case 1: case 2: imagejpeg($dest,$destFile, $quality); break; case 3: imagepng($dest,$destFile); } return $destFile; } /* Create the paging links */ function getPagingNav($sql, $pageNum, $rowsPerPage, $queryString = '') { $result = mysql_query($sql) or die('Error, query failed. ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page{$queryString}\">[Prev]</a> "; $first = " <a href=\"$self?page=1{$queryString}\">[First Page]</a> "; } else { $prev = ' [Prev] '; // we're on page one, don't enable 'previous' link $first = ' [First Page] '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page{$queryString}\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage{$queryString}{$queryString}\">[Last Page]</a> "; } else { $next = ' [Next] '; // we're on the last page, don't enable 'next' link $last = ' [Last Page] '; // nor 'last page' link } // return the page navigation link return $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last; } ?>
  19. thanks! I do believe that is part of the problem, as i removed the extra parenthesis from line 11 and again on line 17, however when i did that a new problem occurred. Parse error: syntax error, unexpected '{' in /Applications/xampp/xamppfiles/htdocs/tv/admin/library/functions.php on line 15 which happens to be a line of nothing.
  20. Hi, i keep getting an error on line 11 when I run this page. from first glance I cant seem to see anything wrong with it, I was wondering if someone could take a look at it and see otherwise. thanks! line 11 happens to be: "if ($_SESSION['isadmin'] != 1)) {" The error i get is "Parse error: syntax error, unexpected ')' in /Applications/xampp/xamppfiles/htdocs/tv/admin/library/functions.php on line 11" <?php /* Check if a session user id exist or not. If not set redirect to login page. If the user session id exist and there's found $_GET['logout'] in the query string logout the user */ function checkUser() { // if the session id is not set, redirect to login page if ($_SESSION['isadmin'] != 1)) { header('Location: ' . WEB_ROOT . 'admin/login.php'); exit; } // the user want to logout if (isset($_GET['logout'])) { doLogout(); } } /* */ function doLogin() { // if we found an error save the error message in this variable $errorMessage = ''; $userName = $_POST['txtUserName']; $password = $_POST['txtPassword']; // first, make sure the username & password are not empty if ($userName == '') { $errorMessage = 'You must enter your username'; } else if ($password == '') { $errorMessage = 'You must enter the password'; } else { // check the database and see if the username and password combo do match $sql = "SELECT user_id FROM tbl_user WHERE user_name = '$userName' AND user_password = PASSWORD('$password')"; $result = dbQuery($sql); if (dbNumRows($result) == 1) { $row = dbFetchAssoc($result); $_SESSION['isadmin'] = $row['isadmin']; // log the time when the user last login $sql = "UPDATE tbl_user SET user_last_login = NOW() WHERE user_id = '{$row['user_id']}'"; dbQuery($sql); // now that the user is verified we move on to the next page // if the user had been in the admin pages before we move to // the last page visited if (isset($_SESSION['login_return_url'])) { header('Location: ' . $_SESSION['login_return_url']); exit; } else { header('Location: index.php'); exit; } } else { $errorMessage = 'Wrong username or password'; } } return $errorMessage; } /* Logout a user */ function doLogout() { if (isset($_SESSION['isadmin'])) { unset($_SESSION['isadmin']); session_unregister('isadmin'); } header('Location: login.php'); exit; } /* Generate combo box options containing the categories we have. if $catId is set then that category is selected */ function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<optgroup label=\"$name\">"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= ">{$child['name']}</option>\r\n"; } $list .= "</optgroup>"; } return $list; } /* If you want to be able to add products to the first level category replace the above function with the one below */ /* function buildCategoryOptions($catId = 0) { $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<option value=\"$key\""; if ($key == $catId) { $list.= " selected"; } $list .= ">$name</option>\r\n"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= "> {$child['name']}</option>\r\n"; } } return $list; } */ /* Create a thumbnail of $srcFile and save it to $destFile. The thumbnail will be $width pixels. */ function createThumbnail($srcFile, $destFile, $width, $quality = 75) { $thumbnail = ''; if (file_exists($srcFile) && isset($destFile)) { $size = getimagesize($srcFile); $w = number_format($width, 0, ',', ''); $h = number_format(($size[1] / $size[0]) * $width, 0, ',', ''); $thumbnail = copyImage($srcFile, $destFile, $w, $h, $quality); } // return the thumbnail file name on sucess or blank on fail return basename($thumbnail); } /* Copy an image to a destination file. The destination image size will be $w X $h pixels */ function copyImage($srcFile, $destFile, $w, $h, $quality = 75) { $tmpSrc = pathinfo(strtolower($srcFile)); $tmpDest = pathinfo(strtolower($destFile)); $size = getimagesize($srcFile); if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } elseif ($tmpDest['extension'] == "png") { $dest = imagecreatetruecolor($w, $h); imageantialias($dest, TRUE); } else { return false; } switch($size[2]) { case 1: //GIF $src = imagecreatefromgif($srcFile); break; case 2: //JPEG $src = imagecreatefromjpeg($srcFile); break; case 3: //PNG $src = imagecreatefrompng($srcFile); break; default: return false; break; } imagecopyresampled($dest, $src, 0, 0, 0, 0, $w, $h, $size[0], $size[1]); switch($size[2]) { case 1: case 2: imagejpeg($dest,$destFile, $quality); break; case 3: imagepng($dest,$destFile); } return $destFile; } /* Create the paging links */ function getPagingNav($sql, $pageNum, $rowsPerPage, $queryString = '') { $result = mysql_query($sql) or die('Error, query failed. ' . mysql_error()); $row = mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; // how many pages we have when using paging? $maxPage = ceil($numrows/$rowsPerPage); $self = $_SERVER['PHP_SELF']; // creating 'previous' and 'next' link // plus 'first page' and 'last page' link // print 'previous' link only if we're not // on page one if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self?page=$page{$queryString}\">[Prev]</a> "; $first = " <a href=\"$self?page=1{$queryString}\">[First Page]</a> "; } else { $prev = ' [Prev] '; // we're on page one, don't enable 'previous' link $first = ' [First Page] '; // nor 'first page' link } // print 'next' link only if we're not // on the last page if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self?page=$page{$queryString}\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage{$queryString}{$queryString}\">[Last Page]</a> "; } else { $next = ' [Next] '; // we're on the last page, don't enable 'next' link $last = ' [Last Page] '; // nor 'last page' link } // return the page navigation link return $first . $prev . " Showing page <strong>$pageNum</strong> of <strong>$maxPage</strong> pages " . $next . $last; } ?>
  21. i am not asking for someone to make me a site/script, I am asking if it is actually possible to make a form do what i need it to... Looking for a yes or no, and any insight someone can provide me on the ftp form.
  22. Hi all, I currently have an upload form on my website. I want to be able to upload larger files then 3 mb's. Is it possible , or does any one know if there are any pre-existing scripts out there that will actually upload a file via ftp connection? In anycase i am still looking to have my form all connected to my database as if i were using the normal HTTP upload function. I was hoping someone could tell me if it is possilbe to create such a form. thanks!
  23. Hi, I was wonder if someone can help me make a dynamically linked box using php. I currently have it working but its using a drop down field as opposed to a list box. Here is an example of what it looks like however this one is an ASP sample.  http://www.atgconsulting.com/triplelist.asp  .  Any help would be appreciated. thanks.
×
×
  • 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.