PHP - If Statement Not Working
Hello guys,
I am having an issue with my if statement. Basically what I am trying to do is when there are no photos uploaded then enter default image. Like I said doesn't look like my if stmt is working at all.. Any ideas? foreach (glob("temp_photo/$subn*.*") as $filename) { //echo "$filename<br>"; $string = $filename; $filename2 = basename($string); if($filename2 == ""){ $filename2="/images/default.jpg"; } // Insert ad details into mysql $query = "INSERT INTO ads (ad_type,ad_title,ad_body,ad_category,ad_photo,ad_member,ad_status,ad_city,ad_state,ad_zip)VALUES('".$ad_type."','".$ad_title."','".$ad_body."','".$catid."','".$filename2."','".$vname."','".$ad_status."','".$city."','".$state."','".$zip."')"; // Error checking to see if the query was successful $result = mysql_query($query) or die (mysql_error()."in <br>$query" ); Similar TutorialsI'm having issues with the following: Code: [Select] <?php session_start(); $_SESSION['username']=$_POST['username']; $_SESSION['password']=$_POST['password']; if($_SESSION['username']=="username" && $_SESSION['password']=="password"){ if($_GET['product']=="add"){ $content.=' <p><label>Product Name:</label> <input type="text" name="product_name" size="30" /> <label>Product Price:</label> <input type="text" name="product_price" size="5" /> </p> <p><label>Product Category:</label> <input type="text" name="product_category" size="30" /></p> <p><label>Product Link:</label> <input type="text" name="product_link" size="30" /></p> <p><label>Product Image:</label> <input type="text" name="product_image" size="30" /></p> <p><label>Product Tag:</label> <input type="text" name="product_tag" size="30" /></p> <p><label>Product Keywords:</label> <input type="text" name="keyword" size="30" /></p> <p><label>Product Features:</label><br /> <textarea name="product_features" rows="10" cols="60"></textarea> </p> <p><label>Product Pros:</label><br /> <textarea name="product_pros" rows="5" cols="30"></textarea> </p> <p><label>Product Cons:</label><br /> <textarea name="product_cons" rows="5" cols="30"></textarea> </p> <p><label>Product Description:</label><br /> <textarea name="product_description" rows="10" cols="60"></textarea> </p> <p><label>Product Notes:</label><br /> <textarea name="product_notes" rows="5" cols="30"></textarea> </p> '; $logout='<div><a href="./acp_admincp.php?log-out">Log-Out</a></div>'; } elseif($_GET['product']=="view"){ } else{ $content.=' <a href="./admincp.php?product=add">Add New Product</a> <br /> <a href="./admincp.php?product=view">View Products</a> '; } } elseif(isset($_GET['log-out'])){ session_start(); session_unset(); session_destroy(); header("Location: ./admincp.php"); } else{ $content=' <form action="./admincp.php" method="post"> <p><label>Username:</label> <input type="text" name="username" size="30" />'; $content.='</p> <p><label>Password:</label> <input type="password" name="password" /></p>'; $content.='<p><input type="submit" value="Submit" name="Submit" /></p> </form>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <base href="http://ghosthuntersportal.com/" /> <title>Ghost Hunter's Portal - Admin Control Panel</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="verify-v1" content="" /> <meta name="keywords" content="ghost, hunters, hunter, ghosts, spirit, spirits, paranormal, investigation, investigator, investigators, k2, emf, meter, kii" /> <meta name="description" content="Ghost Hunters Potal. Parnormal research equipment store." /> <meta name="author" content="Andrew McCarrick" /> <meta name="robots" content="index, follow" <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <img src="./logo.png" alt="Ghost Hunter's Portal Admin Control Panel" /> <br /> <div style="color: #AA44AA; font-size: 26px; margin-top: -30px; margin-left: 125px;">Admin Control Panel</div> <?php echo $logout; echo $content; ?> </body> </html> I can log-in, and get to the page with the two links on it. However, once I click one of the links it falls back to the log-in page, and it ends up being a never ending loop. It's doing this: Log-In --> Page with links ---> Log-In page again Should be doing this: Log-In --> Page with links --> Add Product page or View Products page I can never get into the the actual sub page. Just to be clear, the address bar actually shows product=add or product=view, but it still shows the log-in page. So the issue I'm having here is that when champion_id, contender1_id, contender2_id, and contender3_id values are 0 then it DOES NOT echo Vacant and TBD as it should be, however when they are values other than 0 then it does correctly show the person's name. What am I doing wrong for it to not display the Vacant or TBD? Code: [Select] $query = "SELECT titles.title_name, titles.id, title_champions.champion_id AS champion_id, title_champions.contender1_id AS contender1_id, title_champions.contender2_id AS contender2_id, title_champions.contender3_id AS contender3_id, champion.character_name AS champion, contender1.character_name AS contender1, contender2.character_name AS contender2, contender3.character_name AS contender3 FROM title_champions LEFT JOIN titles ON title_champions.title_id = titles.id LEFT JOIN characters AS champion ON title_champions.champion_id = champion.id LEFT JOIN characters AS contender1 ON title_champions.contender1_id = contender1.id LEFT JOIN characters AS contender2 ON title_champions.contender2_id = contender2.id LEFT JOIN characters AS contender3 ON title_champions.contender3_id = contender3.id ORDER BY titles.title_name"; $result = mysqli_query ( $dbc, $query ); // Run The Query Code: [Select] <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo '<tr><td>' . $row['title_name'] . '</td><td>'; if($row['champion_id'] !== 0){echo $row['champion'];}else{echo "Vacant";} echo '</td><td>'; if($row['contender1_id'] !== 0){echo $row['contender1'];}else{echo "TBD";} echo '</td><td>'; if($row['contender2_id'] !== 0){echo $row['contender2'];}else{echo "TBD";} echo '</td><td>'; if($row['contender3_id'] !== 0){echo $row['contender3'];}else{echo "TBD";} echo '</td><td style="text-align:center;"><img src="img/notepad.png" class="edit" rel="' . $row['id'] . '"/></td></tr>'; } ?> i have been trying to figure this out for the last hour with no luck i am hopeing some one here can help me the problem is well i really dont know what the problem is but the code should check is the passwords match if they dont it will tell you to reenter your password if(isset($_POST['Submit'])) //isset open { $pass1=$_POST['pass1']; $pass2=$_POST['pass2']; if($pass1 != o) //pass open { echo"<style type='text/css'> <!-- body { background-color: #FFFFFF; } body,td,th { color: #000000; } --> </style></head> <body> <table width='100%' border='1'> <tr> <td><center>Your Password Did Not Match Please Reenter Your Passwrods</center></td> </tr> <tr> <td><form id='form1' name='form1' method='post' action=''> <label>Password <input type='text' name='pass1' id='pass1' /> </label> </td> </tr> <tr> <td> <label>Enter Password Again <input type='text' name='pass2' id='pass2' /> </label> </td> </tr> <tr> <td> <label> <center><input type='submit' name='Submit' id='Submit' value='Submit' /></center> </label> </form> </td> </tr> </table> </body>"; die(); //pass colse } else //pass else open { echo" <form name='redirect'> <center> <font face='Arial'><b>Your Account Has Been Validated You Will Now Be Redirect To The Admin Home Page in<br><br> <form> <input type='text' size='3' name='redirect2'> </form> seconds</b></font> </center> <script> <!-- //change below target URL to your own var targetURL='/test1' //change the second to start counting down from var countdownfrom=5 var currentsecond=document.redirect.redirect2.value=countdownfrom+1 function countredirect(){ if (currentsecond!=1){ currentsecond-=1 document.redirect.redirect2.value=currentsecond } else{ window.location=targetURL return } setTimeout('countredirect()',1000) } countredirect() //--> </script>"; //pass else close } //isset close } what i'm trying to do, is have it so a staff member can mange users i came up with these, but it dosn't show on the page :S if ( isadmin ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an admin. You may <a href="manage_users.php" title="manage users">manage users</a> or <a href="admin_settings.php" title="edit site settings">edit site settings</a>. <? if ( ismod ( $_SESSION['user_id'] ) ): ?> <br /> It seems that you're an mod. You may <a href="manage_users.php" title="manage users">manage users</a>. <?php endif; ?> Ok, a bit of a background into my code, It runs off of 2 different passing variables, I have it set up with multiple if() statements to do certain things based on the inputs... Here is a snipet of my code if ($_REQUEST['postal'] != "" && $_REQUEST['lbs'] != "") { $postal = $_REQUEST['postal']; $lbs = $_REQUEST['lbs']; $type = $_REQUEST['type'] if ($type == "splist") { $ztype = "cansp_zone" ; } else { $ztype = "canmp_zone"; } Obviously not the whole thing, Now what you see is line 18-26 of a 216 line document. The nested if statement is what is causing the problem, I get a "syntax error, unexpected T_IF" on line 22, the "if ($type)" line. Now theoretically, if I did not pass the variables (in which case the primary if statement would be false) It should bypass this whole section, however its not. Any ideas? I am thinking its not actually doing the verification and outputting the error because type is not defined. Hi there im having trouble with my If statement in that its not doing what it is suppose to do! I have a do loop that and If statament that checks that resultp < results. If it is less then an echo is suppose to happen, but its not. Im getting notice errors: Undefined index: Class1- 4 but nothing is outputted. I checked the records in the database so the condition will happen but nothings happening. Help Code: [Select] <?php do { ?> <?php echo $row_resultp['Class1_totla']; echo ' Class 1'; echo'<br>'; echo $row_resultp['Class2_totla']; echo ' Class 2'; echo'<br>'; echo $row_resultp['Class3_totla']; echo ' Class 3'; echo'<br>'; echo $row_resultp['Class4_totla']; echo ' Class 4'; echo'<br>';echo'<br>';echo'<br>'; echo $row_results['Class1_totlas']; echo ' Class 1'; echo'<br>'; echo $row_results['Class2_totlas']; echo ' Class 2'; echo'<br>'; echo $row_results['Class3_totlas']; echo ' Class 3'; echo'<br>'; echo $row_results['Class4_totlas']; echo ' Class 4'; if ($row_resultp['Class1'] < $row_results['Class1']){ echo 'you need'; echo $row_resultp['Class1'] - $row_results['Class1']; echo 'more'; } if ($row_resultp['Class2'] < $row_results['Class2']){ echo 'you need'; echo $row_resultp['Class2'] - $row_results['Class2']; echo 'more';} if ($row_resultp['Class3'] < $row_results['Class3']){ echo 'you need'; echo $row_resultp['Class3'] - $row_results['Class3']; echo 'more'; } if ($row_resultp['Class4'] < $row_results['Class4']){ echo 'you need'; echo $row_resultp['Class4'] - $row_results['Class4']; echo 'more'; } ?> <?php } while ($row_resultp = mysql_fetch_assoc($resultp) && ($row_results = mysql_fetch_assoc($results))); ?> Hello Everyone, From time to time, I get into a situation where my if statements do not give the desired results. I always have to play around with them to get the things working. I'm in same situation right now. I'm guessing that I do not completely understand the logic. If someone can take a look at the code below and tell me what's wrong, it will be greatly appreciated. if($_SESSION['account_type'] != 'internal admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } elseif($_SESSION['account_type'] != 'super admin'){ die('<font color="red"><b>Error:</b> This page can only be accessed by internal or super admin.</font>'); break; } I have echoed out the $_SESSION['account_type'] and I'm getting "internal admin" but for some reason, I'm getting the error "Error: This page can only be accessed by internal or super admin." Thanks in advance for your help. Jatt Surma $sql_my_workers = mysql_query("SELECT * FROM Worker WHERE mem_id='$id'"); $my_workers_result = mysql_num_rows($sql_my_workers); while($get_my_workers = mysql_fetch_array($sql_my_workers)){ $my_worker_firstname = $get_my_workers['firstname']; $my_worker_lastname = $get_my_workers['lastname']; $my_worker_age = $get_my_workers['age']; $my_worker_yearspro = $get_my_workers['yearspro']; $my_worker_promotion = $get_my_workers['promotion']; if ($my_workers_result < 1){ $my_workers = " <p class='text' align='center'>You have not created any workers.</p> "; } else { $my_workers .= " <div class='worker_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$my_worker_firstname $my_worker_lastname</p> </div> <div class='worker_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$my_worker_age</p> </div> <div class='worker_promo' align='center'> <p class='text3' style='font-weight: bold; '>Promotion</p> <p class='text3'>$my_worker_promotion</p> </div> <div class='worker_contract' align='center'> <p class='text3' style='font-weight: bold; '>Contract</p> <p class='text3'>-</p> </div> <div class='worker_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$my_worker_yearspro</p> </div> <div class='line'></div>"; } } // connect to the database include_once ("Scripts/mysql_db_connect.php"); // get free agents $sql_free_agents = mysql_query("SELECT * FROM Worker WHERE mem_id!='$id'"); $free_agents_result = mysql_num_rows($sql_free_agents); while($get_free_agents = mysql_fetch_array($sql_free_agents)){ $free_agent_firstname = $get_free_agents['firstname']; $free_agent_lastname = $get_free_agents['lastname']; $free_agent_age = $get_free_agents['age']; $free_agent_yearspro = $get_free_agents['yearspro']; if ($free_agents_result < 1){ $free_agents = "<p class='text'>There are no free agents.</p>"; } else { $free_agents .= "<div class='fa_name' align='center'> <p class='text3' style='font-weight: bold; '>Name</p> <p class='text3'>$free_agent_firstname $free_agent_lastname</p> </div> <div class='fa_age' align='center'> <p class='text3' style='font-weight: bold; '>Age</p> <p class='text3'>$free_agent_age</p> </div> <div class='fa_yearspro' align='center'> <p class='text3' style='font-weight: bold; '>Years Pro</p> <p class='text3'>$free_agent_yearspro</p> </div> <div class='fa_previouspromo' align='center'> <p class='text3' style='font-weight: bold; '>Previous Promotion</p> <p class='text3'>-</p> </div> <div class='fa_reasonleftpromo' align='center'> <p class='text3' style='font-weight: bold; '>Reason for Leaving</p> <p class='text3'>-</p> </div> <div class='fa_salary' align='center'> <p class='text3' style='font-weight: bold; '>Salary</p> <p class='text3'>-</p> </div> <div class='line'></div>"; } } When I do the if < 1 statement, it comes back blank. The if $my_workers_result comes back as showing 0. So it should do that if statement, but yet it doesn't, its just blank. What am I doing wrong? $query_rsGetOrderDetails = "SELECT * FROM hd_order WHERE order_by = '$usernameLoggedin' ORDER BY order_id DESC LIMIT 3"; Any ideas? now i am trying to get this to work it should change the variable if the statement is ture and it not in that and any one help include'db.php'; $sql2=mysql_query("SELECT * FROM site_config WHERE id=1")or die(mysql_error()); while($row2=mysql_fetch_array($sql2)) { $paypal_email=$row2['paypal_email']; $price=$row2['price']; $sandbox=$row2['sandbox']; $account_number=$row2['account_number']; $quantity_1=$row2['quantity_1']; $product=$row2['product']; $return_url=$row2['return_url']; $demo=$row2['demo']; if($sandbox==1) { $link='http://www.sambob.info'; if(empty($sandbox)) { $link='http://www.bob.tdsnet.org'; } echo"$link<br>$sandbox"; } } Absolutely no idea why my IF statement's playing up - needs some fresh eyes I think! if ($postcheck != $post){ if ($x == "0"){ echo $title; echo "<br>"; $x = "1"; $y = $y + 1; } echo "Change Post to: "; echo $postcheck; echo " from "; echo $post; echo "<br>"; $result2 = mysql_query("UPDATE items SET Post='$postcheck' WHERE ID='$id'") or die(mysql_error()); } When it returns $postcheck and $post, in this case, they're coming out as the same thing (on one record - no others!) - $post is retrieved from a database, and $postcheck is calculated. Both are numbers. Any ideas?! Why is my code below not working properly? I've tried it with == instead of = and it still doesn't work. I've verified using echo statements that $row['name'] = $_POST['name'] and $row['password'] = $_POST['password'] for one of the people in my database, but it still gives the message "Login or password wrong!" Thanks a lot for any help, here is the relevant part of my code (counterInt is defined to be 0 further up): while($row = mysql_fetch_array( $result )) { if($row['name'] = $_POST['name'] & $row['password'] = $_POST['password']) { $counterInt++; session_start(); $_SESSION['name']=$row['name']; } } if(counterInt == 1) { header( 'Location: http://simbazeviangame.99k.org/game.php' ); } if(counterInt == 0) { echo "Login or password wrong!"; } I am using the following request on my site (index.php) Code: [Select] $compass = $_REQUEST['compass']; I wanted to use an if statement to echo an error message if $compass was anything other than north,east,south or west. However the code im using is constantly displaying the error message even when /index.php?compass=north etc. Can anyone see what I have done wrong? Code: [Select] if (($compass != "north") || ($compass != "east") || ($compass != "south") || ($compass != "west")) { echo '<strong>Stop cheating!</strong>'; } Believe me!! I have looked and tried so many snippets of code I am exausted! TableName: keywords Row: id productid keywords Good morning... I have been struggling with update, I dont know why... it seems easy eneough and it dosent look that different than a simple insert. Would someone please take a look at the if statement below, more specificly the update section. I am getting an error (Parse error: syntax error, unexpected T_STRING in...... ). Code: [Select] <? $keywd = substr(implode(",", array_keys($arr_tem)),0,200); $productid = intval($_GET['product_id']); // Make a MySQL Connection mysql_connect("localhost", "xxxxxxxxx", "xxxxxxxxx") or die(mysql_error()); mysql_select_db("xxxxxxxxx") or die(mysql_error()); $get = "SELECT * FROM keywords WHERE productid = $productid"; $SQ_query = mysql_query($get) or die("Query failed: $get\n" . mysql_error()); $fetch = mysql_fetch_array($SQ_query); $id = $fetch['productid']; $key = $fetch['keywords']; // Evaluates to true because $var is empty if (empty($id)) { mysql_query("insert into keywords (productid, keywords) VALUES('$productid','$keywd')"); } else{ if (isset($id)) { echo '$var is set even though it is empty'; $mysql_query = mysql_query(UPDATE keywords SET keywords = '$keywd' WHERE productid = '$productid'); // $mysql_query = mysql_query(UPDATE keywords set keywords = "$keywd" WHERE productid = "$productid"); } endif; ?> Hi, I asked a question about Tokens earlier. After debugging I've found the reason as to why my program isn't working. It's related to this statement: if($token == $_SESSION['token']) { ........; return true; }$token is generated in form using md5(uniqid()). When I echo both $token and $_SESSION['token'] before the if statement they both turn out to be the same. Yet for some reason the if statement is not being satisfied and is not returning true as it's supposed to do. (I've tried $token === $_SESSION['token'] as well.) I don't know if some kind of type casting or other is required for the conditional statement to work. Would be grateful for any suggestions. Edited by mac_gyver, 30 October 2014 - 10:53 PM. removed links from copied text I have <?php /** This file is responsible for processing all the add and modify requests for the movies, games and customer section of the admin page. The various functions here can be called into the pages we need inorder to make code management cleaner and easier to handle. **/ include('databaseconfig.php'); //Add a new customer to the data base. $query = mysql_query("update customer set customer_id = '" .$_POST['cust_id'] . "', first_name = '" .$_POST['fname'] . "', last_name = '" .$_POST['lastname'] . "', adress = '" .$_POST['address'] . "', postal_code= '" .$_POST['postalcode'] . "', phone_number= '" .$_POST['phonenumber'] . "', user_name = '" .$_POST['fname'] . "', user_pass = '" .$_POST['lastname'] . "'"); echo("<h1>Output</h1>"); echo($query); echo("<h1>Possible Errors</h1>"); //Echo errors echo mysql_errno($query) . ": " . mysql_errno($query); ?> Which should get the information from the forum feilds and insert that into the data base, throwing errors if I left feilds null. But when I run it and leave everything blank and hit submit or even actually enter the required data all I get is a page that states Code: [Select] Output Possible Errors : Hello PHP Wizards, i wonder if anyone can help, Ive got an associative array set up with a bunch of items, the idea is to compare the array items with items from a form using $_POST. So far ive got the items displaying from the form as follows Code: [Select] <?php while ($client_prices = each($_POST)) { /* sets the name of the array to $client_prices for easy identification */ echo $client_prices['key']; /* Displays the keys withing the $client_prices array */ echo ' - '; echo $client_prices['value']; /* Displays the values within the $client_prices array */ echo '<br />'; } ?> and for the sake of it ill display the array ive set up on the server side using similar code : Code: [Select] <?php while ($server_prices = each($coffee_prices)) { /* sets the name of the array to $server_prices for easy identification */ echo $server_prices['key']; /* Displays the keys withing the $server_prices array */ echo ' - '; echo $server_prices['value']; /* Displays the values within the $server_prices array */ echo '<br />'; } ?> now, what i want to do is make sure that the keys (name of items) and the values (cost of items) from the client side are the same as the keys and values ive set on the server. so i created an if statement : Code: [Select] <?php if( $client_prices['key'] === $server_prices['key'] && $client_prices['value'] === $server_prices['value'] ) echo 'Prices Match'; else echo '<h2>Oops! Somthing Has Gone, Please Call Us To Place Your Order</h2>'; ?> so i thought i had it all working when as it came back with 'prices match', i thought all is good. however when i purposely change the value of one of the items in my server side array so it will be different from the incoming client value, it still says 'prices match' when they clearly don;t? Anyone help would be appreciated p.s. im fairly new to php, and this is for my learning, not a real client. My case statement is not working. What happened is that two students got a $markgrade of 61 and 67. So they both should get grade B but instead they both get Grade A. 1 student got 55 which should be grade C but gets grade A. why is it not following the switch statement? Code: [Select] function outputModule($moduleID, $moduleName, $sessionData) { if(!count($sessionData)) { return false; } $markTotal = 0; $markGrade = 0; $weightSession = 0; $grade = ""; $sessionsHTML = ''; switch($grade){ case ($markGrade >=70): $grade = 'A'; break; case ($markGrade >=60 && $markGrade <=69): $grade = 'B'; break; case ($markGrade >=50 && $markGrade <=59): $grade = 'C'; break; case ($markGrade >=40 && $markGrade <=49): $grade = 'D'; break; case ($markGrade >=30 && $markGrade <=39): $grade = 'E'; break; case ($markGrade >=0 && $markGrade <=29): $grade = 'F'; break; }; foreach($sessionData as $session) { $sessionsHTML .= "<p><strong>Session:</strong> {$session['SessionId']} {$session['Mark']} {$session['SessionWeight']}%</p>\n"; $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); $weightSession += ($session['SessionWeight']); $markGrade = ($markTotal / $weightSession * 100); } $moduleHTML = "<p><br><strong>Module:</strong> {$moduleID} - {$moduleName} {$markTotal} {$markGrade} {$grade}</p>\n"; return $moduleHTML . $sessionsHTML; } Hi I have a page pulling information from mysql table, it lists names, I have these inside a hyperlink so that where there is a website listed for that record then the user can click on the name and move to their website. Only thing is that what happens if there is not a website for that record. I wanted a script so that if there is a website address listed then it prints the hyperlink but where there is not a website address listed that only the name is printed and it is not a hyperlink. I understand that the strpos can be used for this I have written a script but it is only printing out the name even when there is a website address in the row. What is wrong? PHP Version 5.3.4 Any help very much appreciated Code: [Select] <?php $website = $org_website; $link = 'http'; $weblink = strpos ($website,$link); if ($weblink === !false) { echo "<a href=\"$org_website;\"> FindOrganiserName($org_id); \"> FindOrganiserName($org_website); </a>"; } else { echo FindOrganiserName($org_id); } ?> For some reason this just isn't inserting... HTML snippet: Code: (HTML) [Select] <form name="testimonials_form" method="post" action="insert/"> Name <input type="text" name="from" maxlegnth="100" /> Location <input type="text" name="where" maxlegnth="100" /> Text Snippet <input type="text" name="text" maxlegnth="255"> <input type="submit" name="submit" value="Continue" /> </form> PHP Snippet: Code: (PHP) [Select] <?php $from = $_POST['from']; $where = $_POST['where']; $text = $_POST['text']; if (!$from || !$where || !$text) { $error = "You have missed some fields."; $solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>."; } else { $data_array = array( ':from' => $from, ':where' => $where, ':text' => $text); $insert_testimonial = $connect->prepare("INSERT INTO `testimonials` (text, from, where) VALUES (:text, :from, :where)"); $insert_testimonial->execute($data_array); $amount = $insert_testimonial->rowCount(); if ($amount < 1) { $error = "Something went wrong."; $solution = "Please go back and <a href=\"javascript:history.go(-1)\" target=\"_self\">try again</a>."; } else { header ("Location: ../"); } } ?> All I keep getting back is my custom error "Something went wrong." so there's no 500 error (internal server error) and if I echo $from, $where and $text it displays what I typed in the form, I've re-written it about 5 times in case I wrote it wrong or something but still no luck. I know there can't be a symbol missing or in the wrong place since it would return a 500 error. Does anyone have any clue as to what's up with it? I've written codes like this countless times but this just doesn't seem to be working, so I must be missing something. |