PHP - What's Wrong With My "is_null" Statement?
(Please ignore HTML formatting)
Code: [Select] if (is_null($RESULT['PBS_ACCOUNT_ID'])) { echo "<font size=2 color=#000000 face=arial> <</font>"; echo "<font size=2 color=#000000 face=arial>PBS_ACCOUNT_ID</font>"; echo "<font size=2 color=#000000 face=arial>></font>"; echo "<font size=2 color=#000000 face=arial>HELLO</font>"; echo "<font size=2 color=#000000 face=arial><</font>"; echo "<font size=2 color=#000000 face=arial>/PBS_ACCOUNT_ID</font>"; echo "<font size=2 color=#000000 face=arial>></font>"; } else { echo "<font size=2 color=#000000 face=arial> <</font>"; echo "<font size=2 color=#000000 face=arial>PBS_ACCOUNT_ID</font>"; echo "<font size=2 color=#000000 face=arial>></font>"; echo "<B>"; echo $RESULT['PBS_ACCOUNT_ID']; echo "</B>"; echo "<font size=2 color=#000000 face=arial><</font>"; echo "<font size=2 color=#000000 face=arial>/PBS_ACCOUNT_ID</font>"; echo "<font size=2 color=#000000 face=arial>></font>"; echo "<BR>"; } If the PBS_ACCOUNT_ID field is empty, it just shows blank. Why doesn't it echo "HELLO?" Or should I be using "IS_EMPTY?" Similar TutorialsCan 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> 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 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! 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 Here's my code, whenever I try to fill the form it gives me that error "Oops! Something went wrong. Please try again later"
Code: <?php // Include config file require_once "config.php"; // Define variables and initialize with empty values $CodEntrega = $CodCliente = $Dia = $Pagamento = $Funcionario = ""; $CodEntrega_err = $CodCliente_err = $Dia_err = $Pagamento_err = $Funcionario_err = ""; // Processing form data when form is submitted if($_SERVER["REQUEST_METHOD"] == "POST"){ // Validate name $input_CodEntrega = trim($_POST["CodEntrega"]); if(empty($input_CodEntrega)){ $CodEntrega_err = "Insira o codigo de entrega"; } else{ $CodEntrega = $input_CodEntrega; } // Validate address $input_CodCliente = trim($_POST["CodCliente"]); if(empty($input_CodCliente)){ $CodCliente_err = "Insira o codigo do cliente"; } else{ $CodCliente = $input_CodCliente; } // Validate salary $input_Dia = trim($_POST["Dia"]); if(empty($input_Dia)){ $Dia_err = "Insira a data da entrega"; } else{ $Dia = $input_Dia; } $input_Pagamento = trim($_POST["Pagamento"]); if(empty($input_Pagamento)){ $Pagamento_err = "Insira o tipo de pagamento"; } else{ $Pagamento = $input_Pagamento; } $input_Funcionario = trim($_POST["Funcionario"]); if(empty($input_Funcionario)){ $Funcionario_err = "Insira o codigo do funcionario"; } else{ $Funcionario = $input_Funcionario; } if(empty($CodEntrega_err) && empty($CodCliente_err) && empty($Dia_err) && empty($Pagamento_err) && empty($Funcionario_err)){ $sql = "INSERT INTO entrega(CodEntrega, CodCliente, Dia, Pagamento, Funcionario) VALUES (?, ?, ?, ?, ?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "ssdss", $param_CodEntrega, $param_CodCliente, $param_Dia, $param_Pagamento, $param_Funcionario); // Set parameters $param_CodEntrega= $CodEntrega; $param_CodCliente = $CodCliente; $param_Dia = $Dia; $param_Pagamento = $Pagamento; $param_Funcionario = $Funcionario; if(mysqli_stmt_execute($stmt)) { header("location: home.html"); exit(); } else { echo "Oops! Something went wrong. Please try again later."; } } // Close statement mysqli_stmt_close($stmt); } // Close connection mysqli_close($link); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Projeto TW</title> <link rel="stylesheet" href="css/milligram.css"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> * { box-sizing: border-box; } body { font-family: Arial, Helvetica, sans-serif; } /* Style the header */ header { background-color: #B0171F; padding: 30px; text-align: center; font-size: 35px; color: white; } /* Create two columns/boxes that floats next to each other */ nav { float: left; width: 30%; height: 300px; /* only for demonstration, should be removed */ background: #ccc; padding: 20px; } /* Style the list inside the menu */ nav ul { list-style-type: decimal; padding: 0; } article { float: left; padding: 20px; width: 70%; background-color: #f1f1f1; height: 300px; /* only for demonstration, should be removed */ } /* Clear floats after the columns */ section::after { content: ""; display: table; clear: both; } /* Style the footer */ footer { background-color: #B0171F; padding-top: 7px; padding-bottom: 7px; text-align: middle; color: white; position: relative; bottom: 0; } #content-wrap { padding-bottom: 2rem; /* Footer height */ } #page-container { position: relative; } @media (max-width: 600px) { nav, article { width: 100%; height: auto; } } .dropbtn { background-color: #4CAF50; color: white; padding: 16px; font-size: 16px; border: none; } .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f1f1f1; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { color: black; padding: 12px 16px; text-decoration: none; display: block; } .dropdown-content a:hover {background-color: #ddd;} .dropdown:hover .dropdown-content {display: block;} .dropdown:hover .dropbtn {background-color: #3e8e41;} </style> </head> <body> <header> <div class="head1">PROJETO DE TW</div> <div class="head2">Gestão de uma BD</div> </header> <div class='container'> <div class='navbar'> <ul> <li><a class="active" href="home.html">Home</a></li> <li><a href="#consultar">Consultar</a></li> <li><a href="tabela.html">Inserir</a></li> <li><a href="#alterar">Alterar</a></li> <li><a href="#eliminar">Eliminar</a></li> </ul> </div> <div class = "body_sec"> <section id="Content"> <h3>INSERIR DADOS DE ENTREGA</h3> <button type="button" >ENTREGA</button> </section> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post"> <div class="form-group"> <label>CodEntrega</label> <input type="text" name="CodEntrega" class="form-control <?php echo (!empty($CodEntrega_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodEntrega; ?>"> <span class="invalid-feedback"><?php echo $CodEntrega_err;?></span> </div> <div class="form-group"> <label>CodCliente</label> <input type="text" name="CodCliente" class="form-control <?php echo (!empty($CodCliente_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $CodCliente; ?>"> <span class="invalid-feedback"><?php echo $CodCliente_err;?></span> </div> <div class="form-group"> <label>Dia de Entrega</label> <input type="date" name="Dia" class="form-control <?php echo (!empty($Dia_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Dia; ?>"> <span class="invalid-feedback"><?php echo $Dia_err;?></span> </div> <div class="form-group"> <label>Pagamento</label> <input type="text" name="Pagamento" class="form-control <?php echo (!empty($Pagamento_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Pagamento; ?>"> <span class="invalid-feedback"><?php echo $Pagamento_err;?></span> </div> <div class="form-group"> <label>Codigo do Funcionario</label> <input type="text" name="Funcionario" class="form-control <?php echo (!empty($Funcionario_err)) ? 'is-invalid' : ''; ?>" value="<?php echo $Funcionario; ?>"> <span class="invalid-feedback"><?php echo $Funcionario_err;?></span> </div> <input type="submit" class="btn btn-primary" value="Submit"> <a href="home.html" class="btn btn-secondary ml-2">Cancel</a> </form> </div> </div> </div> </div> </body> </html>
Edited May 10 by Barand code tags added 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 a "best practices" question. Visitors are limited to a maximum of 5 shipping labels per day, so mySQL counts how many were created in the past 24 hours and logs them. Which "style" is better? ### Style #1 ##################### $labelCounter = $db->prepare("SELECT count(*).. // mySQL counts labels if($numberoflabels < 5) {
// RUN BIG CURL SCRIPT IF LESS THAN 5 LABELS $log = $db->prepare("INSERT into label_counter... // log the good label } else { // don't run big curl script echo "Sorry visitor, no label could be created"; } ### Style #2 ##################### $too-many-labels = FALSE; $labelCounter = $db->prepare("SELECT count(*) // mySQL counts labels
if($numberoflabels > 4) { if ($too-many-labels == FALSE) {
// RUN BIG CURL SCRIPT IF LESS THAN 5 LABELS } else { // don't run big curl script echo "Sorry visitor, no label could be created"; } Style # 1 seems more direct, but Style 2 somehow "looks safer." Which is really better? What are your thoughts, please? 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!
Question:
Background:
Example: The Pacific ("Los Angeles") time right now is 7:58pm, but my code says it's 6:58pm. So now I have to go in and correct the "PT8H" portion. I'm wondering if there is some code I can use whereby I can simply "set it and forget it." Thank you! Edited May 2, 2020 by StevenOliverAs the title says, I'm looking for a better way to create a switch statement on an "edit" form. Since there are 3 of the same types of <selects>, all using the values of US states. Billing state, shipping state, drivers license state. Currently I am using this: switch($row['pri_add4']){ case 'AK': $pri_add4 = '<option value="AK" selected="selected">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'AL': $pri_add4 = '<option value="AK">AK</option><option value="AL" selected="selected">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'AR': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR" selected="selected">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'AZ': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ" selected="selected">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'CA': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA" selected="selected">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'CO': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO" selected="selected">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'CT': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT" selected="selected">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; case 'DC': $pri_add4 = '<option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC" selected="selected">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option>'; break; } NOTE: I had to remove a lot of the state options so the post wouldn't exceed the 40000 characters limit. Why is this not working? I can not seem to incorporate and into the statement $query = "SELECT * FROM Project_Registrations WHERE (First_Name = '$_POST[name_1]' AND Teacher = '$_POST[teacher]' AND School = '$_POST[school]') OR (Second_Name = '$_POST[name_1]' AND Teacher = '$_POST[teacher]' AND School = '$_POST[school]') OR (First_Name = '$_POST[name_2]' AND Teacher = '$_POST[teacher]' AND School = '$_POST[school]') OR (Second_Name = '$_POST[name_2]' AND Teacher = '$_POST[teacher]' AND School = '$_POST[school]') "; Thanks Ok, I am not sure if I can explain it correctly, but here it goes. I have a form where user is asked to enter up to three name. Let's say that the fields are called [name1], [name2] and [name3] and they are called the came in the table. Now I have a code which allows me to compare what names are in the database versus the name that was entered by the user. $query = "SELECT * FROM Project_Registrations WHERE name1= '$_POST[name1]' "; $result2 = mysql_query($query); if (mysql_numrows($result2) > 0) { while($row = mysql_fetch_array($result2)) {echo" ...error code... ";} } else { ...ok code... }; This works well for one name field but I have three in the form and three in the table. How do I define it so all three name fields in the form are compared to all three in the table and if just on matches I can give them the ...error code...? Oh, and they can enter up to three names in the form, but it could be two or one. Can I code it such: $query = "SELECT * FROM Project_Registrations WHERE name1= '$_POST[name1]' OR name1= '$_POST[name2] OR name1= '$_POST[name2]' OR ...'"; Thanks Hi and thanks for taking the time to read through this first and foremost. I have a bit of code that I have managed to piece together with help from other sites and what it does is connect to our local ms sql server and retrieve a few tables from our database. The info is relating to property management and it basically displays the unit address, current date and its rental status. (Occupied or Vacant) This makes it easy for us to at a glance check the status of our rentals instead of having to log into our software and navigate through all that.. anyways, I have two issues I need help with. First problem, in my code, is it possible to write a conditional statement that would check for a certain status in a view and then if it is there, print a simple yes or no in a table with that appropriate property. For example, we have property 1000 name street and it is currently vacant, however the viewPendingLease shows us information regarding future bookings. I would like to be able to look through that view with the code, check property 1000 name street for any future pending leases, and if there is one, print out a "Yes" in a Future Booked column that I would create. If any of that makes sense, I can post the print out of the tables of the viewPendingLease if it makes it easier for anyone to see the data output to understand what I am meaning. The second issue, is it possible to change the color of the text according to a variable, say a word in a generated table with html or css? I would like to color the words vacant or occupied green and red respectively just to make it much easier to zero in on the vacant properties. Or even maybe just color every other row a background color just to help distinguish between the different properties. Here is my code that pulls up my current tables to show Property, Street and current rented status. Code: [Select] <?php //connect to a DSN "*******" $conn = odbc_connect('*******','*****','************'); if ($conn) { //the SQL statement that will query the database $query = "Select unit.PropertyUnitID, unit.Street, unit.Status, from unit"; //perform the query $result=odbc_exec($conn, $query); echo "<table border=\"1\"><tr>"; //print field name $colName = odbc_num_fields($result); for ($j=1; $j<= $colName; $j++) { echo "<th>"; echo odbc_field_name ($result, $j ); echo "</th>"; } //fetch tha data from the database while(odbc_fetch_row($result)) { echo "<tr>"; for($i=1;$i<=odbc_num_fields($result);$i++) { echo "<td>"; echo odbc_result($result,$i); echo "</td>"; } echo "</tr>"; } echo "</td> </tr>"; echo "</table >"; //close the connection odbc_close ($conn); } else echo "odbc not connected"; ?> I currently have the viewPendingLease.Active (which shows if there is a future pending lease) taken out due to a repeating data issue I am also trying to figure out... 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 Hi, I currently have an if, elseif, else program that starts off with Code: [Select] if( $v_name == "" || $v_msg == "" ) echo "something" how do I turn this into a switch? but the very next elseif I have Code: [Select] elseif( strcspn( $_REQUEST['msg'], '0123456789' ) == strlen( $_REQUEST['msg'] ) ) echo "something" is it possible to turn this into a switch with 2 different strings like that to evaluate? I have a registration form on my website and after Registration I want the user to activate first his account. I don't have problem on sending this email to the user. What I want to appear is like this.. GoodDay "username", Blah Blah! how can you actually do that? I know that you can do that through session variables but the thing is email's can't accept scripts on sending emails. how can I get the value from a session variable for example and convert it to plain html text so that i can OUTPUT it to the email.. HELP PLEASE! This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=347922.0 I have a script in where I need to push as a conformation, I have the script written... Code: [Select] echo '<p>Your comments have been successfully entered. Would you like to <a href="1-1.php' . $_GET['id'] . '">view the final report</a>?</p>'; The problem is that there is no '=' sign between the php and the ID... is there a way to make it so that it shows up? I have a "switch statement" that is a bit ridiculous switch($row['warr_Ext_Term']) { case '24 month / 24,000 miles': $month24 = date('Y-m-d',strtotime($date_sold . '+730 days')); $warr_Ext_Exp_Date = substr($month24, 5, 2).'-'.substr($month24, 8, 2).'-'.substr($month24, 2, 2); $warr_Ext_Exp_Miles = number_format($row['mileage'] + 24000).' miles'; $today = date('Y-m-d'); if ($month24 > $today) { $warr_Ext_Exp_Text = 'Expires'; } else { $class = 'red'; $warr_Ext_Exp_Text = '<span class="'.$class.'">Expired</span>'; } break; } $warr_Ext_Cmpy = ' <li><label>Extended</label>'.$row['warr_Ext_Cmpy'].'</li> <li><label>Term</label>'.$row['warr_Ext_Term'].'</li> <li><label>Contract #</label>'.$row['warr_Ext_Num'].'</li> <li><label>'.$warr_Ext_Exp_Text.'</label><span class="'.$class.'">'.$warr_Ext_Exp_Date.'</span><br><label> </label><span class="'.$class.'">'.$warr_Ext_Exp_Miles.'</span></li>' ; What it does is determines when a customers warranty expires, or when it did expire based on the miles that they bought the vehicle at, and based on today's date. The problem is that I sell numerous warranties from 9 days, 4,500 miles up to 120 months, 100,000 miles. Is there a better way to write this, based on the info pulled from the "$row['warr_Ext_Term']" row? Any help would be greatly appreciated... |