PHP - Using Variables In Mysql Query Not Working. Help Please!
I am trying to run a mysql query to get the sum of a column.
When I type out the column name it works. When the column name is stored in a variable it does not seem to work. Code: [Select] <?php $total = $_GET['total']; if ($order != "" && $total != ""){ $query2 = "SELECT SUM('.$type2.') FROM customers WHERE sched=1"; $result2 = mysql_query($query2) or die(mysql_error()); while($row = mysql_fetch_array($result2)){ echo "Total ". " = $". $row["SUM('.$type2.')"]; echo "<br />"; } } ?> Any Help would be appreciated. Similar TutorialsSo, I'm working on a quiz system. The text and choices are stored in a MySQL database. I haven't gotten to the choices yet, I'm still having trouble with the text. Here's my code: Code: [Select] $querytext = "SELECT text FROM quiz id = '$prob'"; $result = mysql_query($querytext) or die(mysql_error()); echo $result; Yes, I'm already connected and stuff, that's just the snippet. I made sure that $prob is 1. Here's the MySQL Error I'm getting: 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 '= ''' at line 1 I've looked all over the web and through the MySQL/PHP section of a 991-page PHP book. What am I doing wrong? I bet that I really, really failed epicly this time, but I never catch my epic fails and have to ask questions about them in order to fix the problem. So please reply Ok so I have this script which will take a propery formated .csv file and upload to my database. here's the part i need to know if it's possible. basically it puts a group of codes into the database but i need a field that will specify which user the code pertains to from another table. The most logical way to reference the user is with an id code; but short of having the user reference an id code to put in the csv file, is there anyway I can make a query that will INSERT INTO and upload the csv? here's my current code... <?php $tmpName = $_FILES['song_codes']['tmp_name']; include('database.php'); if($sc != ""){ mysql_query('LOAD DATA LOCAL INFILE \''.$tmpName.'\' INTO TABLE music_codes FIELDS ENCLOSED BY "\"" TERMINATED BY "," LINES TERMINATED BY "\n" ;') or die('Error loading data file.<br>' . mysql_error()); $var = @$_GET['q'] ; $trimmed = trim($var); $table = @$_GET['field']; $query="SELECT * FROM contacts WHERE @'table' contains @'trimmed' order by id"; $result=mysql_query($query); $num=mysql_numrows($result); Why wont this work? Zacron Hello all, I am using the Lynda.com PHP course to further learn php. On one of the examples, they are using a SQL Query that works for them but is erroring out for me. It is the query below for the $page_set variable, particularly the use of the WHERE subject_id = {$subject["id"]}". Code: [Select] <?php require_once ('includes/conf.php'); ?> <?php include ('includes/header.php'); ?> <?php require_once ('includes/functions.php'); ?> <table id="stucture"> <tr> <td id="navigation"> <ul class="subjects"> <?php $subject_set = mysql_query("SELECT * FROM subjects", $connection); if (!$subject_set) { die ("Database query failed: " . mysql_error()); } while ($subject = mysql_fetch_array($subject_set)) { echo "<li>{$subject["menu_name"]}</li>"; } $page_set = mysql_query("SELECT * FROM pages WHERE subject_id = {$subject["id"]}"); // This appears to be the problem area, unless it is fooling me. It works with this exact statement in their code. if (!$page_set) { die ("Database query failed: " . mysql_error()); } echo "<ul class='pages'>"; while ($page = mysql_fetch_array($page_set)) { echo "<li>{$page['menu_name']}</li>"; } echo "</ul>"; ?> </ul> </td> <td id="page"><h2>Content Area</h2> </td> </tr> </table> <?php require ('includes/footer.php'); ?> The error listed is this: Database query failed: 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 '' at line 1 Thanks, you all are the best! BtD Hiya peeps! I have this code; $q3 = "SELECT `data` FROM `firm_text_strings` WHERE `id` = '100' AND `languages_id` = 'EN'"; $q4 = "SELECT `data_2` FROM `firm_text_strings` WHERE `id` = '100' AND `languages_id` = 'EN'"; $r3 = mysql_query($q3); $r4 = mysql_query($q4); if($r3 && $r4) { while($w3 = mysql_fetch_assoc($r3) && $w4 = mysql_fetch_assoc($r4)) { $resultStr = $w3['data'] . '<br />' . $w4['data_2']; } } else { $resultStr = 'error'; } everything is working up to the while function, it just wont do the loop for some reason. Anyone have any ideas. Many thanks, James. Hi there, I have this query, which outputs the records properly in PhpMyAdmin. But when using this query inside my PHP code, the result is incomplete. Instead of retrieving the expected 15 results, I only get the first one twice. Also, I don't get any errors. Code: (php) [Select] <?php $get_files = "SELECT `id` FROM `files` WHERE `category` = 'W';"; include_once('connection.inc.php'); $con = mysql_connect(MYSQL_SERVER, MYSQL_USERNAME, MYSQL_PASSWORD) or die ("Connection failed: " . mysql_error()); $dbname = "myDB"; $select_db = mysql_select_db($dbname, $con) or die ("Can't open database: " . mysql_error()); $result_files = mysql_query($get_files) or die ("Query failed: " . mysql_error()); $files = mysql_fetch_array($result_files); $W_files = "'".implode("', '", $files)."'"; // echo $W_files; outputs the first number twice, instead of the expected 15 different ones $get_checklist = "SELECT * FROM `checklist` WHERE `id` IN ($W_files) ORDER BY `id` ASC;"; $result_checklist = mysql_query($get_checklist) or die ("Query failed: " . mysql_error()); // .... code for displaying ?> Hi guys need some help.I created a simple Update Customer Details page Where you Enter the Customer ID ,The Customer Details Get Displayed inside a Form and you make changes within the Form.But the update query I wrote is not working as it should be.It Executes the Query ,when I hardcode the Customer ID inside the Update query but fails when I need to Enter the Customer ID directly from the form using post.In This Code I tried to Update only the Customer's Firstname.Thanks Here Is The Code Code: [Select] <?php $db=mysql_connect("localhost","root","") or die('Unable to Connect To Database.Please check the Database Parameters'); mysql_select_db('ecommerce') or die(mysql_error()); if(isset($_POST['enterid'])) { $_POST['inputid']; } $query="SELECT * FROM customer WHERE Cid='$_POST[inputid]'"; $result=mysql_query($query) or die(mysql_error()); $row=mysql_fetch_array($result); $new_cid=$row['Cid']; $new_firstname=$row['Cfname']; $new_lastname=$row['Clname']; $new_email=$row['Email_id']; $new_address=$row['Address']; $new_pincode=$row['Pincode']; $new_payment=$row['Mode_of_payment']; $new_city=$row['City']; $new_state=$row['State']; $new_phone=$row['Phone']; $html1=<<<HTML1 <form action="updatecustomer.php" method="post"> <p class="inputidentifier">Please Enter The Customer's ID</p><input type="text" style="width:375px;height:40px;font-size:30px;" name="inputid" size="20"><br><br> <input type="submit" name="enterid" style="height:40px"> HTML1; print($new_cid); if(isset($_POST['update'])) { $query1="UPDATE customer SET Cfname='$_POST[firstname]' WHERE Cid='$_POST[inputid]'"; mysql_query($query1) or die(mysql_error()); if(mysql_affected_rows()==1) print("Query sucessful"); else print("Something went wrong"); } ?> <html> <head> <style type="text/css"> .inputtext {width:300px; height:40px;font-size:30px;} .inputidentifier{font-size:25px;font-family:"Arial"} .h1type{font-family:"Arial"} </style> <title>Test</title> </head> <body> <?php print($html1); ?> <h1 align="center" class="h1type">Update Customer Details</h1> <form action="updatecustomer.php" method="POST"> <table align="center" cellspacing="10" cellpadding="10" border="0" width="60%"> <tr> <td align="right" class="inputidentifier">First Name</td> <td align="left"><input type="text" class="inputtext" name="firstname" placeholder="eg:Kevin" value="<?php print($new_firstname) ?>"></td> </tr> <tr> <td align="right" class="inputidentifier">Last Name</td> <td><input type="text" class="inputtext" name="lastname" placeholder="eg:Aloysius" value="<?php print($new_lastname) ?>"></td> </tr> <tr> <td align="right" class="inputidentifier">E-mail</td> <td align="left"><input type="email" style="width:500" class="inputtext" name="email" placeholder="yourname@email.com" value="<?php print($new_email) ?>"> </tr> <tr> <td align="right" class="inputidentifier">Phone Number</td> <td align="left"><input type="text" class="inputtext" name="phone" placeholder="How Do We Call You?" value="<?php print($new_phone) ?>"></td> </tr> <tr> <td align="right" class="inputidentifier">Address</td> <td><textarea style="width:500;height:150" wrap="virtual" class="inputtext" name="address" placeholder="Where is your Crib?"><?php print($new_address) ?></textarea></td> </tr> <tr> <td align="right" class="inputidentifier">State</td> <td align="left"><input type="text" style="width:500" class="inputtext" name="state" placeholder="State" value="<?php print($new_state) ?>"> </tr> <tr> <td align="right" class="inputidentifier">City</td> <td align="left"><input type="text" class="inputtext" name="city" placeholder="City" value="<?php print($new_city) ?>"> </tr> <tr> <td align="right" class="inputidentifier">Pin Code</td> <td><input type="text" class="inputtext" name="pincode" placeholder="Mulund 400080" maxlength="6" value="<?php print($new_pincode) ?>"></td> </tr> <tr> <td align="right" class="inputidentifier">How do Pay for your Bling?</td> <td align="left"> <input type="text" class="inputtext" name="payment" value="<?php print($new_payment)?>"> </tr> <tr> <td></td> <td><input type="submit" name="update" value="Update!" style="width:100px;height:60px;"></td> </tr> </table> </form> </body> </html> Hi guys, I'm trying to query two tables for different data and echo the results that match both tables. Here are the tables I have and the query I'm trying to run. (Table) qc_reports (Fields) id report_date report_lot_number report_po report_supplier report_buyer report_inspectedby report_pulptemprange report_carrierconditions report_supplierclaim report_carrierclaim report_temprecorder report_temprange_N report_temprange_M report_temprange_B report_suppliercontact report_contactedby report_time report_comments (Table) qc_lots (Fields) id report_id lot_temprange lot_commodity lot_rpcs lot_brand lot_terms lot_cases lot_orgn lot_estnum lot_avgnum This is the query that I'm trying to do. Code: [Select] <?php $sql = "SELECT * FROM qc_reports, qc_lots WHERE "; if (!empty($start_date) and !empty($end_date)) $sql .= " qc_reports.report_date BETWEEN '$start_date' and '$end_date' AND "; if (!empty($search_fronteralot)) $sql .= " qc_reports.report_lot_number = '$search_fronteralot' AND "; if (!empty($search_buyer)) $sql .= " qc_reports.report_buyer = '$search_buyer' AND "; if (!empty($search_supplier)) $sql .= " qc_reports.report_supplier = '$search_supplier' AND "; if (!empty($search_po)) $sql .= " qc_reports.report_po = '$search_po' AND "; if (!empty($search_carrierconditions) and $search_carrierconditions != 'all') $sql .= " qc_reports.report_carrierconditions = '$search_carrierconditions' AND "; if (!empty($search_commodity) and $search_commodity != 'all') $sql .= " qc_lots.lot_commodity = '$search_commodity' AND "; if (!empty($search_inspectedby)) $sql .= " qc_reports.report_inspectedby = '$search_inspectedby' AND "; $sql = substr($sql, 0, -4); $query = mysql_query($sql); $numrows = mysql_num_rows($query); ?> RESULTS - <?php echo $numrows; ?> <hr> <table width='500'><tr><td><b>Date</b></td><td><b>Lot Number</b></td><td><b>PO</b></td><td> </td></tr> <tr> <td> </td> </tr> <?php while ($row = mysql_fetch_assoc($query)) { $id = stripslashes($row['id']); $report_lot_number = stripslashes($row['report_lot_number']); $report_po = stripslashes($row['report_po']); $report_date = stripslashes($row['report_date']); echo "<tr> <td>" . $report_date . "</td></td><td>" . $report_lot_number . "</td><td>" . $report_po . "</td><td><a href='view_report.php?id=" . $id . "'>View</a></td> </tr>"; } echo '</table><br><br><br><hr><br><br>'; } ?> All the variables are passed from a HTML form with $_POST. I need the search to work like this: If there is a value in a form field then the query gets appended with that value but when it gets to the $search_commodity it needs to search the second table (qc_lots) and check for the results. Any results that match have to be matched to the results from the first table (qc_reports) and display (echo) only qc_reports that match to both tables. The only common field is the report_id on the qc_lots table and the id on the qc_reports table. I'm stuck and need some guidance. Can someone help please? Hi there, I'm having a problem with updating a record with an UPDATE mysql query and then following that query with a SELECT query to get those values just updated. This is what I'm trying to do...I'd like a member to be able to complete a recommended task and upon doing so, go to a page in their back office where they can check off that task as "Completed". This completed task would be recorded in their member record in our database so that when they return to this list, it will remain as "Completed". I'm providing the member with a submit button that will call the same page and then update depending on which task is clicked as complete. Here is my code: Code: [Select] $memberid = $_SESSION['member']; // Check if form has been submitted if(isset($_POST['task_done']) && $_POST['task_submit'] == 'submitted') { $taskvalue = $_POST['task_value']; $query = "UPDATE membertable SET $taskvalue = 'done' WHERE id = $memberid"; $result = mysqli_query($dbc, $query); } $query ="SELECT task1, task2, task3 FROM membertable WHERE id = $memberid"; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result, MYSQLI_ASSOC); $_SESSION['task1'] = $row['task1']; $_SESSION['task2'] = $row['task2']; $_SESSION['task3'] = $row['task3']; ?> <h4>Task List</h4> <table> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task1" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task2" /> <input type="hidden" name="task_submit" value="submitted" /> </form> <form action="" method="post"> <tr> <td>Task 1</td> <td><?php if($_SESSION['task1'] == 'done') {echo '<div>Completed</div>';} else{ echo '<input type="submit" name="task_done" value="Mark As Completed" />';} ?></td> </tr> <input type="hidden" name="task_value" value="task3" /> <input type="hidden" name="task_submit" value="submitted" /> </form> </table> The problem that I am having is that the database is not updated with the value "done" but after submission, the screen displays "Completed" instead of "Mark As Completed". So the value is being picked up as "done", but that is why I have the SELECT after the UPDATES, so that there is always a current value for whether a task is done or not. Then I refresh and the screen returns the button to Mark As Complete. Also, when I try marking all three tasks as, sometimes all three are updated, sometimes only one or two and again, I leave the page or refresh and the "Marked As Completed" buttons come back. Bizarre. If anyone can tell me where my logic is going wrong, I would appreciate it. Hey guys, New to the forum and a newer user of PHP / MySQL. I am having trouble with some code I've written up. I don't seem to get any errors when running it, but it's not updating my database the way that it should. hopefully a simple fix. I am thinking that it must be on the MySQL side of things. Couple of things to start. My html form is comprised completely of drop down list inputs. I'm the only user so I thought this would be the easiest approach. Because of that I've made my PHP as follows: Code: [Select] <?php $season = $_POST['season']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $time = $_POST['time']; $event = $_POST['event']; $game = $_POST['game']; $buyin = $_POST['buyin']; $connect = mysql_connect('localhost','root','') or die('can not connect'); if ($connect) { echo "connected to database"; } $db = mysql_select_db('dpl') or die('can not find database'); if ($db) { echo "DPL Selected"; } $query = sprintf("INSERT INTO events (season , month , day , year , time , event , game , buyin) VALUES ('%s' , '%s' , '%s' , '%s' , '%s' , '%s' , '%s' , '%s')", $season , $month , $day , $year , $time , $event , $game , $buyin ); if ($query) { echo "Your event has been added"; } ?> My connection is working, my database is selected and I'm even now getting confirmation that my query is working, but when i go to check my database there are no entries in it? any thoughts? I've tried the drop down variables as both VARCHAR and TEXT inputs in MySQL, but I can't seem to get it to work. Any help is greatly appreciated. Here is my code: // Start MySQL Query for Records $query = "SELECT codes_update_no_join_1b" . "SET orig_code_1 = new_code_1, orig_code_2 = new_code_2" . "WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2)"; $results = mysql_query($query) or die(mysql_error()); // End MySQL Query for Records This query runs perfectly fine when run direct as SQL in phpMyAdmin, but throws this error when running in my script??? Why is this??? Code: [Select] 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 '= new_code_1, orig_code_2 = new_code_2WHERE concat(orig_code_1, orig_c' at line 1 If you also have any feedback on my code, please do tell me. I wish to improve my coding base. Basically when you fill out the register form, it will check for data, then execute the insert query. But for some reason, the query will NOT insert into the database. In the following code below, I left out the field ID. Doesn't work with it anyways, and I'm not sure it makes a difference. Code: Code: [Select] mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); Full code: Code: [Select] <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $name = mysql_real_escape_string($_POST['name']); $server_type = mysql_real_escape_string($_POST['type']); $description = mysql_real_escape_string($_POST['description']); if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings!<br/>All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40' name='description'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < 8) { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = mysql_query("SELECT username,name FROM servers WHERE username = '$username' OR name = '$name' LIMIT 1"); if(mysql_num_rows($check1) < 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); echo "Server has been succesfully created!"; } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> Can I use a variable inside an sql query to determine which table to select from? The 2 functions below do exactly the same thing, they're just selecting data from different tables. I'm not sure how I can do it. Maybe put a parameter in the function & use sprinf? // Output the page data function showpages() { db_connect(); $query = ("SELECT * FROM pages"); // can I change pages to a variable somehow? $result = mysql_query($query); $result = result_to_assoc($result); return $result; } // Echo the pricelist data into the pricelist form function show_pricelist() { db_connect(); $query = ("SELECT * FROM pricelist"); // Again, if pricelist can be a variable, then I need only 1 function $result = mysql_query($query); $result = result_to_assoc($result); return $result; } Hi, my query doesn't work, I've got a date field in my MySql table, I want to get results of all employees that was added in a certain period. My query doesn't work but as soon as I type in values in my query instead of variables it works, what am I doing wrong? Code: [Select] $date = date('Y/m'); $date1 = strtotime('-6 month'); $date2 = strtotime('-6 month'); echo date('Y', $date1); echo date('m', $date2); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $sql = "SELECT * FROM detail WHERE year(engaged) > '$date1' and month(engaged) > '$date2'"; $result=mysql_query($sql); echo mysql_num_rows($result); I have a query that pulls 1 field with 20 rows of data. I need to assign each row to a different variable so that I can then display them in different locations on a page. I cannot make each row of data a different field because of other constraints. My data is very well normalized. I am using mysqli so something like the old mysql_result would be lovely! How can this be done without hitting my database 20 times? Thanks for the help. Hello there, i`m trying to figure out a way to reorder a query string depending on variables. So the url would have the following query: /result/index.php?page=Weissenfels+Clack+and+Go&tyre=155_70_12&option1=30_02&option2=43_02&v_t=car&options=2 It should depend what page they come from if the page is equal to option2 then option1 is op1 and option2 is op2 To make it myself easier i have converted some variables On every first two digits ie 43 from the 43_02 can have 13 different ending digits, ie _03 or _04 or _05 etc... So i have converted all 43_02 43_03 etc to one variable ie $chain1 or $chain2 which holds in this case 43 a 43 is equal to Weissenfels+Clack+and+Go in the index page i have included the following process. At the moment i can only use php coding, unfortunately no mysql atm thank you in advance. Code: [Select] <?php $tyre = $_GET['tyre']; // finds the tyre size $op1 = $_GET['option1']; // finds the first chain size if applicable $op2 = $_GET['option2']; // finds the second chain size if applicable $op3 = $_GET['option3']; // finds the third chain size if applicable $op4 = $_GET['option4']; // finds the fourth chain size if applicable $op5 = $_GET['option5']; // finds the fith chain size if applicable $op6 = $_GET['option6']; // finds the sixth chain size if applicable $op7 = $_GET['option7']; // finds the seventh chain size if applicable $op8 = $_GET['option8']; // finds the eighth chain size if applicable $options = $_GET['options']; $page = $_GET['page']; $error = $_GET['info']; $vehicle_type = $_GET['v_t']; // finds the vehicle type $b = "Weissenfels+WeissTech+Tecna"; $c = "Weissenfels+Clack+and+Go"; if (($op1 == "30_02") || ($op1 == "30_03")) { $chain1 = "m30"; } elseif (($op2 == "43_02") || ($op2 == "43_03")) { $chain2 = "m43"; } else echo "error"; switch ($page) { case (($page == $c) && ($chain1 == "m43")); $option1 = $op1; $option2 = $op2; break; case (($page == $c) && ($chain2 == "m43")); $option1 = $op2; $option2 = $op1; break; default; $option1 = $op1; $option2 = $op2; break; } if ($options=="1") // calculates the possible combination { // outputs the results include 'options_1.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="2") { // outputs the results include 'options_2.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="3") { // outputs the results include 'options_3.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="4") { // outputs the results include 'options_4.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="5") { // outputs the results include 'options_5.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="6") { // outputs the results include 'options_6.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="7") { // outputs the results include 'options_7.php'; // type the amount of possible chains in here ie options_3 options_4 etc } elseif ($options=="8") { // outputs the results include 'options_8.php'; // type the amount of possible chains in here ie options_3 options_4 etc } else echo "there is an error on process_action2"; ?> I'm restarting this under a new subject b/c I learned some things after I initially posted and the subject heading is no longer accurate. What would cause this behavior - when I populate session vars from a MYSQL query, they stick, if I populate them from an MSSQL query, they drop. It doesn't matter if I get to the next page using a header redirect or a form submit. I have two session vars I'm loading from a MYSQL query and they remain, the two loaded from MSSQL disappear. I have confirmed that all four session vars are loading ok initially and I can echo them out to the page, but when the application moves to next page via redirect or form submit, the two vars loaded from MSSQL are empty. Any ideas? I'm very new to this and really could use some help. I've got a Web app that has one form that collects data from the user and puts it into a mysql database and has another form that allows the user to select critiera to find records in the database and display them on the page. All this is working just fine, but now that my database is getting more data in it, I want to add functionality to display 10 records on a page with results page navigation links so the user can move forward and backward in the results set. This part is not working and I've put in echo statements to figure out what the code is doing. The problem I'm having is that when the selection critiera pulls more than 10 records from the database, the first page of results is correct per the selection criteria entered by the user on the select form. When the 'next' link is selected to review the second page of results, the query is executed again. But this time the form variables have been reset and the results now contains the entire contents of the db. The start record is set to look at the 11th instance of the results set, so the second page starts with the 11th record in the database instead of the 11th record in the original results set. The original select statement is built by determining which criteria is selected using $_POST against each form variable. How can I retain the form variables or the original select statement so the second execution of the select statement results in the same results set as the first? The other option that may be better is to retain the original results set and avoid re-executing the select statement altogether. But I don't know how to do that either. Any suggestions, code samples or adivice is much appreciated! Hello All, In below script, I'm using another script called "SimpleImage.php" to upload and resize photos for a news site. The problem comes with renaming the photos. I need to name the photo based off of the story id. I have everything right to get the story id, but saving it as the variable is what's confusing me. Here's what I have: <?php include ("newsconnection.php");?> <?php $picturename = $_POST['newstoryid']; include('SimpleImage.php'); $image = new SimpleImage(); $image->load($_FILES['uploaded_image']['tmp_name']); $image->resizeToWidth(300); $image->save('$picturename'); ?> It's the $image->save('$picturename'); line that's messing me up. Any help would be great!! hi,
I'm new to php. I tried to get sum of two variables using java script. Value of one variable come from a php variable, Other one is a static value. here is the code
$price_per_day=100; it displays correctly. but when i try to add it with another variable it displays nothing. Please help me.
<!DOCTYPE html> |