PHP - Having Trouble Concatenating
I don't get why this fails. date() is meant to be a string, so why does it not concatenate correctly?
Code: [Select] date_default_timezone_set('UTC'); $inputTime = date('c'); $inputTime = $inputTime . ' (UTC)'; // or $inputTime = date('c') . ' (UTC)'; Thanks. Similar TutorialsHi, I have two variables: $latest_note and $notes. Whenever I update $latest_note, I also want this (and today's date) to be added to $notes, such that $notes becomes a sort of archive of all of the latest notes, listed by date. I tried creating a third variable called $full_notes and saying $full_notes = $latest_note.$notes; ... then when I run my mysql update, I set notes='$full_notes' but it's not working properly. Is there a way to simply add one variable to the beginning of another in the db directly, concatenating the two? Thanks! I have a series of echo statements containing html and php elements. Is it possible to somehow store the following statements in one variable by concatenating and later print that variable. The variable should print out the statements as it is printing now. Code: [Select] <? echo "USER banned:<b>"; echo '<a style="text-decoration: none;" href="'.$forumurl.'1acpanel/user.php?do=edit&u='.$banuserid.'"<fontcolor="#4822aa" face="verdana" size="2">'.$banusername.'</font></a><br>'; echo "</b>USER Banned By:<b>"; echo '<a style="text-decoration: none;" href="'.$forumurl.'1acpanel/user.php?do=edit&u='.$banneruserid.'"><font color="#4822aa" face="verdana" size="2">'.$bannerusername.'</font></a><br>'; echo "</b>Banned on:<b>".$bandate."</b><br>"; echo "Reason:<b>".$reason."</b><br><br>"; ?> The below might be a noob question but, I concatenate two spaces in the below string $new_hebrew_date_string = $hebrewMonthName . ' ' . $hebrewDay . "%"; yet when I execute echo "<br />new_hebrew_date_string is $new_hebrew_date_string<br />"; printf("hebrew_date_string is: %s <br />", $new_hebrew_date_string); Only one space is output in between $hebrewMonthName and $hebrewDay regardless of how many spaces I pad the string with. Strangely enough, the string $new_hebrew_date_string is correctly padded w/spaces when I pass it as a parameter to a mySQL stored procedure. Any ideas anyone? Thank you. Hello everyone, I am new to this forum and PHP world. Doing my first project, a pretty complicated one to start with. I will be needing your help a lot to accomplish it. Here is the first one. 1. I have a certain field called 'country' 2. I have small flag icons for every country. WHAT DO I WANT TO DO? Example - If the country is U.S.A., the U.S. flag shows up and is a link to www.domain.com/usa If the country is Germany, the German flags shows up and is a link to www.domain.com/germany If the country is not set, no flag shows up. END. How do I execute this? This is what I am doing to get the image <img src="images/flags/<?php echo $row_rsPilots['country']; ?>.gif" alt="" name="Flag" width="20" height="20" id="Flag" /> How do make it a link to www.domain.com/'country' Thanks in advance Building a website for work. I am struggling with the login for some reason. I`m using a lot of the same code as I did for my personal site and a few other websites I`ve programmed which has always worked. But for some reason, it isn`t working now. I`ve already told it to display to me the information that`s being processed and that is all correct (it even updates the database like it`s supposed to). It just won`t show the person being logged in, which defeats the purpose of logging in, yanno? Here are all the files in question. login.php <?php include "file_calls.php"; $title = "Business Name (Beta): Log In"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "Log into the Business Name website. Only authorized members of the Business Name Staff can log into the website."; echo "<p>"; include "login_form.php"; ?> login_form.php <?php echo "<form action='logging.php' method='post'>"; echo "E-Mail Address:"; echo "<br><input type='text' name='email' size=60 maxlength=100>"; echo "<p>"; echo "Password:"; echo "<br><input type='password' name='pass' size=60 maxlength=25>"; echo "<p>"; $buttonlabel = "Log In"; include "formbutton_format.php"; echo "</form>"; ?> logging.php <?php include "file_calls.php"; $title = "Business Name (Beta): Logging In"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "Logging into the Business Name website. Only authorized members of the Business Name Staff can log into the website."; echo "<p>"; $email = $_POST['email']; $pass = $_POST['pass']; $entry_date = strftime("%B\ %e\,\ %Y %I:%M:%S %p", time()); $res = mysql_query("SELECT id, memlev, pwd1, pwd2, email, name FROM user_data WHERE email='$email'"); $by = mysql_fetch_row($res); mysql_free_result($res); $log = $by[4]; $pas = $by[2]; $pas2 = $by[3]; if ($email && $pass) { if ($by[0]) { if ($by[1] == 2) { $passwd = crypt($_REQUEST['pass'],$by[5]); if ($pass == $pas2) { mysql_query("UPDATE user_data SET lastlogin='$entry_date' WHERE email='$email'"); mysql_close($con); header("Location: index.php"); } elseif ($passwd != $pas) { header("Location: nolog.php?logout=1&m=4"); } } elseif ($by[1] == 1) { header("Location: nolog.php?logout=1&m=2"); } elseif ($by[1] == 0) { header("Location: nolog.php?logout=1&m=3"); } } elseif (!$by[0]) { header("Location: nolog.php?logout=1&m=1"); } } elseif (!$email || !$pass) { echo "<b>Error:</b> Both username and password must be entered in order to log in."; echo "<p>"; include "login_form.php"; } ?>[/php index.php [php]<?php include "file_calls.php"; $title = "Business Name (Beta)"; include "functions.php"; session_start(); echo "$title"; echo "<p>"; echo "This website is currently under construction. Thank you for your patience."; echo "<p>"; if ($lev > 1) { echo "Hello, $loggeduser !"; } elseif ($lev < 2) { echo "Not logged in."; } echo "<p>"; echo "$lev"; echo "<br>$loggeduser<br>$email"; ?> auth.php <?php // Defines DEFINE('SESSION_MAGIC','sadhjasklsad2342'); // Initialization @session_start(); @ob_start(); /* Redirects to another page */ function Redirect($to) { @session_write_close(); @ob_end_clean(); @header("Location: $to"); } /* Deletes existing session */ function RemoveSession() { $_SESSION = array(); if (isset($_COOKIE[session_name()])) { @setcookie(session_name(), '', time()+(60*60*24*365), '/'); } } /* Checks if user is logged in */ function isLoggedIn() { return(isset($_SESSION['magic']) && ($_SESSION['magic']==SESSION_MAGIC)); } /* read message count */ function CountMessages($id) { if ($res=mysql_query("SELECT * FROM user_data WHERE email='$email'")) { $count=mysql_num_rows($res); mysql_free_result($res); return($count); } return 0; } /* Go login go! */ function Login($email,$pass) { global $nmsg, $rows; $ok=false; if ($res=mysql_query("SELECT id, email, name, pwd1, pwd2, memlev FROM user_data WHERE email='$email' AND pwd2='$pass'")) { if ($rows=mysql_fetch_row($res)) { $_SESSION['sess_name'] = $rows[2]; $_SESSION['pass'] = $pass; $_SESSION['gal'] = $rows[0]; $_SESSION['level2'] = $rows[5]; $_SESSION['email'] = $rows[1]; $_SESSION['magic'] = SESSION_MAGIC; $nmsg = CountMessages($rows[0]); $ok=true; } else { include('login_failed.php'); } mysql_free_result($res); } return($ok); } /* Terminates an existing session */ function Logout() { @RemoveSession(); @session_destroy(); } /* Escape array using mysql */ function Escape(&$arr) { if (Count($arr)>0) { foreach($arr as $k => $v) { if (is_array($v)) { Escape($arr[$k]); } else { if (function_exists('get_magic_quotes')) { if(!get_magic_quotes_gpc()) { $arr[$k] = stripslashes($v); } } $arr[$k] = mysql_real_escape_string($v); } } } } // ----------------------------------------------- // Main // ----------------------------------------------- Escape($_POST); Escape($_GET); Escape($_COOKIE); Escape($_REQUEST); Escape($_GLOBALS); Escape($_SERVER); ?> file_calls.php <?php include "info_con.php"; include "auth.php"; ?> functions.php <?php echo "<title>$title</title>"; $lev=isset($_SESSION['level2'])?$_SESSION['level2']:0; $logged=isset($_SESSION['gal'])?$_SESSION['gal']:0; $loggeduser=$_SESSION['sess_name']; $nmsg = 0; $rows = isset($_SESSION['rows'])?$_SESSION['rows']:array(); $email = isset($_SESSION['email'])?$_SESSION['email']:''; $pass = isset($_SESSION['pass'])?$_SESSION['pass']:''; function rand_chars($c, $l, $u = FALSE) { if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++); else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s)); return $s; } function ShowLoggedInBar() { global $email,$pass,$rows,$logid; $nmes=""; if($nmsg){ $nmes="($nmsg New)"; } echo "Hello, $loggeduser !"; } /* check if we are logging out */ if (isset($_REQUEST['logout'])) { Logout(); } /* check if already logged in */ if (isset($_SESSION['magic']) && ($_SESSION['magic']==SESSION_MAGIC)) { ShowLoggedInBar(); } else { /* not logged in, is it a form post? */ if (isset($_REQUEST['email']) && isset($_REQUEST['pass'])) { $email = $_REQUEST['email']; $pass = crypt($_REQUEST['pass'],$email); Login($email,$pass); } else { } } ?> Can anyone see why it works on everything but getting the person logged in? Hi Chaps, I have a PHP FTP App, where users can log in using a unique code and a password. Their unique code corresponds to an FTP folder, e.g. Quote \FTP_Root\Customer A & Co\ So when the user logs in, they can see their FTP directory and contents, in this case an Inbox and an Outbox. This works as the FTP folder contains both an Inbox and an Outbox. The problem I am having is when I try browsing within this directory (say the Inbox), ftp-chdir fails. I have a hyperlink that sends a 'dir' parameter to the same ftp.php page, and if set, will attempt to change to the given directory. So even though the URL Hyperlink reads: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A & Co/Inbox When you click on this link, the page tries to load: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A So my question is what do I need to change, the Hyperlink to read something like: Quote ....server.co.uk/ftp.php?dir=/FTP_Root/Customer%20A%20&%20Co/Inbox Do something to the ftp-chdir function, where I encode/decode/whatever to make sure it tries to change to the correct FTP directory? Or exclude all ampersand entirely? I am using PHP Version 5.3.1 and MYSQL 5.1.41 and I have my select statement here however i was not sure with the php that im using to filter the results if I should have or could have posted it here or in the PHP section, as part of my question pertains to it as well...if i am posting in the wrong place please let me know and i will move it. ok this is killin me its not working and when it works it works backwards...whats happening is when I use $DArea anywhere in the Query it doesnt work, If I choose a different Area than one in the database It executes the Else Statement(not supposed to do that) and it post data from the same Month, Year and Area to the database...once again what im trying to do is not allow any information from an Area "$DArea" in the database unless the Month or the Year is different. In other words If I fill out information from area "Gym" on November("DMonth") of 2010("DYear") the next time i will be allowed to enter data on it is next month. And if you were wondering Dmonth and DYear are variables tied to the time() function abd it does pass the correct month and time to the database. $DArea = $areaReported; $query = mysql_query("SELECT * FROM $table_name WHERE Month ='$DMonth' AND Year= '$DYear' AND Area = '$DArea'") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows!=0) { while ($row = mysql_fetch_assoc($query)) { $dbMonth = $row['Month']; $dbYear = $row['Year']; $dbArea = $row['Area']; } if ($DMonth==$dbMonth&&$DYear==$dbYear&&$DArea==$dbArea) { mysql_query("INSERT INTO $table_name (user_id, Date, Month, Year, Area, percent1, stat1) values ('{$user_id}', '{$realdate}', '{$DMonth}', '{$DYear}', '{$DArea}', '{$percent1}', '{$stat1}')"); // defining the output include("output.inc"); if ($total == "1"){ $output = $output1; } else if ($total == "2"){ $output = $output2; } else if ($total == "3"){ $output = $output3; } else if ($total == "4"){ $output = $output4; } else if ($total == "5"){ $output = $output5; } else if ($total == "6"){ $output = $output6; } else if ($total == "7"){ $output = $output7; } else if ($total == "8"){ $output = $output8; } else if ($total == "9"){ $output = $output9; } else if ($total == "10"){ $output = $output10; } } else echo "<p style=\"color:red;\">A Report for this $areaReported has already been submitted for this Month</p>"; } I have also tried the statement this way. ("SELECT 'Month', 'Year', 'Area' FROM 'data' WHERE 'Month' ='$DMonth' AND 'Year'='$DYear' AND 'Area' = '$DArea'") If it stops any info from hitting the database it stops it all and when the error message I want to appear when someone tries to enter a duplicate record from a specific area for the same month, it does not show unless its a month that does not exist in the database and to get that to even show up I have to take the Area Clause out of the Select statement. I am out of ideas on this one. Can anyone tell me if im even going in the right direction here? Please help Don't have a huge deal of experience with this side of things, well php as a whole really but really struggle with this side, ive coded up a cron but it only works for 1 user, unsure as to why, i want it to do the action for every player that has item 17, the codes below any help would be appreciated, Thanks guys Code: [Select] <?php include("server.php"); $sql = "SELECT * FROM player_inventory WHERE item_id = 17"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $sql2 = "SELECT * FROM players WHERE id = $res[player_id]"; $que2 = mysql_query($sql2); while($res2=mysql_fetch_array($que2)) { $Weight = 8 / 100 * (100 + $res2['ProductionWeight']); $Quality = 75 / 100 * (100 + $res2['ProductionWeight']); $StreetCred = $Weight * $Quality / 10; $update = "UPDATE players SET StreetCred = StreetCred + $StreetCred WHERE id = $res[player_id]"; mysql_query($update) or die(mysql_error());; $update2 = "INSERT INTO drug_inventory (player_id,quality,weight) VALUES('$res[player_id]',$Quality,$Weight)"; mysql_query($update2) or die(mysql_error());; echo "Grow Completed."; } ?> I'm new to php and having some trouble with debugging a piece of code. Could someone please help me understand what's the error. I'm using Code Lobster for debugging and attempting to validate input for a simple sign in form. The error is and code is shown below. If I can understand this, I think I can continue with the rest of the checking. Parse error: syntax error, unexpected T_FOREACH, expecting ')' in C:\wamp\www\login_check_blank.php on line 20 <php // Program name - login_check_Blank.php // Description - checks form for blank fields // Date - 10/26/10 // Programer - R. Langevin ?> <html> <head> <title>Checking for empty fields</title> </head> <body> <?php // set up array for all fields $labels = array( "userName" => "username", "passWord" => "password", // Check each field for blanks foreach ($_POST as $field => $value) { } if ($value =="") { $blank_array[] = $field; } // end of foreach loop for $_post // if any fields were blank, display error message and redisplay form if (@sizeof ($blank_array) >0 { echo "<strong>One or more requied fields were found to be blank</strong>" // display list of blank fields foreach($blank_array as $value) { echo " $nbsp; {$labels[$value] } <br>"; } } echo "$userName "welcome back to the Taft Union High School class of 65 website." exit() ?> </body> </html> Hi Chaps, I've created a web-based FTP site, but having trouble with PHP's FTP_PUT function. I've tried: // FTP access parameters $host = 'ftp.example.org'; $usr = 'example_user'; $pwd = 'example_password'; // file to move: $local_file = './example.zip'; $ftp_path = '/data/example.zip'; // connect to FTP server (port 21) $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host"); // send access parameters ftp_login($conn_id, $usr, $pwd) or die("Cannot login"); // turn on passive mode transfers (some servers need this) // ftp_pasv ($conn_id, true); // perform file upload $upload = ftp_put($conn_id, $ftp_path, $local_file, FTP_BINARY); // check upload status: print (!$upload) ? 'Cannot upload' : 'Upload complete'; print "\n"; // close the FTP stream ftp_close($conn_id); And also Net_FTP's FTP_PUT function: require_once 'Net/FTP.php'; $test = new Net_FTP('www.domain.co.uk', 21); $test->connect('www.domain.co.uk', 21); $test->login('username', 'password'); $file_tmp = $_FILES["file"]["tmp_name"]; $file_name = $_FILES["file"]["name"]; $test->put($file_tmp, 'Uploads/'.$file_name, FTP_BINARY); I've tested this with a very small text file and it works OK, but when I try with a zip file of around 9Mb it takes FOREVER, and sometimes doesn't upload at all, or if it does, it has a size of 0kb. I need the script to handle big files up to 150Mb in size. What can I do to speed up the process and is there something I have missed (current config settings > ini_set('max_upload_filesize', 150000000)) ? I'd like to perform 2 tasks: First, get a list of users who have not logged in for 30 days. Then, deduct some points as a penalty. This is what I have so far: Code: [Select] $sec=30*86400; $curr_time=time(); $maxtime=$curr_time-$sec; $result = mysql_query("SELECT scm_mem_id FROM sc_member WHERE (scm_lastlogin < '$maxtime') ORDER BY scm_lastlogin") ; while($row = mysql_fetch_row($result)) { $member = $row[0]; //-------------------------- DEDUCT POINTS -------------------------------- $points = ?; // need to pull existing points (field: scm_points) from the above SELECT statement and deduct 10% (rounded) $time_=time(); $sql_c = "INSERT INTO sc_coins_asset (`type_id`,`mem_id`,`from/to_mem_id`,`date_added`,`value`) VALUES(9,$member,8,'".$time_."',-".$points.")"; $db->insert_data($sql_c); } I'm trying to figure out why my entire if statement is not working properly. What is happening when I run my form is that it puts it into the first if statement regardless of what the value of $style is and I don't know why. The other parts of the for submission works BUT my if statement. And inside of firebug it is passing the RIGHT post data so it has the correct value for style each time. <?php // Include the database page require ('../inc/dbconfig.php'); if (isset($_POST['submitcharacter'])) { $charactername = mysqli_real_escape_string($dbc, $_POST['charactername']); $charactershortname = mysqli_real_escape_string($dbc, $_POST['charactershortname']); $sortorder = mysqli_real_escape_string($dbc, $_POST['sortorder']); $style = mysqli_real_escape_string($dbc, $_POST['style']); $status = mysqli_real_escape_string($dbc, $_POST['status']); $alignment = mysqli_real_escape_string($dbc, $_POST['alignment']); $division = mysqli_real_escape_string($dbc, $_POST['division']); $query = "INSERT INTO `characters` (charactername, charactershortname, status_id, style_id, division_id, alignment_id, sortorder, creator_id, datecreated) VALUES ('$charactername','$charactershortname','$status','$style','$division', '$alignment', '$sortorder', 1, NOW())"; mysqli_query($dbc, $query); $query_id = mysqli_insert_id($dbc); $query1 = "INSERT INTO `allies` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query1); $query2 = "INSERT INTO `rivals` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query2); if ($style = 1) { $query3 = "INSERT INTO `singles` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query3); } elseif ($style = 2) { $query4 = "INSERT INTO `tagteams` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query4); } elseif ($style = 3) { $query5 = "INSERT INTO `managers` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query5); } } elseif ($style = 4) { $query6 = "INSERT INTO `stables` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query6); } elseif ($style = 5) { $query7 = "INSERT INTO `referees` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query7); } else { $query8 = "INSERT INTO `staff` (character_id) VALUES (".$query_id.")"; mysqli_query($dbc, $query8); } ?> I'm not sure if this is a php issue or jquery issue. When I complete the form and hit submit it puts the successful message up like its supposed to but also with the fields still filled in the form which it shouldn't be doing and it doesn't actually post in the database so I'm not sure if its a php issue or jquery issue. Code: [Select] <script type="text/javascript"> $(document).ready(function() { $('div.message-error').hide(); $('div.message-success').hide(); $("input.submit").click(function() { $('div.message-error').hide(); var templatename = $("input#templatename").val(); if (templatename == "") { $("div.message-error").show(); $("input#templatename").focus(); return false; } var headercode = $("textarea#headercode").val(); if (headercode == "") { $("div.message-error").show(); $("textarea#headercode").focus(); return false; } var footercode = $("textarea#footercode").val(); if (footercode == "") { $("div.message-error").show(); $("textarea#footercode").focus(); return false; } var dataString = 'templatename='+ templatename+ '&headercode=' + headercode + '&footercode=' + footercode; $.ajax({ type: "POST", url: "processes/template.php", data: dataString, success: function() { $("div.message-success").show(); return true; } }); return false; }); }); </script> <!-- Form --> <form action="#" name="templateform" > <fieldset> <legend>Add New Template</legend> <div class="field required"> <label for="templatename">Template Name</label> <input type="text" class="text" name="templatename" id="templatename" title="Template Name"/> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <div class="field required"> <label for="headercode">Header Code</label> <textarea name="headercode" id="headercode" title="Header Code"></textarea> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <div class="field required"> <label for="footercode">Footer Code</label> <textarea name="footercode" id="footercode" title="Footer Code"></textarea> <span class="required-icon tooltip" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span> </div> <input type="submit" class="submit" name="submittemplate" id="submittemplate" title="Submit Template" value="Submit Template"/> </fieldset> </form> <!-- /Form --> <!-- Messages --> <div class="message message-error"> <h6>Required field missing</h6> <p>Please fill in all required fields. </p> </div> <div class="message message-success"> <h6>Operation succesful</h6> <p>Template was added to the database.</p> </div> <!-- /Messages --> validation page <?php // Include the database page include ('inc/dbconfig.php'); if ((isset($_POST['templatename'])) && (strlen(trim($_POST['templatename'])) > 0)) { $templatename = stripslashes(strip_tags($_POST['templatename'])); } else {$templatename = 'No name entered';} if ((isset($_POST['headercode'])) && (strlen(trim($_POST['headercode'])) > 0)) { $headercode = stripslashes(strip_tags($_POST['headercode'])); } else {$headercode = 'No name entered';} if ((isset($_POST['footercode'])) && (strlen(trim($_POST['footercode'])) > 0)) { $footercode = stripslashes(strip_tags($_POST['footercode'])); } else {$footercode = 'No name entered';} $query = "INSERT INTO `templates` (templatename, header, footer, creator_id, datecreated) VALUES ('".$divisionname."','".$headercode."','".$footercode."' 1, NOW())"; mysql_query($query); ?> I have this as my code: if(!empty($stipulation)){ if($stipulation == "Championship Title Match"){ print "<h3 class=title>".$title." Match</h3>"; } else{ print "<h3 class=stipulation>".$stipulation."</h3>"; } } however I'm wanting to make it to where if it $stipulation has a value then it echos it and nothing if it doesn't have a value then don't nothing else happens. I also need a similiar if statement that will check to see if there is a value for $title and if there is then it echos $title Championship Match and again if no value exists it does nothing. I have a form that I want the data to e-mail in a message. Everything works except for the checkbox arrays. "Array" displays when I want all values of checked boxes to display. Here is the code, I have bolded where checkbox data should be coming over. I'm not a pro so any help is greatly appreciated. Code: [Select] $message = "<html><body>\r\n"; $message .= "<table width='500' border='0' cellpadding='2'>\r\n"; $message .= " <tr>\r\n"; $message .= " <td width='150'>School</td>\r\n"; $message .= " <td width='350'>" . $_POST['school'] . " </td>\r\n"; $message .= " </tr>\r\n"; $message .= " <tr>\r\n"; $message .= " <td width='150'>Teacher</td>\r\n"; $message .= " <td width='350'>" . $_POST['teacher'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <tr>\r\n"; $message .= " <td width='150'>Subject</td>\r\n"; $message .= " <td width='150'>" . $_POST['subject'] . "</td>\r\n"; $message .= " <td width='150'>Period</td>\r\n"; $message .= " <<td width='50'>" . $_POST['period'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Date</td>\r\n"; $message .= " <td width='50'>" . $_POST['month'] . "</td>\r\n"; $message .= " <td width='15'>" . $_POST['day'] . "</td>\r\n"; $message .= " <td width='15'>" . $_POST['year'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Time In:</td>\r\n"; $message .= " <td width='100'>" . $_POST['timeIn'] . "</td>\r\n"; $message .= " <td width='150'>Time Out:</td>\r\n"; $message .= " <td width='100'>" . $_POST['timeOut'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Teacher Location Upon Entrance</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q6_1Teacher6'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q7_comments7'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Student Engagement</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q11_2Student'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Students Engaged/Total Students</td>\r\n"; $message .= " <td width='350'>" . $_POST['q12_studentsEngagedtotal'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q15_comments15'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Teaching Alignment</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q17_3Teaching17'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q18_comments18'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Identified Learning</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q13_4Identified'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q16_comments16'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Rigor Rate</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q20_5Rigor'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q21_comments21'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Assessment Practice</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q22_6Assessment'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q27_comments27'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Instructional Practice</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q24_studentDirected'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q23_comments23'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= " <td width='150'>Learning Environment</td>\r\n"; [b]$message .= " <td width='350'>" . $_POST['q28_8Learning'] . "</td>\r\n";[/b] $message .= " </tr>\r\n"; $message .= " <td width='150'>Comments</td>\r\n"; $message .= " <td width='350'>" . $_POST['q29_comments29'] . "</td>\r\n"; $message .= " </tr>\r\n"; $message .= "</table>\r\n"; $message .= "</body></html>"; $titleurl = preg_replace('/[^a-zA-Z0-9_ -%]/', '-', $d); $titleurl = preg_replace('/[ ]/', '-', $titleurl); How do you add to this to replace ---- with - --- with - -- with - and remove quotes? How do you remove a - if it's at the very end of $titleurl. For example, replace My-iPhone- with My-iPhone I am trying to put the tree of an XML file into an array. sample.xml Code: [Select] <?xml version='1.0' encoding='UTF-8'?> <getHistogramsResponse xmlns="http://www.ebay.com/marketplace/search/v1/services"> <ack>Success</ack> <version>1.7.0</version> <timestamp>2010-09-01T12:13:31.480Z</timestamp> <aspectHistogramContainer> <domainName>UK_CamerasPhoto_DigitalCameras_DigitalCameras_JN</domainName> <domainDisplayName>Digital Cameras</domainDisplayName> <aspect name="Brand"> <valueHistogram valueName="Canon"> <count>4323</count> </valueHistogram> <valueHistogram valueName="Sony"> <count>2210</count> </valueHistogram> </aspect> </aspectHistogramContainer> </getHistogramsResponse> $this->cXmlToArray->m_arr = GetXMLTree('sample.xml') if (isset($this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer'][0])) { $this->m_arrResult = $this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer']; } else if (count($this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer']) > 0) { $this->m_arrResult[] = $this->cXmlToArray->m_arr['getHistogramsResponse']['aspectHistogramContainer']; } However my output is showing as: Array ( [0] => Array ( [domainName] => UK_CamerasPhoto_DigitalCameras_DigitalCameras_JN [domainDisplayName] => Digital Cameras [aspect] => Array ( [0] => Array ( [valueHistogram] => Array ( [0] => Array ( [count] => 4311 ) [1] => Array ( [count] => 2209 ) ) ) ) So how do I get it to return the attributes name and valueName? Any help will be greatly appreciated. i am not a coder by any means and my boss threw me under the bus to add an auto reply to this form. I've figured out that this is the code that the form uses to process - but now i have NO IDEA what to do. Can ANYONE help me with this? it's supposed to have instructions in the response and send a copy to us and the the submitter. THANKS SO MUCH IN ADVANCE!!! Here's the php form code: Code: [Select] <?php $EmailFrom = "Win One"; $EmailTo = "sales@capsonewire.com"; $Subject = "Registration"; $Name = Trim(stripslashes($_POST['Name'])); $Tel = Trim(stripslashes($_POST['Tel'])); $Email = Trim(stripslashes($_POST['Email'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Message = Trim(stripslashes($_POST['Message'])); // validation $validationOK=true; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "Message: "; $Body .= $Message; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">"; } ?> hi, i am pulling data from a database, a picture and some text, i am able to have the records display vertically but i want them to display across the screen rather than downwards, but because of the page size, i only want 2 results per line. does any one know how i can do this? thanks in advance. Des This is the code i am currently using $result = mysql_query("select * from staff'"); echo "<table border='0' cellpadding='10' cellspacing='0'>"; echo "<tr>"; while($row = mysql_fetch_array($result)) { echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>"; echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>"; } echo "</tr>"; echo "</table>"; errors: Deprecated: Function session_register() is deprecated in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/login.php:18) in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /Applications/XAMPP/xamppfiles/htdocs/login.php:18) in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Deprecated: Function session_register() is deprecated in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 22 Code: Code: [Select] <?php if ($_POST['email']) { include_once "connect_to_mysql.php"; $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = preg_replace("[^A-Za-z0-9]", "", $_POST['password']); $password = md5($password); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'"); header("location: member_profile.php?id=$id"); exit(); } } else { print '<br /><br /><font color="#FF0000">No match in our records, try again </font><br /> <br /><a href="login.php">Click here</a> to go back to the login page.'; exit(); } } ?> any help really appreciated...thanks!! |