PHP - "forcing" Php To Echo Information As It Executes
Good evening --
My script takes a while to execute as it processes records from the db. I'd like to have it print out to the screen the record id # as it processess each record, just to let me know where it is. Currently, the program waits till the end and then prints out the record numbers, which is no help. How can I enable PHP to print out each record number as it goes along? Thanks! Similar Tutorialshello, I was wondering what is the point of writing for a dropdown: <?php if ($_POST[inputfieldID] == "value") { echo "selected"; } ?> or for a checkbox/ radio button: <?php if ($_POST['cb/radioID'] == "value") { echo "checked"; } ?> I guess it's for after submit, if there is any error, the values filled will still be echoed in the inputfield, or am i wrong? But then if that is true, i have a php search box where i use AJAX object to to send all the input they filled in after submit. But after pushing submit the inputted values remain. I guess when using AJAX to send the information i don't need <?php if ($_POST[inputfieldID] == "value") { echo "selected"; } ?> in my html forms? Little confused Can maybe somebody bring clearness Can someone please help me with an array problem i can not figure out. I need the array to be numbered from 1 to how ever many fields that are needed in the form and have a mysql field name and the title of the field also in the array. 1, "mysql_field_name", "Title of form field" 2, "", "" and so on then the form will be shown based on the array. I have the following draft code which I am working with. any suggestions on how i may do this array ? Code: [Select] <?php $options = array( '1'=> array('fieldtext'=>'option1', 'mysqlfield'=>'option1'), '2'=> array('fieldtext'=>'option2', 'mysqlfield'=>'option2'), '3'=> array('fieldtext'=>'option3', 'mysqlfield'=>'option3'), '4'=> array('fieldtext'=>'option4', 'mysqlfield'=>'option4'), ); // $options = array(1 => "option1", "option2", "option3", "option4"); // the line above works but i want to include the name of the mysql field as well. $userid = 1; ?> <div style="align: center; margin: 12px; font-family:Tahoma;"> <br><br><?php if ($_POST['Update'] != "Update") { // check if form submitted yet, if not get data from mysql. $res = db_query("SELECT * FROM `users` WHERE `userid` = '" . $userid . "'"); foreach($options as $key => $value) { $_POST[$key] = mysql_result($res, 0, $value); } $ok_to_update = "no"; } elseif ($_POST['Update'] == "Update") { // check if form submitted yet, if so get POST data. // error checking // foreach($options as $key => $value) { // $_POST[$i] = ""; // } $ok_to_update = "yes"; } if ($_POST['Update'] == "Update" && $ok_to_update == "yes") { // $res = db_query("INSERT INTO `users` () VALUES ()"); // add user details to database. ?><p><br><br><br>Thank you for updating</p><?php } else { ?><form name="form1" method="post" action=""> <?php foreach($options as $key => $value) { ?><p><?php echo($value); ?>: <input type="text" name="<?php echo($key); ?>" value="<?php echo($_POST[$key]);?>"></p> <?php } ?> <input name="Update" type="submit" value="Update"> </form> <?php } ?> </div> How can i make echo "<b>Site:</b> ".$req_user_info['site']."<br>"; linkable The site raw fron the db contains an site url. Regards Hi, bit stuck on how to find and replace "<" and ">" with "<" and ">". I basically have a database record that outputs to screen and I need the code in the <code> tags to be rendered to the screen. I therefore need it to go through the whole array variable from the db and change the symbols just inside the code tags. Please be aware that the code tags might happen more than once here's an example below Code: [Select] <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1> </code> the desired output would be: <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> <p>blah blah blah</p> <p>blah blah blah</p> <p>blah blah blah</p> <code> <h1>hello</h1 </code> help on this would be great Cheers Rob Cannot modify header information - headers already sent by (output started at ) on line 179 I labeled 179 its at the bottom. I understand this means its already generating the html but not how or where. A solution would of course be nice but if some one could tell me even how to figure it out it would be great. Code: [Select] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "test@test.com"; $email_subject = "$mile"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } /*"trail_section_mile", float dash "trail_section_name", #9()alphanumeric "name", "date"auto date "email",same "telephone" same "trail_condition" no validation just sanitize size limit "attention_area" no validation just sanitize size limit "under_20" no validation just sanitize size limit "_20_54" no validation just sanitize size limit "_55_over" no validation just sanitize size limit */ if(!isset($_POST['trail_section_mile']) ) { died('1'); } if(!isset($_POST['trail_section_name']) ) { died('2'); } if(!isset($_POST['name']) ) { died('3'); } if(!isset($_POST['email']) ) { died('4'); } if(!isset($_POST['telephone']) ) { died('5'); } if(!isset($_POST['trail_condition']) ) { died('6'); } if(!isset($_POST['attention_area']) ) { died('7'); } if(!isset($_POST['under_20']) ) { died('8'); } if(!isset($_POST['_20_54']) ) { died('9'); } if(!isset($_POST['_55_over']) ) { died('0'); } if(!isset($_POST['total_hours']) ) { died('011'); } //comments field is a honeypot require ('Validate.php'); $email = $_REQUEST['email']; $validate = new Validate(); if (!Validate::email($email, array('check_domain' => true, 'use_rfc822' =>true))) { echo "Invalid email"; } $trail_section_mile = $_POST['trail_section_mile']; // required $trail_section_name = $_POST['trail_section_name']; // required $name = $_POST['name']; // required $email = $_POST['email']; // required $telephone = $_POST['telephone']; // required $trail_condition = $_POST['trail_condition']; // required $attention_area = $_POST['attention_area']; // required $under_20 = $_POST['under_20']; $_20_54 = $_POST['_20_54']; $_55_over = $_POST['_55_over']; $_55_over = $_POST['total_hours']; // required if (preg_match('/[\d\D\b\B\s\S]/', $comments)) { echo "nope"; } if (!preg_match("/([\w\.\#\-\,]{1,30})+/", $trail_section_mile)) {echo "please enter the section mile markers again only numbers, decimals dashes and # are aloud"; } if (!preg_match("/[a-z'-]+/", $trail_section_name)) { echo "Try your last name again."; } if (!preg_match("/[a-z'-]+/", $name)) { echo "please re-type your address."; } if (!preg_match("/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/i", $telephone)) { echo "Something is wrong with the phone number you intered. Please enter your area code first then ther rest of tyour number."; } if (( preg_match( "/[\r\n]/", $first_name ) || preg_match( "/[\r\n]/", $email ) || preg_match( "/[\r\n]/", $last_name) ) || preg_match( "/[\r\n]/", $state)) { echo "nope"; } $trail_section_mile = strip_tags($trail_section_mile); $trail_section_name = strip_tags($trail_section_name); $name =strip_tags($name); $email = strip_tags($email); $telephone = strip_tags($telephone); $trail_condition = strip_tags($trail_condition); $attention_area = strip_tags($attention_area); $under_20 = strip_tags($under_20); $_20_54 = strip_tags($_20_54); $_55_over = strip_tags($_55_over); $total_hours = strip_tags($total_hours); $trail_section_mile = htmlspecialchars($trail_section_mile); $trail_section_name = htmlspecialchars($trail_section_name); $name = htmlspecialchars($name); $email = htmlspecialchars($email); $telephone = htmlspecialchars($telephone); $trail_condition = htmlspecialchars($trail_condition); $attention_area = htmlspecialchars($attention_area); $under_20 = htmlspecialchars($under_20); $under_20 = htmlspecialchars($_20_54); $_55_over = htmlspecialchars($_55_over); $total_hours = htmlspecialchars($total_hours); $email_message = "Form details below.\n\n"; $email_message = date("m/d/Y") . "\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Trail Section Mile Markers: ".clean_string($trail_section_mile)."\n"; $email_message .= "Trail Section Name : ".clean_string($trail_section_name)."\n"; $email_message .= "Reported by: ".clean_string($name)."\n"; $email_message .= "Email Address: ".clean_string($email)."\n"; $email_message .= "Telephone Number: ".clean_string($telephone)."\n"; $email_message .= "General Trail Condition : ".clean_string($trail_condition)."\n"; $email_message .= "Mile #/Problem/Suggested Improvements: ".clean_string($attention_area)."\n"; $email_message .= "Volunteers Under Age 20 #Males/#Females/Ethnicity/Name: ".clean_string($under_20)."\n"; $email_message .= " Volunteers Ages 20 to 54 #Males/#Females/Ethnicity/Name: ".clean_string($_20_54)."\n"; $email_message .= "Volunteers Age 55+ #Males/#Females/Ethnicity/Name: ".clean_string($_55_over)."\n"; $email_message .= "Total Volunteer Hours: ".clean_string($total_hours)."\n"; $about ="Maintenance Report from" .$name. "/n"; // create email headers $headers = 'Subject : '.$about."/r/n" .'From: '.$email."\r\n" .'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); header("Location: oht/maintenance/maintenance-report/thank-you/"); //line 179 @mail($email_to, $email_subject, $email_message, $headers); ?> <?php } ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Hi all, just to get this out of the way i have now been working on html / css / php / mysql coding for about 3 weeks. So i dont know too much, on to the problem... I am creating a database for asset managment in and out of our shop I have setup the db and it works with no issues. So I am currently trying to add fluff as i put it. The guys in the shop want the web page to have a table of information on what is in the shop and when they click on the asset number in the table they want it to open a new page where you can edit the database information of that item. I have no clue how to emplement this after reading diffrent ideas for about 4 hours today I am just stuck and confused. any ideas or tips would be helpfull This first block of code is my status page. Code: [Select] <style> tr {font-size:24px;} button {width:120px} </style> <body topmargin="50px"> <?php session_start(); include("../../Connections/db_connection.php"); $table = "shop_inventory"; mysql_select_db("$db_database", $connect); unset ($db_username, $db_password); $currenttime = getdate(); $result = mysql_query("SELECT * FROM shop_inventory WHERE In_Shop='1'"); $test = mysql_fetch_array($result); echo "<table border='1' align='center' style='text-align:center' cellpadding='10' width='100%'> <tr> <th>Asset number</th> <th>Building</th> <th>Room number</th> <th>In date</th> </tr>"; $_SESSION['array_row'] = $test; while($row = mysql_fetch_array($result)) { $style = ''; //if ($currenttime - $row['Entered_Shop_Time'] == 0 || 1) $style = 'style="background-color:#00FF00"'; echo "<tr>"; echo "<td> <button onClick=../subpages/edititems.php>" . $row['Asset'] . "</button> </td>"; echo "<td>" . $row['Building'] . "</td>"; echo "<td>" . $row['Room_Number'] . "</td>"; echo "<td $style>" . date("F j, Y", strtotime($row['Entered_Shop_Time'])) . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($connect); ?> </body> This second block of code is the page where i want to dump the table info into for editing. Code: [Select] <?php session_start(); include("../../Connections/db_connection.php"); $table = "shop_inventory"; mysql_select_db("$db_database", $connect); unset ($db_username, $db_password); //$Asset = $_POST['Asset']; $Session = $_SESSION['array_row']; //$data = mysql_query("SELECT * FROM shop_inventory WHERE Asset=$session"); //$query = mysql_query($data) or die ("Cannot select database." . mysql_error()); //$Session = mysql_fetch_array($data); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add Items</title> </head> <body> <div style=" padding-top:5px;"> <h1><center>Add New Items</center></h1> </div> <form name="myForm" action="afteredititems.php" method="post"> Asset Number: <input type="text" name="Asset" value="<?php echo $Session['Asset']?>"/><br /><br /> Manufactu <input type="text" name="Manufacture" value="<?php echo $Session['Manufacture']?>"/><br /><br /> Model: <input type="text" name="Model" value="<?php echo $Session['Model']?>"/><br /><br /> Serial Number: <input type="text" name="Serial_Number" value="<?php echo $Session['Serial_Number']?>"/><br /><br /> Building: <input type="text" name="Building" value="<?php echo $Session['Building']?>"/><br /><br /> Room Number: <input type="text" name="Room_Number" value="<?php echo $Session['Room_Number']?>"/><br /><br /> <input type="hidden" name="In_Shop" value="1"/> Type of Equipment: <select name="Type" value="<?php echo $Session['Type']?>"> <option value="desktop">Desktop</option> <option value="laptop">Laptop</option> <option value="ipad">Ipad</option> <option value="ipod">Ipod</option> <option value="projector">Projector</option> <option value="printer">Printer</option> </select><br /> <br /> <center><input type="submit" value="Add Item"/></center> </form> </body> </html> And lastly I have a page that redisplays the edited information. Code: [Select] <?php //$Asset = $_POST['Asset']; //$data = mysql_query("SELECT * FROM shop_inventory WHERE Asset=$Asset"); //$query = mysql_query($data) or die ("Cannot select database." . mysql_error()); //$data2 = mysql_fetch_array($data); include("../../Connections/db_connection.php"); $table = "shop_inventory"; mysql_select_db("$db_database", $connect); unset ($db_username, $db_password); $Asset = $_POST['Asset']; $Manufacture = $_POST['Manufacture']; $Model = $_POST['Model']; $Sn = $_POST['Serial_Number']; //<---- possibly fubar check sn everywhere $Building = $_POST['Building']; $Room_Number = $_POST['Room_Number']; $Type = $_POST['Type']; $data = mysql_query("UPDATE `shop_inventory` SET Manufacture='$Manufacture', Model='$Model', Serial_Number='$Sn', Building='$Building', Room_Number='$Room_Number', Type='$Type' WHERE Asset=$Asset"); //$query = mysql_query($data) or die("could not execute query.". mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <!-- display changes --> Asset: <?php echo $Asset ?><br /> Manufactu <?php echo $Manufacture ?><br /> Model: <?php echo $Model ?><br /> Serial number: <?php echo $Sn ?><br /> Building: <?php echo $Building ?><br /> Room Number: <?php echo $Room_Number ?><br /> Type: <?php echo $Type ?><br /><br /> </body> </html> I know there is a lot of poorly formated code and more then likely it is hard to read as I was going to do cleanup after I had all my features working. After doing all the digging i found out about sessions and how they are used to pass data, I thought it would be a good method but I just could not figure out how to send information from the table if the table is reciving its info from an array. any help would be appreciated thanks. Hi guys I am a newbie with PHP and I have been trying to solve this problem for 3 days.. Ive set up a booking form on my website to be sent directly to my email once the client clicked on the send button.. The problem I am having while checking these pages on wamp is that the booking form is ok but when I click on the send button the following message error appears "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\fluffy_paws\booking_form2.php on line 27" When I check online I have this message "500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed." Are my codes wrong??? My webhosting is Blacknight.com , Im on Windows Vista, my internet is a dongle with O2 ireland Thanks for your help! Hello I have a from that updates a few things in the db, and uses "<?php echo $PHP_SELF;?>". The form does update everything fine, however that page does not reflect it. If I refresh the page manually I can see the new values. Is this a common thing, and can anything be done to fix this? Hi guys I'm struggling a bit, I need to replace a word that occurs multiple times in text with an array("up","down","forward","backwards") of words. $find = "left"; $replace = array("up","down","forward","backwards"); $text = "left left left left"; echo str_replace($find,$replace,$text); The Output is: array array array array Did try this with a foreach statement as well, but no luck. Is there a better way of doing this? Thanks Hi all - I am a novice when it comes to PHP, but I have managed to use it successfully many times. I have an issue where I can not get a variable to echo when I am calling it from within a file that is using SSI. Here is a basic example that should explain it better. In the /index.php file: Code: [Select] <?php $photo1="photo1.jpg"; $photo2="photo2.jpg"; ?> <?php include('http://www.DOMAIN.com/includes/header.php'); ?> In the /header.php file: <img src="http://www.DOMAIN.com/photos/<?php echo $photo1; ?>"> When I try to echo $photo1 from within the /header.php file it simply does nothing, even though the variable is declared before the call for the include file. If I try to do the echo with the IMG tag from within the /index.php file, it works no problem -but that wont work without a MAJOR site redesign with how things are configured. Question is, why does this not work, and how can I fix it? Huge thanks from this Newb! Hello, all... I seem to remember, like if I have a problem with a mysql_query() statement, and want find out why it keeps giving me an error, I'm often told to echo out the statement for debugging purposes. Can somebody remind me again how that's done... thanks! cant work out this mysql syntax error "operation":"medupdate","medid":"","name":"ibo","medyear":"5","medmonth":"21","medday":"1","recuser":1,"SuccFail":"fail","SuccFailMessage":"error occured 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 '''WHERE med_id=' at line 2","ResultData":""} Code: [Select] $sql="update metodology set med_description='".$req['name']."', med_year='".$req['medyear']."', med_month='".$req['medmonth']."', med_day='".$req['medday']."', med_recorddate= now(), med_recorduserid= 1'"; $sql.= " WHERE med_id=".$req['medid']; I have written code so that when something from a MySQL field equals 0, then PHP will take no action, and if the field equals anything else, then 'echo "foo"'. The problem I am having is that when PHP echo's nothing (echo ""), its still creating the effect of a HTML <BR>. Screen shots: 1. When the MySQL table contains something else than 0 (echo "foo"). http://i51.tinypic.com/2n7oxo1.png 2. When the table contains 0 (echo ""). http://i53.tinypic.com/2h5jg4k.png 3. What it should look like if the table were to contain 0 (echo ""). Note that their is no <BR> effect. http://i51.tinypic.com/2jdtaf.png Code: $query = "select sizes from products where id='$id'"; $result = mysql_query($query); $data = mysql_fetch_array($result); if ($data['sizes'] == 0) {echo "";} else {echo "Small - ".$data['sizes'];} Is it possible to make it so if a MySQL field result equals 0, then PHP will not produce the HTML <BR> effect when it echo's nothing (echo "")? I am running through a tutorial and I am getting an error based on a the concatication operator on my output. Below is my code. As you can see I am echoing $display_block .= "<p>$title<br>$rec_label<br>.... If I send this as-is I get this error: Notice: Undefined variable: display_block in C:\wamp\www\php\php_mysql\sel_byid.php on line 36 I can resolve the error by placing this before the while loop: $display_block = ""; Is there a better way to output the concatenation.= so I don't need to do this weird fix? while ($row = mysql_fetch_array($result)) { $id = $row['id']; $format = $row['format']; $title = stripslashes($row['title']); $artist_fn = stripslashes($row['artist_fn']); $artist_ln = stripslashes($row['artist_ln']); $rec_label = stripslashes($row['rec_label']); $my_notes = stripslashes($row['my_notes']); $date_acq = $row['date_acq']; if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); } else { $artist_fullname = trim("$artist_ln"); } if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; } $display_block .= "<p>$title<br>$rec_label<br>$artist_fullname<br>$my_notes<br>$date_acq<br>$format</p>"; I am getting the following error when using composer: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? Just started. I am pretty sure composer.json wasn't changed. journalctl doesn't show anything. Maybe Doctrine related, however, nothing seems to help.
Any ideas? [michael@devserver www]$ php -v PHP 7.3.4 (cli) (built: Apr 2 2019 13:48:50) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies with DBG v9.1.9, (C) 2000,2018, by Dmitri Dmitrienko [michael@devserver www]$ composer -V Composer version 1.4.2 2017-05-17 08:17:52 [michael@devserver www]$ yum info composer Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.us.oneandone.net * epel: mirror.rnet.missouri.edu * extras: mirror.us.oneandone.net * remi-php73: mirror.bebout.net * remi-safe: mirror.bebout.net * updates: mirror.us.oneandone.net Installed Packages Name : composer Arch : noarch Version : 1.8.4 Release : 1.el7 Size : 1.8 M Repo : installed From repo : epel Summary : Dependency Manager for PHP URL : https://getcomposer.org/ License : MIT Description : Composer helps you declare, manage and install dependencies of PHP projects, : ensuring you have the right stack everywhere. : : Documentation: https://getcomposer.org/doc/ [michael@devserver www]$ composer update Loading composer repositories with package information Updating dependencies (including require-dev) [ErrorException] "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]... [michael@devserver www]$
This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=318175.0 I know this is stupid newbie stuff, but I can't think about this the right way. And this question might very well make NO sense. If so, I apologize in advance. I'm trying to consolidate code. I basically have lots of quizzes, all with their own answers, which I compare using AJAX. I had individual pages for each quizzes answers to do that comparison and everything was working fine. It would do the following... Code: [Select] <?php $userinput = strval($_GET['userinput']); $userinput= trim($userinput); $userinput = strtolower($userinput); switch ($userinput) { case 'heat': case 'miami heat': echo 'Miami Heat'; exit; case 'magic': case 'orlando magic': echo 'Orlando Magic'; exit; case 'jazz': case 'utah jazz': echo 'Utah Jazz'; exit; default: echo 'incorrectguess'; } ?> But now I am storing the answers in a MySQL database (for example, one answer set is in the database as "Miami Heat/heat/miami"...each allowed answer is separated by a "/", with the first answer being the "main" correct answer). So now, I want to just have ONE "comparison" page and populate the "cases" into that page dynamically, from the database. This is what I came up with so far, but it's not working... Code: [Select] <?php $userinput = strval($_GET['userinput']); $userinput= trim($userinput); $userinput = strtolower($userinput); if ($_GET['quizid'] == "") { redirect_to('index.php'); } else { $quizid=$_GET['quizid']; } $sql = "SELECT * FROM answers WHERE quizid = $quizid"; $result = mysql_query($sql, $connection); if (!$result) { die("Database query failed: " . mysql_error()); } else { switch ($userinput) { while ($results = mysql_fetch_array($result)) { $answers = explode("/", $results['answer']); $n = count($answers); for ($i=1; $i < $n; $i++) { case '$answers[$i]': } echo '$answers[0]'; exit; default: echo 'incorrectguess'; } } ?> What I'm having trouble grasping is where I need to use "echo" or NOT use "echo". For example, where I have "switch ($userinput) {" in the NEW code, does that need to actually be "echo 'switch ($userinput) {';"? I'm trying different combos and failing, so just curious if someone can help me understand what, if anything, needs to be echoed when doing it the 2nd way (dynamic info) rather than the 1st way (static info) Code: [Select] if (empty($_POST['selected_messages'])) message($lang_pms['Must select']); $idlist = array_values($_POST['selected_messages']); $idlist = array_map('intval', $idlist); $idlist = implode(',', array_values($idlist)); // If you're not the owner of the message, you can't delete it. $result = $db->query('SELECT DISTINCT sender_id FROM '.$db->prefix.'messages WHERE id IN ('.$idlist.') AND folder="sent" ') or error('Unable to delete the message', __FILE__, __LINE__, $db->error()); Okay, as you can see it makes intval for all the $_POST['selected_messages'] , but the problem is, when I use tamper data and just add a form field "selected_messages" it brings up a mysql error and the $idlist is blank.. so is there a way to make sure that the $_POST['selected_messages'] has to equal 'selected_messages[]' OR show error? people can just tamper data and use selected_messages without the [] and it brings up a mysql error, that's not good, I don't want users seeing my code edit: WOW Code: [Select] if (empty($idlist)){ message("No Permission"); } fixed it sorry How do i get the page to echo a message after my user's have registered? i was thinking it goes under the query like this, am i correct?: Code: [Select] $query ="INSERT INTO `companies` (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone, email, premiumuser_description, username, password, salt, approved, upload) VALUES ('$company_name', '$what_services', '$website', '$contact_name', '$location', '$postcode', '$street1', '$street2', '$city', '$phone', '$email', '$premiumuser_description', '$username', '$password', '$salt', '$approved', '$upload')"; $result = mysql_query($query) or die(mysql_error()); if ($result) { echo('Thanks, your now registered'); using the if statement? any help would be appreciated, many thanks. Hello, I am guessing that this is a totally noob question and I am sorry about it. I am not someone who is familiar with php. I just can see what code says sometimes. I have a wordpress file which I wanted to edit. I was successful until I hit this line of code. <?php echo "\n" . installedtheme::frontSections( ); ?> This code is responsible for entire front page structure. When I delete this line my front page gets empty. In html side I can see </section> parts which I want to exclude but select what to exclude from code. I am guessing this echo calling a file that is told as front sections. I am lost. Is there any way to find and edit this file?
Thanks for help. |