Jump to content

Julian

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Julian's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello guys I'm getting the results from my database using do {} while, this is working fine. What I want to is put a number starting from 1 to each result, each record has it's unique key but I want to start from 1 with the results, example: do { echo "Number # Here" . $row_name['name'] . "<br />"; } while ($row_name = mysql_fetch_assoc($name)); Output "Number 1 Here" John "Number 2 Here" Teresa "Number 3 Here" Jamie
  2. Is not PHP is simple HTML code: <a name="ANCHOR_NAME" id="ANCHOR_NAME"></a> Just place the anchor where you want the page to land after submission.
  3. You can try with anchors
  4. It not inserting the data, and yes I'm obtaining a variable with $news
  5. I did that using js, try this code: script language="JavaScript" type="text/javascript"> <!-- function getsupport ( selectedtype ) { document.YOUR_FORM_NAME.supporttype.value = selectedtype ; document. YOUR_FORM_NAME.submit() ; } --> </script> <a href="javascript:getsupport('pass')">View popular categories</a> <input type="hidden" name="supporttype"/>
  6. Hello! I have this code to upload files, and I want to store the file names into the database, so far I have: $news = ($HTTP_GET_VARS['id_noticia']); foreach ($_FILES as $fieldName => $file) { move_uploaded_file($file['tmp_name'], "../../images/documentos/" . $file['name']); mysql_select_db($database_rcpc, $rcpc); $updateSQL = "INSERT INTO documentos (id_noticia, nombre) VALUES (".$news.",".$file['name'].")"; $update = mysql_query($updateSQL); } Files upload fine. Script to connect to db is fine also, but for some reason is not inserting... any hint? Thanks
  7. Have you tried using: SELECT DISTINCT or GROUP BY?
  8. Hi guys... Have this code: <?php error_reporting(0); define ( 'FILE_UPLOAD_DIR', '/path_to/documentos/' ); $fileObject = $_FILES ['Filedata']; $fileSize = ( double ) $fileObject ['size']; $fileName = $fileObject ['name']; $fileType = strtolower ( pathinfo ( $fileName, PATHINFO_EXTENSION ) ); $fileTempPath = $fileObject ['tmp_name']; $fileUploadPath = rtrim ( FILE_UPLOAD_DIR, '/' ) . '/' . basename ( $fileName ); if (move_uploaded_file ( $fileTempPath, $fileUploadPath )) { echo "OK"; } else { die ( "OcurriĆ³ un error al intentar cargar el archivo" ); } ?> It works with a flash uploader that waits until the "OK" to finish. After it finishes I need to continue with mysql inserts. The code works, but it doesn't finish because the other part of the code is executing. How can I make the other part of the code wait until the first part finishes? Here's the other part of the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET tipo=%s, titulo=%s, id_miembro=%s, dia=%s, mes=%s, ano=%s, status=%s, bajada=%s, principal=%s, secundario=%s, comentarios=%s, pie1=%s, pie2=%s, pie3=%s, video1=%s, pie4=%s, video2=%s, pie5=%s, audio1=%s, pie6=%s, audio2=%s, pie7=%s, documento=%s, tags=%s, title_eng=%s, keywords=%s, description=%s, belice=%s, costarica=%s, elsalvador=%s, guatemala=%s, honduras=%s, nicaragua=%s, panama=%s WHERE id_noticia=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['id_miembro'], "int"), GetSQLValueString($_POST['dia'], "int"), GetSQLValueString($_POST['mes'], "text"), GetSQLValueString($_POST['ano'], "int"), GetSQLValueString(isset($_POST['status']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['bajada'], "text"), GetSQLValueString($_POST['principal'], "text"), GetSQLValueString($_POST['secundario'], "text"), GetSQLValueString(isset($_POST['comentarios']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['pie1'], "text"), GetSQLValueString($_POST['pie2'], "text"), GetSQLValueString($_POST['pie3'], "text"), GetSQLValueString($file_new_name1, "text"), GetSQLValueString($_POST['pie4'], "text"), GetSQLValueString($file_new_name2, "text"), GetSQLValueString($_POST['pie5'], "text"), GetSQLValueString($file_new_name3, "text"), GetSQLValueString($_POST['pie6'], "text"), GetSQLValueString($file_new_name4, "text"), GetSQLValueString($_POST['pie7'], "text"), GetSQLValueString($file_new_name5, "text"), GetSQLValueString($_POST['tags'], "text"), GetSQLValueString($_POST['title_eng'], "text"), GetSQLValueString($_POST['keywords'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString(isset($_POST['belice']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['costarica']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['elsalvador']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['guatemala']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['honduras']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['nicaragua']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['panama']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['id_noticia'], "int")); mysql_select_db($database_rcpc, $rcpc); $Result1 = mysql_query($updateSQL, $rcpc) or die(mysql_error()); $updateGoTo = "list.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
  9. Hi guys... Have this code: <?php error_reporting(0); define ( 'FILE_UPLOAD_DIR', '/path_to/documentos/' ); $fileObject = $_FILES ['Filedata']; $fileSize = ( double ) $fileObject ['size']; $fileName = $fileObject ['name']; $fileType = strtolower ( pathinfo ( $fileName, PATHINFO_EXTENSION ) ); $fileTempPath = $fileObject ['tmp_name']; $fileUploadPath = rtrim ( FILE_UPLOAD_DIR, '/' ) . '/' . basename ( $fileName ); if (move_uploaded_file ( $fileTempPath, $fileUploadPath )) { echo "OK"; } else { die ( "OcurriĆ³ un error al intentar cargar el archivo" ); } ?> It works with a flash uploader that waits until the "OK" to finish. After it finishes I need to continue with mysql inserts. The code works, but it doesn't finish because the other part of the code is executing. How can I make the other part of the code wait until the first part finishes? Here's the other part of the code: if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE noticias SET tipo=%s, titulo=%s, id_miembro=%s, dia=%s, mes=%s, ano=%s, status=%s, bajada=%s, principal=%s, secundario=%s, comentarios=%s, pie1=%s, pie2=%s, pie3=%s, video1=%s, pie4=%s, video2=%s, pie5=%s, audio1=%s, pie6=%s, audio2=%s, pie7=%s, documento=%s, tags=%s, title_eng=%s, keywords=%s, description=%s, belice=%s, costarica=%s, elsalvador=%s, guatemala=%s, honduras=%s, nicaragua=%s, panama=%s WHERE id_noticia=%s", GetSQLValueString($_POST['tipo'], "int"), GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['id_miembro'], "int"), GetSQLValueString($_POST['dia'], "int"), GetSQLValueString($_POST['mes'], "text"), GetSQLValueString($_POST['ano'], "int"), GetSQLValueString(isset($_POST['status']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['bajada'], "text"), GetSQLValueString($_POST['principal'], "text"), GetSQLValueString($_POST['secundario'], "text"), GetSQLValueString(isset($_POST['comentarios']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['pie1'], "text"), GetSQLValueString($_POST['pie2'], "text"), GetSQLValueString($_POST['pie3'], "text"), GetSQLValueString($file_new_name1, "text"), GetSQLValueString($_POST['pie4'], "text"), GetSQLValueString($file_new_name2, "text"), GetSQLValueString($_POST['pie5'], "text"), GetSQLValueString($file_new_name3, "text"), GetSQLValueString($_POST['pie6'], "text"), GetSQLValueString($file_new_name4, "text"), GetSQLValueString($_POST['pie7'], "text"), GetSQLValueString($file_new_name5, "text"), GetSQLValueString($_POST['tags'], "text"), GetSQLValueString($_POST['title_eng'], "text"), GetSQLValueString($_POST['keywords'], "text"), GetSQLValueString($_POST['description'], "text"), GetSQLValueString(isset($_POST['belice']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['costarica']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['elsalvador']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['guatemala']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['honduras']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['nicaragua']) ? "true" : "", "defined","1","0"), GetSQLValueString(isset($_POST['panama']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['id_noticia'], "int")); mysql_select_db($database_rcpc, $rcpc); $Result1 = mysql_query($updateSQL, $rcpc) or die(mysql_error()); $updateGoTo = "list.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); }
  10. Are `month` and `year` separate columns on your sql structure? or are you using a date column that contains the month and year?
  11. Hello, I have this script from DW thats puts into tabs the contents. I'm getting the "Tab" and "Content" from database, but I'm having issues with the loop. I hope someone here can help me out... I'll comment my problems on the script: <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"> <li class="TabbedPanelsTab" tabindex="0">Tab 1</li> //Here's the first loop <li class="TabbedPanelsTab" tabindex="0">Tab 2</li> </ul> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent">Content 1</div> // Here's the second loop <div class="TabbedPanelsContent">Content 2</div> </div> </div> And here's the tricky part: First loop depends on the result of the second loop.... database query: mysql_select_db($database_rcpc, $rcpc); $query_new = "SELECT noticias.id_noticia AS id_noticia, paises.pais AS pais, noticias.tipo AS tipo, noticias.titulo AS titulo, noticias.status AS status, noticias.bajada AS bajada "; $query_new .= "FROM noticias "; $query_new .= "INNER JOIN paises ON noticias.id_pais=paises.id_pais "; $query_new .= "WHERE tipo = 2 AND noticias.status = 1 "; $query_new .= "ORDER BY paises.orden ASC, id_noticia DESC"; $new = mysql_query($query_new, $rcpc) or die(mysql_error()); $row_new = mysql_fetch_assoc($new); $totalRows_new = mysql_num_rows($new); Thanks for looking!
  12. Never mind.... I have to trim white space!!! It works now. Thank you very much!!!
  13. Thanks Keith I got rid the error message, working now. Test the script but I found that the results are not as expected. Practical example: On record 1, I have tags: "test, prueba, example". On record 2, I have tags: "test" When display record 2, results are as expected. query shows anything related to "test". On the other hand record 1 only show itself. Thanks again...
  14. Hello, I'm I'm dealing with a simple tags search on my website. Each tag is stored separated by a comma in the same column. (pool, ball, dinner) I'm working with this script that actually do the trick, but I'm facing a MySQL error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tags LIKE '%test%' ORDER BY fecha ASC' at line 1" Here's the code: $q = $row_noticias['tags']; //bit of sanitizing $qtrim = strtolower($q); $qtrim = stripslashes($q); $qtrim = strip_tags($q); $qtrim = trim($q); //split values by whitespace into an array, then for each array member stick them together with "OR columnname LIKE '%$arrayvalue%' " $qtrim = explode(',', $q); foreach($qtrim as $value) { $qtrim = $qtrim."OR tags LIKE '%".$value."%' "; } //we now have a string which has the following value: //OR fullname LIKE '%".$value1."%' OR fullname LIKE '%".$value2."%' //we now need to remove the first OR, so the string looks like this: //fullname LIKE '%".$value1."%' OR fullname LIKE '%".$value2."%' $qtrim = substr($qtrim,2); //then we use the string in a mysql query //$query = "SELECT * FROM products WHERE ".$qtrim; $query_relacionados = "SELECT * FROM noticias WHERE " .$qtrim. " ORDER BY fecha ASC"; $relacionados = mysql_query($query_relacionados, $rcpc) or die(mysql_error()); Thanks for your help!!!!
×
×
  • 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.