PHP - Mysqli_query Problems
I wrote a simple mysql record update.
mysqli_query($link, "UPDATE photo01 SET PhotoText='abcd' WHERE id= '1' ");
Work fine until I use a variable:
mysqli_query($link, "UPDATE photo01 SET PhotoText= $ZZ WHERE id= $x ");
If $ZZ contains only number it updated the cell.
ANY letters does not.
The cell is text and standard US ASCII
I tried:
mysqli_query($link, "UPDATE photo01 SET PhotoText={$ZZ} WHERE id={$x}");
same problem
Here is my loop:
<?php
for ($x = 0; $x < 131 ;$x++) { $ZZ = $_POST["z".$x]; if ($ZZ != '') { mysqli_query($link, "UPDATE photo01 SET PhotoText={$ZZ} WHERE id={$x}"); } } ?> Similar TutorialsOkay so I created a theme for my website that will also utilize a custom CMS script I developed and its not cooperating with me nicely. Here's my head of my header file for my template: Code: [Select] <!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" <?php language_attributes(); ?>> <head> <title><?php bloginfo('name') ?>: <?php bloginfo('description') ?></title> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> <meta http-equiv="content-type" content='<?php bloginfo("html_type"); ?> charset=<?php bloginfo('charset'); ?>' /> <?php if(is_singular()){ wp_enqueue_script('comment-reply');} ?> <?php wp_head(); ?> <?php require ('efedmanager/inc/dbconfig.php'); ?> </head> Now on my index page that calls the header file I DO NOT get a error saying that the file could not be located. So that's good news. Here's my dbconfig.php file. Code: [Select] <?php /** * @author Jeff Davidson * @copyright 2010 */ // This file contains the database access information and establishes a connection to MySQL and selects the database // Set the database access information as contstants DEFINE ('DB_USER', '?'); DEFINE ('DB_PASSWORD', '?'); DEFINE ('DB_HOST', '?'); DEFINE ('DB_NAME', '?'); // Make the database connection $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (!$dbc) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } ?> Now when I go to one of my custom pages like this one it brings up the message: Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/xtremer/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 38 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/xtremer/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()'d code on line 39 Code: [Select] <div id="champions" class="content"> <h1 class="pageheading">KOW Champions and Contenders</h1> <?php $championsQuery = " SELECT titles.titleName, titles.shortName, champions.champID, champions.con1ID, champions.con2ID, champions.con3ID, biochamp.shortName AS championshortName, biochamp.characterName AS champion, biocon1.shortName AS con1shortName, biocon1.characterName AS con1, biocon2.shortName AS con2shortName, biocon2.characterName AS con2, biocon3.shortName AS con3shortName, biocon3.characterName AS con3 FROM champions LEFT JOIN titles AS titles ON titles.ID = champions.titleID LEFT JOIN characters AS biochamp ON champions.champID = biochamp.ID LEFT JOIN characters AS biocon1 ON champions.con1ID = biocon1.ID LEFT JOIN characters AS biocon2 ON champions.con2ID = biocon2.ID LEFT JOIN characters AS biocon3 ON champions.con3ID = biocon3.ID WHERE titles.statusID = '1' ORDER BY titles.ID"; $championsResult = mysqli_query($dbc, $championsQuery); while ( $row = mysqli_fetch_array ( $championsResult, MYSQLI_ASSOC ) ) { $fieldarray=array('titleName','shortName','championID','championshortName','champion','con1ID','con1','con1shortName','con2ID','con2','con2shortName','con3ID','con3','con3shortName'); foreach ($fieldarray as $fieldlabel) { ${$fieldlabel} = $row[$fieldlabel]; } ?> <div id="title"><span class="large">< ?php echo $titleName ?></span> < ?php if (file_exists('images/championshots/'.$titleshortName.'/'.$championshortame.'.png')) { echo "<img class=champion src=images/championshots/".$shortName."/".$champion.".png alt= />\n"; } else { echo "<img class=champion src=images/championshots/".$shortName."/".$shortName.".png alt= />\n"; } if (strlen ($champion) < 1) { echo "<span class=medium>Vacant"; } else { echo "<span class=medium><a href=/bio?shortName=".$championshortName.">".$champion."</a></span>\n"; echo "<span class=medium>(Since TBD)</span>"; } ?> <span class="contender">Contenders</span> <ul> < ?php if ( strlen ($con1) < 1) { echo "<li><span class=medium>TBD</span>"; } else { echo "<li><a href=/bio?shortName=".$con1shortName.">".$con1."</a></li>\n"; } if (strlen ($con2) < 1) { echo "<li><span class=medium>TBD</span>"; } else { echo "<li><a href=/bio?shortName=".$con2shortName.">".$con2."</a></li>\n"; } if (strlen ($con3) < 1) { echo "<li><span class=medium>TBD</span>"; } else { echo "<li><a href=/bio?shortName=".$con3shortName.">".$con3."</a></li>\n"; } ?> </ul> </div> < ?php } ?> </div> Hi guys, I have coded this, however I have received an error msg, can someone advice me in this? Thank you Warning: mysqli_query() expects at least 2 parameters, 1 given in D:\inetpub\vhosts\abc.com\httpdocs\report.php on line 166 Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in D:\inetpub\vhosts\abc.com\httpdocs\report.php on line 167 <?php $sql = mysqli_query("SELECT * FROM tutor_preferred_district ORDER BY district_id ASC"); while($data = mysqli_fetch_array($sql)) { echo '<input name="district" type="checkbox" id="'.$data['district_id'].'" value="'.$data['district_id'].' class="required" title="Please check at least 1 location."> <label for="'.$data['district_id'].'">'.$data['district_name'].'</label>'; } ?> Hi, I'm by no means an expert in php but I use and continually try and figure out how to update some very old soccer stats scripts that break from time to time when newer versions of php are released. Anyway, I would appreciate any pointers with this error please: Warning: mysqli_query() expects parameter 3 to be integer, object given in /blah/blah/blah.php on line 81 The code is: 79 - mysqli_query($connection,"INSERT INTO seasons SET 80 - SeasonID = '$seasonid', 81 - SeasonPlayerID = '$player_id'",$connection) 82 - or die(mysqli_error($connection)); Server is running php 7.2.28 Thanks in advance. After overcoming this-> error "Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the futu use mysqli or PDO instead in this-> $myconnection = mysql_connect($server, $user, $pass);" by changing mysql_query to mysqli_query($con, $query), I started getting this specific error on line 106= $result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);
Warning: mysqli_query() expects parameter 1 to be mysqli, null given on line 106=="$result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);"
This header wont go, I tried $myconnection = mysql_connect($query); and it says expecting 2 parameters.
Please I'm open to ideas to solve this,
<snip - code is posted in next post>
Edited by mac_gyver, 05 June 2014 - 03:28 PM. removed code not in code tags as the op posted it later Hey guys,
Earlier I mentioned making search criteria in my database. I also had to put in something to make it add to the database. I made some code like this:
<form id="form" name="form" method="post" action="Website2.php"> <p> <label for="Genre">Genre</label> <input type="text" name="Genre" id="Genre" /> </p> <p> <label for="Naam">Naam</label> <input type="text" name="Naam" id="Naam" /> </p> <p> <label for="Jaar">Jaar</label> <input type="text" name="Jaar" id="Jaar" /> </p> <p> <label for="Regisseur">Regisseur</label> <input type="text" name="Regisseur" id="Regisseur" /> </p> <p> <input type="submit" name="Verzenden" id="Verzenden" value="Verzenden" /> </p> </form> <?php $Genre = $_POST["Genre"]; $Naam = $_POST["Naam"]; $Jaar = $_POST["Jaar"]; $Regisseur = $_POST["Regisseur"]; /*Hier hoeft geen verbinden meer gemaakt te worden met de database*/ if (isset($_POST['Verzenden']) && trim($_POST['Verzenden'])!=''){ $sql = "INSERT INTO Movies (Genre, Naam, Jaar, Regisseur) VALUES ('$Genre', '$Naam', '$Jaar', '$Regisseur')"; $resultaat = mysqli_query($db, $sql); $verbreken = mysqli_close($db); echo "De gegevens van $Naam zijn opgeslagen in de database.";} else echo 'Hier kunt u iets toevoegen'; ?>However it didn't work. I got the problem "Warning: mysqli_query() expects parameter 1 to be mysqli, null given in... on line 119" Can you guys help please? class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); It display a blank page like attachment result1.jpg, but if I move the $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); from function debug() and join it with function execute() like this: public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } it return me Linuxformat content ( expected result ) like result2.jpg below is the working code : class curl2{ private $curl_init; private $CURLOPT_URL; public function connect(){ $this->curl_init = curl_init(); } public function debug(){ curl_setopt($this->curl_init, CURLOPT_VERBOSE, TRUE); } public function setUrl($url = null){ $this->CURLOPT_URL = $url; curl_setopt($this->curl_init, CURLOPT_URL, $this->CURLOPT_URL); } public function execute(){ $fp = fopen("curl2.txt", "w"); curl_setopt($this->curl_init, CURLOPT_STDERR, $fp); curl_setopt($this->curl_init, CURLOPT_RETURNTRANSFER, TRUE); $out = curl_exec($this->curl_init); curl_close($this->curl_init); return $out; } } $curl2 = new curl2; $curl2->connect(); $curl2->setUrl("http://www.linuxformat.co.uk"); $curl2->debug(); echo $curl2->execute(); Why I couldn't split "CURLOPT_STDERR, CURLOPT_RETURNTRANSFER" with "curl_exec" I'm trying to either update my database if some data matches the if statement, or insert the data in a new row if it doesn't match (if possible). The code will update the database just fine if the data matches, but if not, it won't insert the new data. (When I leave off the if statement it will insert just fine). I fear I'm not using the if...else correctly. Thanks for any help. <?php header("Location: admin_schedule.php"); include("opendatabase.php"); $date=("$_POST[gamedate]"); $week=("$_POST[Week]"); $game=("$_POST[Game]"); $hometeam=("$_POST[team_name_1]"); $awayteam=("$_POST[team_name_2]"); $check = mysql_query("SELECT week_id,game_id FROM schedule"); $row[] = mysql_fetch_array($check); if ($row[week_id]='$week' && $row[game_id]='$game') { mysql_query("UPDATE schedule SET week_id = '$week', game_id = '$game', date = '$date', H_team = '$hometeam', A_team = '$awayteam' WHERE week_id = '$week' AND game_id = '$game'"); } else { mysql_query("INSERT INTO schedule (week_id,game_id,date,H_team,A_team) VALUES('$week','$game','$date','$hometeam','$awayteam')"); } mysql_close($con); Hi I have plans in developing a connect function for remote login to my web side. I can't find any useful on Google. Some idees on how to code a API connect button? Something similiar to Facebook connect, Twitter connect etc. BUT this should not rely on facebook api. I'm going to make my own stand alone api. I know I need to use REST in backend, but I'm missing the knowledge to know how to send / recive the login data, and how to know when a user are online or not. I'm greatfull for any help. Also links. And also tips on how to make a developer plattform for apps, much like the way Facebook have it. First Since I first started learning PHP, I've been writing code for forms like this: $name = $_POST["name"]; if ($name == "") { echo "You didn't type anything"; } I've written scripts like this and tested them on a GOdaddy server, and they always worked fine. Now, after testing scripts like that on my own server (WAMP2 [PHP5, Mysql, Apache]), I get an error saying "Unidentified index: name", and so I have to nest that if statement AS WELL AS the variable assignment inside another if statement like this: if (isset ($_POST["name"])) { $name = $_POST["name"]; if ($name == "") { echo "you didn't type anything. } } The error doesn't actually stop the script from running, but a medium sized box appears in the browser with the error message contained that's after the element in the document of which is getting an invalid error. Which way is truly the correct way? Because now that I have to use the second way in order for my scripts to run correctly on my own server, I have to write more code and it all gets disorganized and more complicated to read. So...is this a configuration thing that I can tweak in WAMP2 to stop messages like that from popping up? Or is the second way the way you're supposed to do it? Also, I was wondering why ereg got deprecated and what the replacement of it is in PHP5? I've asked before and even googled it but I simply get taken to a "Pearl" function on PHP.net. I'm not sure what it is, or how to use it, and haven't got any hints from either PHP.net or anywhere else. Any suggestions? I want to gettwitter feeds, this gives me a xml http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3 based on this: http://www.w3schools.com/PHP/php_xml_simplexml.asp i try to get the xml with: <?php$xml = simplexml_load_file("http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3");?>() i get this error: Quote Warning: simplexml_load_file(http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://twitter.com/statuses/user_timeline.rss?screen_name=fleuragemapvv&count=3" in /home/vhosting/x/vhost0033377/domains/doekewartena.nl/htdocs/www/temp/twitter03.php on line 2 i have no clue, i'm very new to php can i even use simplexml_load_file cause it has no .xml file type extention. the image in my comments box wont show up it gives me an error Code: [Select] Notice: Undefined index: avatar in /home/ecabrera/public_html/profile.php on line 277 and i dont whats wrong with it Code: [Select] // display comments $perpage = 10; $start=0; if(@$_GET['s']) $start = $_GET['s']; $query = mysql_query("SELECT * FROM profile_comments WHERE profile_id='$getid' ORDER BY id DESC LIMIT $start, $perpage"); $numrows = mysql_num_rows($query); if ($numrows > 0){ $next = $start + $perpage; $prev = $start - $perpage; while($row = mysql_fetch_assoc($query)){ $user_id = $row['user_id']; $user_name = $row['user_name']; $comment = nl2br($row['comment']); $date = $row['date']; $avatar = $row['avatar']; echo "<img src='avatars/$avatar'></img><a href='$site/profile?id=$getid'></a> <b> on $date</b><br />"; echo "<div style='margin-left: 10px;'>$comment</div><hr>"; } } else echo "This user has no profile comments.<br />"; // end diplay comment area Hi, I hope someone can help me. I am trying to generate a script for our Intranet that tells me which birthdays = today. My field in my table = d/m/y, eg 09/05/2011 (9 May 2011). How do I get the script to just look at the day & month, not the year? My script looks like this: Code: [Select] <?php echo date("d/m/Y") . "<br />"; $myDate = date('d/m/Y'); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("dbname", $con); $sql = "SELECT * FROM detail WHERE dob='$mydate'"; $result=mysql_query($sql); echo mysql_num_rows($result); ?> Hello, Alright I am having a few issues here. Let me explain what I am doing...this is a script that allows a customer to split an order..he can split certain items out of one order and it will create another order with the items he split added to this order, and then subtracting the items from the old order. The products are stored in one field called products, they are stored in a delimited list like this qty, product name, price each, product id | qty, product name, price each, product id |etc. Now, before you say why are you storing your products like that?? The reason I have to store my products like so is because the customer does not want the products stored in the order table to be dependent off the products table like they were before. In that case if he modified a product it would modify all of the orders with that product stored in them. Make sense? I am aware a delimited list probably wasn't the best way to do this but it was the best way I could think of. Ok here is my list of issues. 1) Everytime you split an order, it is not creating a new order to store the items that were split into. It created an order the first time I did it, and now all it does is it keeps updating the products field in that order, rather than creating a new order. 2) Next I do not know how I can update the old products (stored in the $prod array). It needs to update the products qtys after the order was split, and then if all of the qty for that product were moved to the new order it just needs to remove that product from the $prod array rather than updating the quantity. The code is below. Please let me know if I can provide any more information to help! Thanks everyone! // Get Old Order $get_order = @mysql_query("SELECT * FROM orders WHERE order_id = {$_POST['order_id']}"); $order = @mysql_fetch_assoc($get_order); // Get Old Order Items $products = $order['products']; //breaking products text down for display $prod = array(); $_products = explode('|', $products); foreach ($_products AS $p) $prod[] = explode(',', $p); /* $get_items = @mysql_query("SELECT product_id, qty FROM order_items WHERE order_id = {$order['order_id']}"); $items = array(); while(($row = @mysql_fetch_assoc($get_items)) !== false) { $items[] = $row; } */ if(empty($prod)) { header("Location: tracking.php"); die(); } // Create New Order mysql_query("INSERT INTO orders SET customer_id = {$order['customer_id']}, order_status = {$order['order_status']}, order_date = '{$order['order_date']}', order_date_paid = '{$order['order_date_paid']}', order_shipping = '{$order['order_shipping']}', order_shipping_fee = '{$order['order_shipping_fee']}', order_insurance = '{$order['order_insurance']}', order_insurance_fee = '{$order['order_insurance_fee']}', order_insurance_total = '{$order['order_insurance_total']}', order_grand_total = '{$order['order_grand_total']}', order_date = '{$order['order_date']}', order_filled = '{$order['order_filled']}', order_ship_date = '{$order['ship_date']}'"); $get_new_order = @mysql_query("SELECT MAX(order_id) AS order_id FROM orders") or die(mysql_error()); $new_order_id = @mysql_result($get_new_order, 'order_id', 0); // Add Items to New Order & Remove Items from Old Order $new_items = array(); $_new_items = ''; foreach($prod as $p2) { for($i = 0; $i < $p2[0]; $i++) { if(!empty($_POST[trim($p2[3]).'_'.$i])) { $new_items[trim($p2[3])]++; } } } //construct new static products list foreach($new_items as $id=>$qty) { $get_product = mysql_query("SELECT name, price FROM products WHERE product_id = '{$id}'"); $got_product = mysql_fetch_assoc($get_product); $_new_items .= $qty.','.$got_product['name'].','.$got_product['price'].','.$id.'|'; //echo $id.' - '.$qty.'<br>'; } //remove last character in products text before going into DB $_new_items = substr_replace($_new_items ,"",-1); //update products field in new order mysql_query("UPDATE orders SET products = '{$_new_items}' WHERE order_id = '{$new_order_id}'"); Hello, I'm having trouble with zip_read. I made a zip of 2 plain 8k text files and zipped them w/ winrar using default settings. I opened the file w/ zip_open and then checked to make sure the return value was a valid resource, which it is. But when I try to use the return value of zip_read I get: Quote Warning: zip_entry_name() expects parameter 1 to be resource, boolean given in xxx It is actually returning "1". According to the zip error codes I think this means "Multi-disk zip archives not supported". I have no idea what a 'multi-disk' zip file is. I've posted my code below. How can I get php to read through a zip file? Thanks Code: [Select] $zip = zip_open($this->upload_path . $filename); if (is_resource($zip)) { $i = 0; while($zip_entry = zip_read($zip) && $i<500 ){ if($this->debug) echo "zip_entry=" . $zip_entry . "<br>"; $basename = basename(zip_entry_name($zip_entry)); $zipped_file = $this->upload_path . $basename; // other unrelated code } } I am trying my hand at using an array i have never done it before, and I am having some problems getting it work work. if someone could point me in the right direction? Thanks <?php $active_keys = array(); foreach($_GET['img'] as $key => $filename) { if(!empty($filename)) { $active_keys[] = $key; } } ?> This script works fine except, the a href only displays baseurl/current_folder instead of baseurl/other_folder/other_folder/current_folder I'm sure it's simple, but I can't figure it out. Code: [Select] function breadcrumbs($separator = '', $home = 'Home') { $path = array_filter(explode('/', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))); $base_url = ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/'; $breadcrumbs = array("<p><a href=\"$base_url\">$home</a></p>"); $last = end(array_keys($path)); foreach ($path AS $x => $crumb) { $title = ucwords(str_replace(array('.php', '_'), Array('', ' '), $crumb)); $title = ucwords(str_replace(array('.html', '_'), Array('', ' '), $crumb)); if ($x != $last){ $breadcrumbs[] = "<p><a href=\"$base_url$crumb\">$title</a></p>"; }else{ $breadcrumbs[] = "<p>$title</p>"; } } return implode($separator, $breadcrumbs); } echo breadcrumbs(); I have a config file that lists a file like so.. Code: [Select] $file1 = 'storagefolder/mydatabase.txt'; How can I delete the file "mydatabase.txt" that is in another directory 'storagefolder' ? Code: [Select] unlink($file1);gives an error that says not such file or directory why cant i login in i have everything in my db this is the code Code: [Select] <?php session_start(); $email= $_SESSION['email']; ?> <?php if(loginbtn){ $email = $_POST['email']; $password = $_POST['password']; if($email && $password){ //connection to db require 'scripts/connect.php'; $query = mysql_query("SELECT * FROM users WHERE email='$email'"); $numrows = mysql_num_rows($query); if($numrows == 0){ $rows = mysql_fetch_assoc($query); $dbemail = $row['email']; $dbpassword = $row['password']; if($password==$dbpassword){ $_SESSION['email'] = $dbemail; echo "You have been logged in as $email"."<br/>"; }else echo "You enter a incorrect password"; }else echo "This person does not exsit"; }else echo "You did not fill in all the fields"; }else echo "$form"; $form = "<form action='login.php' method='POST'> <table> <tr> <td>Email</td> <td><input type='email' name='email'></td> </tr> <tr> <td>Password</td> <td><input type='password' name='password'></td> </tr> <tr> <td></td> <td><input type='submit' name='loginbtn' value='Login'></td> </tr> </table> </form>"; echo $form; ?> im trying to just search and display results from a price drop box but it doesnt seem to work it ignores the while statement and just prints the entire database heres my code if it helps Quote <?php mysql_connect("localhost", "root") or die(mysql_error()); // makes a connection mysql_select_db("estate_agents") or die('I cannot connect to the database because: ' . mysql_error()); //conects to the database $price = $_POST['Price']; $query = "SELECT * FROM properties"; $result = mysql_query($query); switch ($price) { case '1' : $price_low = 100; $price_high = 300 ; " (I would like to pay less and get less specifications) < ".$price_low."-".$price_high.">"; break; case '2' : $price_low = 200; $price_high = 500; " (I would like to pay for what I get so what I get is equivalent to the price) < ".$price_low."-".$price_high.">"; break; case '3' : $price_low = 400; $price_high = 700; " (I would prefer to Pay as much as possible to get the best computer) < ".$price_low."-".$price_high.">"; break; case '4' : $price_low = 600; $price_high = 900 ; " (I have no preference) < ".$price_low."-".$price_high.">"; break; case '5' : $price_low = 900; $price_high = 2000 ; " (I have no preference) < ".$price_low."-".$price_high.">"; break; } //gives the different vaules for each drop down option from the input form for price ?> <table border="1" width="100%" height="10"> <tr> <td bgcolor="#FFFFFF">House Number</td> <td bgcolor="#FFFFFF">Street NamePrice</td> <td bgcolor="#FFFFFF">Area</td> <td bgcolor="#FFFFFF">Postcode</td> <td bgcolor="#FFFFFF">Type of Property</td> <td bgcolor="#FFFFFF">Number of Bedrooms</td> <td bgcolor="#FFFFFF">Number of Bathrooms</td> <td bgcolor="#FFFFFF">Price</td> <td bgcolor="#FFFFFF">Image</td> <td bgcolor="#FFFFFF">Description</td> </tr> <?php while ($row = mysql_fetch_array($result)) { if (($row['Price'] >= $price_low) && ($row['Price'] <= $price_high)) //price ?> <tr> <td align="center" bgcolor="#FFFFFF"><?php echo $row["Address_Line_1"]; ?></a></td> <!-- fetch the model name from the database and display in table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Address_Line_2"]; ?> </td> <!-- fetch the price from the database and display in the table--> <td align="center" bgcolor="#FFFFFF"><?php print $row["Area"]; ?> </td> <!-- fetch the type from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Post_Code"]; ?> </td> <!-- fetch the type from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Type_of_Property"]; ?> </td> <!-- fetch the size from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Number_of_Bedrooms"]; ?> </td> <!-- fetch the skill from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Number_of_Bathrooms"]; ?> </td> <!-- fetch the style from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Price"]; ?> </td> <!-- fetch the style from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Property_Image"]; ?> </td> <!-- fetch the style from the database and display in the table --> <td align="center" bgcolor="#FFFFFF"><?php print $row["Description"]; ?> </td> <!-- fetch the style from the database and display in the table --> </tr> <?php }//while ?> i am newish to php any help is much appreciated Hi guys Im new here. Ive got a small problem. I have a simple uploading script, had problems with that too but its working fine now to a certain extent. When I set a download link for the files that have been uploaded and click to download, it downloads but I get the following errors when I open the file, its a .txt file. But it seems to happen on all files also, it allows me to download .png, .php, .jpg bout it wont actually open them once they are downloaded (Ive change the domain to an example, its not my actual domain within the warnings below): The following warnings occurred: Warning [2] filesize() [function.filesize]: stat failed for http://mydomain/expiry_files/downloads/text.txt" - Line: 69 - File: expiry_download.php PHP 5.2.17 (Linux) Warning [2] readfile(http://mydomain/expiry_files/downloads/text.txt") [function.readfile]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found - Line: 70 - File: expiry_download.php PHP 5.2.17 (Linux) Here my download file, most of it (Ive also attached an image of the text file after I downloaded it and opened it, below): if (isset($_GET['id'])){ $file_id = (int)$_GET['id']; $file = $db->query("SELECT * FROM ".TABLE_PREFIX."expiredownloads WHERE `id` = {$file_id}"); $row = $db->fetch_array($file); if ($row['expire_end'] < time()){ //// Do nothing Yet }else{ $link = ''.$mybb->settings['bburl'].'/expiry_files/downloads/'.$row['expire_file'].'"'; $filename = $row['expire_file']; header('Content-type: application/octetstream'); header('Content-type: application/octet-stream'); header('Content-Description: File Transfer'); header("Content-Disposition: attachment; filename=\"$filename\""); header('Content-Length:'.filesize($link)); readfile($link); } } Hope you guys can spot a problem, If you require anymore information, just shout. Thanks in advance. |