Jump to content

patheticsam

Members
  • Posts

    122
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

patheticsam's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I'm new to php and I have a pretty basic question : I have a set of variables like this : $event10 = $_POST['event10']; $event11 = $_POST['event11']; $event12 = $_POST['event12']; $event13 = $_POST['event13']; $event14 = $_POST['event14']; $event15 = $_POST['event15']; $event16 = $_POST['event16']; $event17 = $_POST['event17']; $event18 = $_POST['event18']; $event19 = $_POST['event19']; $event20 = $_POST['event20']; $event21 = $_POST['event21']; $event22 = $_POST['event22']; $event23 = $_POST['event23']; $event24 = $_POST['event24']; $event25 = $_POST['event25']; $event26 = $_POST['event26']; $event27 = $_POST['event27']; $event28 = $_POST['event28']; $event29 = $_POST['event29']; $event30 = $_POST['event30']; $event31 = $_POST['event31']; $event32 = $_POST['event32']; $event33 = $_POST['event33']; $event34 = $_POST['event34']; $event35 = $_POST['event35']; $event36 = $_POST['event36']; $event37 = $_POST['event37']; $event38 = $_POST['event38']; $event39 = $_POST['event39']; $event40 = $_POST['event40']; $event41 = $_POST['event41']; $event42 = $_POST['event42']; $event43 = $_POST['event43']; $event44 = $_POST['event44']; $event45 = $_POST['event45']; $event46 = $_POST['event46']; $event47 = $_POST['event47']; $event48 = $_POST['event48']; $event49 = $_POST['event49']; $event50 = $_POST['event50']; $event51 = $_POST['event51']; $event52 = $_POST['event52']; $event53 = $_POST['event53']; $event54 = $_POST['event54']; Some of these variables contains some infos as some others are left empty. Basically I just want to know how much variables contains a value(are not empty).. If anyone can show me what to do or point me to a simple tutorial it would be really appreciated! Thank you!
  2. Hi, I'm new to php and I have a pretty basic question : I have a form that passes about 50 different fields to another page. Once on the page I get the value like this : $event10 = $_POST['event10']; $event11 = $_POST['event11']; $event12 = $_POST['event12']; $event13 = $_POST['event13']; $event14 = $_POST['event14']; $event15 = $_POST['event15']; $event16 = $_POST['event16']; $event17 = $_POST['event17']; $event18 = $_POST['event18']; $event19 = $_POST['event19']; $event20 = $_POST['event20']; $event21 = $_POST['event21']; $event22 = $_POST['event22']; $event23 = $_POST['event23']; $event24 = $_POST['event24']; $event25 = $_POST['event25']; $event26 = $_POST['event26']; $event27 = $_POST['event27']; $event28 = $_POST['event28']; $event29 = $_POST['event29']; $event30 = $_POST['event30']; $event31 = $_POST['event31']; $event32 = $_POST['event32']; $event33 = $_POST['event33']; $event34 = $_POST['event34']; $event35 = $_POST['event35']; $event36 = $_POST['event36']; $event37 = $_POST['event37']; $event38 = $_POST['event38']; $event39 = $_POST['event39']; $event40 = $_POST['event40']; $event41 = $_POST['event41']; $event42 = $_POST['event42']; $event43 = $_POST['event43']; $event44 = $_POST['event44']; $event45 = $_POST['event45']; $event46 = $_POST['event46']; $event47 = $_POST['event47']; $event48 = $_POST['event48']; $event49 = $_POST['event49']; $event50 = $_POST['event50']; $event51 = $_POST['event51']; $event52 = $_POST['event52']; $event53 = $_POST['event53']; $event54 = $_POST['event54']; Some of these variables values are left empty. Basically what I'm trying to do is to output the number of values that are NOT empty and multiply the amount by 500. If anyone can help me out or point me to a tutorial it would be really appreciated!! Thank you!!
  3. Well I gave to complete script. Thats the reason why I can't understand why I'm getting this error??
  4. Hi there, I'm new to php and I have a parse error with a really simple script which I can't understand why it's not working Basically I have a contact form in which your select a departement, the department value is posted to the send.php file to send the mail and depending on the selected department, the destination email changes. Here is the send.php script : $departement = $_POST['departement']; $nom = $_POST["name"]; $courriel = $_POST["email"]; $telephone = $_POST["phone"]; $message = $_POST["message"]; //change this to your email. if($departement=='Informations'){ $to1 = "rocky@email1.com"; $to2 = "pierre@email1.com"; $to3 = "john@email1.com"; } <--PARSE ERROR? elseif ($departement=='Ventes'){ $to1 = "sam@email1.com"; $to2 = "john@email1.com"; } elseif ($departement=='Recrutement'){ $to1 = "isaax@email1.com"; $to2 = "john@email1.com"; } $from = $courriel; $subject = "Nouveau message recu de votre site web"; //begin of HTML message $message = <<<EOF <html> <body bgcolor="#FFFFFF"> <h1>Courriel Recu du site web</h1> <br /><br /> Vous avez recu un nouveau courriel d'un client a partir de votre site web.<br /> Veuillez contacter le client dans les plus brefs delais.<br /><br /> Nom du client : $nom <br /><br /> Telephone : $telephone <br /> Courriel : $courriel <br /><br /> Departement : $departement<br /> Message du client : $message </body> </html> EOF; //end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; // now lets send the email. if($departement=='Informations'){ mail($to1, $subject, $message, $headers); mail($to2, $subject, $message, $headers); mail($to3, $subject, $message, $headers); } elseif ($departement=='Ventes'){ mail($to1, $subject, $message, $headers); mail($to2, $subject, $message, $headers); } elseif ($departement=='Recrutement'){ mail($to1, $subject, $message, $headers); mail($to2, $subject, $message, $headers); } ?> Here's the error I'm getting :PHP Parse error: syntax error, unexpected '}' in /home3/centreau/public_html/contact-auto-doum-centre-auto-dumoulin/send.php on line 21 If anyone can help me out it would be really appreciated! Thanks!1
  5. Hi! I'm new to php and I have a really simple question.. I have some text stored in a MySQL database and i'm outputting the texts like this : $data = mysql_query("SELECT * FROM lva_artistes ORDER by RAND() LIMIT 0,2") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo $info['text']; } Since it's a long text I want to know if there's a way to output only the first X characters (ex: only de first 500 characters)... If anyone can point me to a tutorial or the right function it would be really appreciated.. Thanks!!
  6. Hi, I have an issues that I can't seems to figure what i'm doing wrong, I'm mostly new to php and I have a script that splits the results from DB into different pages. The script is working correctly but not if I had a WHERE clause in the SQL command..I really don't understand why.... here's the script : <?php require_once('../admin/config.php'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $plan_type = $_POST['plan_type']; $plan_style = $_POST['plan_style']; $plan_bedroom = $_POST['plan_bedroom']; $plan_bathroom = $_POST['plan_bathroom']; $plan_garage = $_POST['plan_garage']; $plan_superficie = $_POST['plan_superficie']; $tbl_name="plans"; //your table name $adjacents = 3; $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE plan_type='$plan_type'"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; $targetpage = "index.php"; //your file name (the name of this file) $limit = 15; //how many items to show per page $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; //first item to display on this page else $start = 0; //if no page var is given, set start to 0 $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit WHERE plan_type='$plan_type'"; $result = mysql_query($sql); if ($page == 0) $page = 1; //if no page var is given, default to 1. $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 $pagination = ""; if($lastpage > 1) { $pagination .= "<div class=\"nextpage\">"; //previous button if ($page > 1) $pagination.= "<a href=\"$targetpage?page=$prev\">< Précedent</a> "; else $pagination.= "<span class=\"disabled\">< Précendent </span>"; //pages if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span> "; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } } elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some { //close to beginning; only hide later pages if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span> "; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } $pagination.= "..."; $pagination.= " <a href=\"$targetpage?page=$lpm1\">$lpm1</a> "; $pagination.= " <a href=\"$targetpage?page=$lastpage\">$lastpage</a> "; } //in middle; hide some front and some back elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= " <a href=\"$targetpage?page=1\">1</a> "; $pagination.= " <a href=\"$targetpage?page=2\">2</a> "; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span> "; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } $pagination.= "..."; $pagination.= " <a href=\"$targetpage?page=$lpm1\">$lpm1</a> "; $pagination.= " <a href=\"$targetpage?page=$lastpage\">$lastpage</a> "; } //close to end; only hide early pages else { $pagination.= " <a href=\"$targetpage?page=1\">1</a> "; $pagination.= " <a href=\"$targetpage?page=2\">2</a> "; $pagination.= "..."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= " <span class=\"current\">$counter</span> "; else $pagination.= " <a href=\"$targetpage?page=$counter\">$counter</a> "; } } } //next button if ($page < $counter - 1) $pagination.= " <a href=\"$targetpage?page=$next\">Suivant ></a>"; else $pagination.= " <span class=\"disabled\">Suivant ></span>"; $pagination.= "</div>\n"; } ?> <?php while($row = mysql_fetch_array($result)) { echo " <table class=\"plantable\"> <tr> <td class=\"first\"><img src=\"../timthumb.php?src=admin/PHOTOS-PLANS/".$row['photo_main']."&h=140&w=150&zc=1\" alt=\"Plan de maison ".$row[plan_type]." ".$row['plan_style']."\"></td> <td class=\"second\">DL00-".$row['plan_id']."<br /><br /><b>".$row['plan_type']."</b><br />Style : ".$row['plan_style']."<br />Chambres à coucher : "; if ($row['plan_bedroom']=='Plus de 5') { echo $row['plan_bedroom_sup']; } else { echo $row['plan_bedroom']; } echo "<br />Salles de bain : "; if ($row['plan_bathroom']=='3 et plus') { echo $row['plan_bathroom_sup']; } else { echo $row['plan_bathroom']; } echo "</td> <td class=\"third\"><a href=\"view_plan.php?cmd=view&id=".$row['plan_id']."\">Voir les détails du plan</a><br /><br /><br /><p class=\"price\">".$row['plan_price']." $ </p><br /><a href=\"order_plan.php?cmd=order&id=".$row['plan_id']."\"><img src=\"../images/bouton_commander.png\" alt=\"Commander un plan de maison\" border=\"0\"></a></td> </tr> </table> <br /> "; } ?> <?=$pagination?> Basically if I remove the "WHERE" clause highlighted in red $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit WHERE plan_type='$plan_type'"; the prev/next script works appart from the facts that it displays all the reseults from the DB and I need to display only the results =$plan_type If anyone can help me it would be really appreciated.. Thanks!!
  7. Works,...I knew it was something small. Thanks! Really appreciated!!
  8. p.s. the event_date field in MySQL is correctly set to DATE type...
  9. Hi, I'm a little bit new to php and I'm working on a script to display upcoming events. Here's the script I have : <?php require_once('../admin/config.php'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } $date = Date("Y-m-d"); $data = mysql_query("SELECT * FROM events WHERE event_date > $date ORDER by event_date") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { ?> <div class="indent-bottom17 border-bottom p8"> <?php echo $date; ?> <h3 class="p4-1"><?php echo $info['event_city'].", ".$info['event_state']; ?></h3> <h6 class="p4-1">Course title : <?php echo $info['event_title']; ?></h6> <a href="view_event.php?cmd=view&id=<?php echo $info['event_id']; ?>">View details...</a> </div> <?php } ?> I don't get any errors and the script seems to work except for the part that it also displays events from the past...it ignores the condition : SELECT * FROM events WHERE event_date > $date ORDER by event_date I don't know if i'm doing this right but if anyone can point me to a solutions it would be really appreciated...Thanks!!
  10. I'm sorry..as I said I'm a little bit new to this..can you just give a code example of an array lookup...thanks...
  11. This is exactly what I'm trying to do...The values are assigned correctly but how do I know which ones have been assigned? Thanks!
  12. Hi, I am currently working on an html form wich loads somes values into $_SESSIONS values (here's the code for the html form) <form name="change" action="../secure/" method="post"> <div class="FBG2"> <h2>Services de telephonie</h2> <span class="division"><input type="checkbox" name="T01"><p>Videotron téléphonie</p></span> <span class="division"><input type="checkbox" name="T02"><p>Bell Canada</p></span> <span class="division"><input type="checkbox" name="T03"><p>Bell Mobilité</p></span> <span class="division"><input type="checkbox" name="T04"><p>Fido</p></span> <div class="clr"></div> <span class="division"><input type="checkbox" name="T05"><p>Rogers sans-fil</p></span> <span class="division"><input type="checkbox" name="T06"><p>Telus</p></span> <span class="division"><input type="checkbox" name="T07"><p>Telus mobilité</p></span> <span class="division"><input type="checkbox" name="T08"><p>Allstream</p></span> <div class="clr"></div> </div> </form> i'm passing the values into $_SESSION values: <?php session_start(); $_SESSION['T01'] = $_POST['T01']; $_SESSION['T02'] = $_POST['T02']; $_SESSION['T03'] = $_POST['T03']; $_SESSION['T04'] = $_POST['T04']; $_SESSION['T05'] = $_POST['T05']; $_SESSION['T06'] = $_POST['T06']; $_SESSION['T07'] = $_POST['T07']; $_SESSION['T08'] = $_POST['T08']; Now since the forms contains only checkboxes some of the values are left empty..How can I loop through the values and eliminate the ones that are left empty and output the ones that are selected? I'm new to php..so if some one can point me to a tutorial or command it would be really 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.