PHP - Js Code Problem
hi,
i combined two js code in one, gradient slider wroking and changed codes in text area. this is ok. but gradient colors can not displaying in textarea and also horizontal and vertical menu can not changing colors and codes.
what is my wrong ?
<div class="export"> <textarea name="baslikrengi_<?php echo $cnt1; ?>" cols="32" class="export" id="baslikrengi_<?php echo $cnt1; ?>"><?php echo KT_escapeAttribute($row_rskayan_icerikler['baslikrengi']); ?></textarea></div> <select id="orientation" onchange="changeOrientation();"> <option value="horizontal">Horizontal</option> <option value="vertical" selected="selected">Vertical</option> </select> <div class="gradient3"></div> <script> $(document).ready(function(){ $('.gradient3').ClassyGradient({ gradient: '#00ffff 0%,#008900 30%,#f00044 70%,#0042d2 100%', onChange: function(stringGradient,cssGradient) { $('.export').val(cssGradient); } }); }); $(document).ready(function() { $('.gradient3').ClassyGradient({ gradient: '#ebf1f6 0%,#ff9cff 40%,#ff6aff 61%,#ff2db7 100%', target: '.export' }); }); function changeOrientation() { var orientation = $('#orientation :selected').val(); $('.gradient3').data('ClassyGradient').setOrientation(orientation); } </script <script> $(document).ready(function() { $('.gradient').ClassyGradient(); }); </script> Edited by dgnzcn, 24 May 2014 - 04:49 AM. Similar TutorialsHi I'm using codeigniter for my php project i' already have a drop down list displayed in one page of the web browser which had dynamic values from my database, as soon as you click on the submit button it takes you to another page which has to display the cities from my database and that is not happening at the moment, this code used to work nicely when i had the cities displayed in a single page as the drop menu but doesn't anymore since i need the cities displayed on another page ,any help will be highly appreciated. <? function writeCities($id) { $con = mysql_connect("localhost","root",""); if (!$con) die('Could not connect: ' . mysql_error()); mysql_select_db("msansi", $con); $query = "SELECT cities FROM provinces WHERE id ="; $query .= $id; $result = mysql_query($query); $row = mysql_fetch_array($result); echo $row[0]; } function onChangeDropBox() { var selected =0; selected = document.myform.province.value; var t = ["<? writeCities(9);?>";] document.myform.submit.value = t; } Hi, i found this coding from a web site. Can anyone what is the meaning of this code when selecting data. $sql =("SELECT `customer_id`, `nic`, `full_name`, `name_with_initials`, `address`, `contact_number`, `gender` FROM `customer` WHERE `nic`='%s'", mysql_real_escape_string($_POST['nic']) ); $result=mysql_query($sql) or die( mysql_error() ); Specially that part where `nic`='%s'" and real_escape_string(). Thanks, Hello, I have in my script , a page called Account Details , and there is an option there to change the password . And to change it i must put the current password and the new password. My problem is that it doesn't recognize that i inserted the correct current password and it still says " you must add the correct current password ... " Here is the code , can you please check if it is the code or the SQL syntaxes who causes the problem ? Code: [Select] if($act == "updatePassword"){ //Update password $oldPass = hash("sha256", mysql_real_escape_string($_POST["currentPassword"])); $newPass = mysql_real_escape_string($_POST["newPassword"]); $newPassConfirm = mysql_real_escape_string($_POST["newPassword2"]); //If hash $oldPass is the same as the DB already hashed password continue you with the password change if($oldPass == $hashedPass){ //Check if new password is valid if($newPass != "" && strlen($newPass) > 6){ //Change the password only if $newPass == $newPassConfirm if($newPass == $newPassConfirm){ //Update hashed password $newHashedPass = hash("sha256", $newPass.$salt); $passchangeSuccess = mysql_query("UPDATE `webUsers` SET `pass` = '".$newHashedPass."' WHERE `id` = '".$userId."'"); if($passchangeSuccess){ $goodMessage = "Password successfully changed."; }else{ $returnError = "Database Failure - Unable to change password"; } }else if($newPass != $newPassConfirm){ $returnError = "The \"New Password\" and \"New Password Repeat\" fields must match"; } }else{ $returnError = "Your new password is not valid, Must be longer then 6 characters"; } }else if($oldPass != $hashedPass){ //Typed in password dosent match DB password $returnError = "You must type in the correct current password before you can set a new password."; } } And this is the input code ( html code ) Code: [Select] <b><u>Change Password</u></b><br/> <form action="/accountdetails.php" method="post"><input type="hidden" name="act" value="updatePassword"> <table> <tr><td>Current Password: </td><td><input type="password" name="currentPassword"></td></tr> <tr><td>New Password: </td><td><input type="password" name="newPassword"></td></tr> <tr><td>New Password Repeat: </td><td><input type="password" name="newPassword2"></td></tr> <tr><td>Authorize Pin: </td><td><input type="password" name="authPin" size="4" maxlength="4"></td></tr> </table> <span style="text-decoration: underline;">(You will be redirected to the login screen upon success)</span> <br /> <input type="submit" value="Update Password Settings"></form> <br /> <br /> I think it is because that $hashedPass is not identified ... right ? What should i do ? Thanks a lot for the help ! When i try to run the page...i ddnt see anything...its just a plane white background.. is there a problem in my code Code: [Select] <?php $con = mysql_connect ("localhost","root",""); if(!$con) { die ('could not connect:' . mysql_error()); } mysql_select_db ("users", $con); $username = "sample"; $sql = "SELECT * FROM `users` WHERE `id`='".username."'"; $res = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_assoc($res)) { $imagename = $_FILES['image']['imagename']; $tmp_name = $_FILES['image']['tmp_name']; $location = "avatar/".$imagename; move_uploaded_file($tmp_name,$location); $avatar = mysql_query("SELECT imagelocation FROM `users` WHERE `id`='".$username."'")or die(mysql_error()); $row3 = mysql_fetch_assoc($avatar); $location = $row3['imagelocation']; echo"<table width=\"686\" height=\"178\" border=\"0\">"; echo"<tr> <td width=\"160\" height=\"30\">First Name</td> <td width=\"321\">" . $row['name'] . "</td> </tr>"; echo"<tr> <td height=\"31\">Email Address</td> <td>" . $row['email'] ."</td> </tr>"; echo"<tr> <td height=\"28\">Username</td> <td>" . $row['username'] ."</td> </tr>"; echo"<tr> <td height=\"30\">ProfilePic</td> <td> </td> </tr>"; echo"<tr> <td><table width=\"100\" border=\"0\" align=\"center\"> <tr> <td><img src =\"$location\" width=\"100\" hieght=\"100\"></td> </tr>"; echo"</table></td>"; echo"<td><form id=\"form1\" name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"\"> <input type=\"file\" name=\"image\" id=\"image\" />"; echo"</form></td> </tr> </table>"; } mysql_close($con); ?> I have created a form, that contains multiple text fields. When the user clicks on the Submit button, the form data should be populated in MySQL, I have programmed it in a way, that it works well, but the problem is, Since it contains so many text fields that collects the Manufacturer, Brand and so on repeatedly, I have created multiple queries to populate the DB. Here is the code, Code: [Select] <?php include("connect.php"); if (isset($_POST['confirm_order'])) { $o_manufacturer = trim(@$_POST['o_manufacturer']); $o_brand = trim(@$_POST['o_brand']); $o_type = trim(@$_POST['o_type']); $o_exp_date = trim(@$_POST['o_exp_date']); $o_qty = trim(@$_POST['o_qty']); $o_unit = trim(@$_POST['o_unit']); $o_unit_price = trim(@$_POST['o_unit_price']); $o_package = trim(@$_POST['o_package']); $o_package_price = trim(@$_POST['o_package_price']); $o_selling_price_perUnit = trim(@$_POST['o_selling_price_perUnit']); $query = "INSERT INTO order_entry (o_sno, o_manufacturer, o_brand, o_type, o_exp_date, o_qty, o_unit, o_unit_price, o_package, o_package_price, o_selling_price_perUnit) VALUES ('', '$o_manufacturer', '$o_brand', '$o_type', '$o_exp_date', '$o_qty', '$o_unit', '$o_unit_price', '$o_package', '$o_package_price', '$o_selling_price_perUnit')"; $results = mysql_query($query); if ($results) { echo '<center><p class=small>Order updation successful, Click on LIST ORDERS button below to view the order entry.</p><br></center>'; echo '<center><a href="List_Orders.php" class="myButton">List Orders</a></center>'; } // Second Row Insertion if(!empty($_POST['o_manufacturer1'])) { $query = "INSERT INTO order_entry (o_sno, o_manufacturer, o_brand, o_type, o_exp_date, o_qty, o_unit, o_unit_price, o_package, o_package_price, o_selling_price_perUnit) VALUES ('', '".$_POST['o_manufacturer1']."' , '".$_POST['o_brand1']."' , '".$_POST['o_type1']."' , '".$_POST['o_exp_date1']."' , '".$_POST['o_qty1']."' , '".$_POST['o_unit1']."' , '".$_POST['o_unit_price1']."' , '".$_POST['o_package1']."' , '".$_POST['o_package_price1']."', '".$_POST['o_selling_price_perUnit1']."' )"; $results = mysql_query($query); } // Third Row Insertion if(!empty($_POST['o_manufacturer2'])) { $query = "INSERT INTO order_entry (o_sno, o_manufacturer, o_brand, o_type, o_exp_date, o_qty, o_unit, o_unit_price, o_package, o_package_price, o_selling_price_perUnit) VALUES ('', '".$_POST['o_manufacturer2']."' , '".$_POST['o_brand2']."' , '".$_POST['o_type2']."' , '".$_POST['o_exp_date2']."' , '".$_POST['o_qty2']."' , '".$_POST['o_unit2']."' , '".$_POST['o_unit_price2']."' , '".$_POST['o_package2']."' , '".$_POST['o_package_price2']."', '".$_POST['o_selling_price_perUnit2']."' )"; $results = mysql_query($query); } // Fourth Row Insertion if(!empty($_POST['o_manufacturer3'])) { $query = "INSERT INTO order_entry (o_sno, o_manufacturer, o_brand, o_type, o_exp_date, o_qty, o_unit, o_unit_price, o_package, o_package_price, o_selling_price_perUnit) VALUES ('', '".$_POST['o_manufacturer3']."' , '".$_POST['o_brand3']."' , '".$_POST['o_type3']."' , '".$_POST['o_exp_date3']."' , '".$_POST['o_qty3']."' , '".$_POST['o_unit3']."' , '".$_POST['o_unit_price3']."' , '".$_POST['o_package3']."' , '".$_POST['o_package_price3']."', '".$_POST['o_selling_price_perUnit3']."' )"; $results = mysql_query($query); } // Fifth Row Insertion if(!empty($_POST['o_manufacturer4'])) { $query = "INSERT INTO order_entry (o_sno, o_manufacturer, o_brand, o_type, o_exp_date, o_qty, o_unit, o_unit_price, o_package, o_package_price, o_selling_price_perUnit) VALUES ('', '".$_POST['o_manufacturer4']."' , '".$_POST['o_brand4']."' , '".$_POST['o_type4']."' , '".$_POST['o_exp_date4']."' , '".$_POST['o_qty4']."' , '".$_POST['o_unit4']."' , '".$_POST['o_unit_price4']."' , '".$_POST['o_package4']."' , '".$_POST['o_package_price4']."', '".$_POST['o_selling_price_perUnit4']."' )"; $results = mysql_query($query); } mysql_close(); } ?> Instead of posting the 'o_manufacturer ' value multiple times 'o_manufacturer1', 'o_manufacturer2', 'o_manufacturer3' and 'o_manufacturer4' I m looking for a code, that uses for loop or any other alternative ways that optimizes the code and works the proper way... NOTE : The file that i have attached is working 100% perfect, but I am looking for code optimization. Looking for help from experts.. Thanks a lot in advance... The issue is that if you f5 once attacking another player you can attack them again without any error message... Below is the code, is there a way to prevent the refresh from making the attack happen again? <?php $sql = "SELECT * FROM messages WHERE to_username = '$defender_info[username]' AND from_username = '$playerdata[username]' AND type = 'Combat' ORDER BY id DESC LIMIT 1"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $now = time(); $lastattack = strtotime($res['timestamp']); $timesince = $now - $lastattack; $nextatk = round((10800 - $timesince) / 60); if($timesince < 10800){ echo "You can only attack the same player once every 3 hours.<br><br> You can attack this player again in $nextatk minutes."; } else{ $sql = "SELECT hits FROM users WHERE id = $playerID"; $que = mysql_query($sql) or die(mysql_error()); $res = mysql_fetch_array($que); $hits = $res['hits']; if($hits < 1){ echo "You have no available hits. New hit allowances are granted every ten minutes on the :05's"; } else{ ?> heres the code... <?php mysql_connect("localhost","peter","tizer") or die("Error: ".mysqlerror()); mysql_select_db("matquant"); //replace TestTable with the name of your table //also in a real app you would get the id dynamically $idtochange=$_POST['idtochange']; $sql="select * from `quantites` where id = $idtochange"; $query=mysql_query($sql); while ($row=mysql_fetch_array($query)){ $id = $row['id']; $material = $row['material']; $quantity = $row['quantity']; $unit = $row['unit']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit material list</title> <link href="css/quant1.css" rel="stylesheet" type="text/css"> </head> <body> <div id="leftcol"> <form "method="post"> <p><br/> <input type="text"value="1" name="idtochange" > <p> <input type="submit"value="submit changes"/> </form> <form action="changequan.php"method="post"> <p>Material Id currently active<br/> <input type="text"value="<?php echo $id;?>" name="id" disabled/> </p> <p> Enter new material name: </p> <input type="text"value="<?php echo $material;?>" name="material"/> <br/> change quantity: <input type="text"value="<?php echo $quantity;?>" name="quantity"/> <br/> unit of mesurement for quantity<br/> <input type="text"value="<?php echo $unit;?>" name="unit"/> <br/> </p> <input type="submit"value="submit changes"/> </form> </div> <div id="rightcol"><?php // make connection mysql_connect ("localhost", "peter", "tizer") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); // build query $query = mysql_query("SELECT * FROM `quantites` ORDER BY `id` ASC"); // display results while ($row = mysql_fetch_array($query)) { echo "<br /> ..... " .$row ['id']. " ....... " .$row ['material']. " ...... " .$row['quantity']. " ...... " .$row['unit']. "<br />";} echo mysql_error(); ?> <a href="index.html">Home </a> <p> <a href="quanform.php">Insert new material and quantity form</a></p></div> </body> </html> I'm struggling with php. Any help anyone can give would be appreciated. I use session code to keep post data. It does not work well . I have put the program on the web site. This is the link . http://www.ptiimaging.ca/xx.php The program is for the whole web page. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="mainpage.css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>无标题文档</title> </head> <body> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="mainpage.css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>无标题文档</title> </head> <body> <div class="block"> <div class="logo"> <img src="images/ptiwci_logo_btrfly.jpg" /> <div class="boxlog"> <strong><p class="name">Nizar Goa</p></strong><br /> <em class="wordsinlogo">Managing Director</em><br /> <p class="details">#101, 17873-106A Avenue</p><br /> <p class="details">Edmonton,AB T5S 1V8</p><br /> <p class="details">PH (780) 452-3801</p><br /> <p class="details">FAX (780) 452-3832</p><br /> <p class="details">Cell (780)498-2072</p><br /> <p class="details">ptican@telus.net</p> </div> <p class="lastwords">Toners . Inkjets . Ribbons . Datamedia . Printers</p> </div> <div id="navcontainer"> <ul> <li><a href="index.php">Home</a></li> <li><a href="company.php">Company</a></li> <li><a href="product.php">Product</a></li> <li><a href="contract.php">Contract us</a></li> <li><a href="bestseller.php">Top seller</a></li> <li><a href="new.php">New product</a></li> </ul> </div> <div class="searchbox"> <form action="table3.php" method="post"> <input type="submit" name="submit" value="submit" /> <input type="text" name="search" /> </form> <p>Please search by OEM number</p> </div> <div class="clear"></div> <div class="rollingpicture left"> <object id="bcastr4" data="bcastr4.swf?xml=bcastr.xml" type="application/x-shockwave-flash" width="610.584" height="220"> <param name="movie" value="bcastr4.swf" /> </object> </div> <div class="xsnazzy"> <b class="xtop"><b class="xb1"></b><b class="xb2 color_a"> </b><b class="xb3 color_a"></b><b class="xb4 color_a"></b></b> <div class="xboxcontent"> <h1 class="color_a">search</h1> <form action="xx.php" method="post"> <select name="brand"> <option >brand</option> <option value="Apple">Apple</option> <option value="brother">Brother</option> <option value="Canon">Canon</option> <option value="Dell">Dell</option> <option value="Epson">Epson</option> <option value="HP">HP</option> <option value="lexmark">Lexmark</option> <option value="Samsung">Samsung</option> <option value="Sharp">Sharp</option> <option value="IBM">IBM</option> <option value="Lenovo">Lenovo</option> <option value="Konica-Minolta">Konica-Minolta</option> <option value="okidata">okidata</option> <option value="Mita">Mita</option> <option value="Ricoh">Ricoh</option> <option value="Source technology">Source technology</option> <option value="Standard Register">Standard Register</option> <option value="Tally Genicom">Tally Genicom</option> <option value="Tektronix">Tektronix</option> <option value="Toshiba">Toshiba</option> <option value="Unisys">Unisys</option> <option value="Xerox">Xerox</option> <option value="Xerox Ink Stricks">Xerox Ink Sticks</option> <option value="kyocera">kyocera</option> <option value="Postage Meters">Postage Meters</option> </select> <br /> <select name="sort"> <option >kind</option> <option value="Copier Toner">Copier Toner</option> <option value="Laser Toner">Laser Toner</option> <option value="MICR Toner">MICR Toner</option> <option value="Inkjet">Inkjet</option> </select><Br /> <select name="type"> <option >for</option> <option value="PC">Photo copier</option> <option value="Fax">Fax</option> <option value="Copier">Copier</option> <option value="Cheque">Cheque</option> <option value="Print">Printer</option> <option value="Copier/Fax">Copier/Fax</option> </select> <br /> <input type="submit" value="submit" name="submit" /> </form> </div> <b class="xbottom"><b class="xb4"></b><b class="xb3"></b> <b class="xb2"></b><b class="xb1"></b></b> </div> <div class="leftlist left"> <div class="nextbox"><strong> <center> Inkjet </center> </strong></div> <ul> <li><a href="table.php?id=<?php echo "Brother" ;?>&cd=<?php echo "Inkjet"; ?>">Brother</a></li> <li><a href="table.php?id=<?php echo "Kodak" ;?>&cd=<?php echo "Inkjet"; ?>">Kodak</a></li> <li><a href="table.php?id=<?php echo "PitenyBowes-PostageMeter&Franking system" ;?>&cd=<?php echo "Inkjet"; ?>">PitenyBowes-PostageMeter</a></li> <li><a href="table.php?id=<?php echo "Canon" ;?>&cd=<?php echo "Inkjet"; ?>">Cannon</a></li> <li><a href="table.php?id=<?php echo "Dell" ;?>&cd=<?php echo "Inkjet"; ?>">Dell</a></li> <li><a href="table.php?id=<?php echo "HP" ;?>&cd=<?php echo "Inkjet"; ?>">HP</a></li> <li><a href="table.php?id=<?php echo "Lexmark" ;?>&cd=<?php echo "Inkjet"; ?>">Lexmark</a></li> <li><a href="table.php?id=<?php echo "Samsung" ;?>&cd=<?php echo "Inkjet"; ?>">Samsung</a></li> <li><a href="table.php?id=<?php echo "sharp" ;?>&cd=<?php echo "Inkjet"; ?>">sharp</a></li> <li><a href="table.php?id=<?php echo "Xerox" ;?>&cd=<?php echo "Inkjet"; ?>">Xerox</a></li> </ul> <div class="nextbox"><strong> <center> Laser/MICR/Fax/TFR </center> </strong></div> <ul> <li><a href="table.php?id=<?php echo "Apple" ;?>&cd=<?php echo " Toner"; ?>">Apple</a></li> <li><a href="table.php?id=<?php echo "Brother" ;?>&cd=<?php echo " Toner"; ?>">Brother</a></li> <li><a href="table.php?id=<?php echo "Canon" ;?>&cd=<?php echo " Toner"; ?>">Canon</a></li> <li><a href="table.php?id=<?php echo "Dell" ;?>&cd=<?php echo " Toner"; ?>">Dell</a></li> <li><a href="table.php?id=<?php echo "Epson" ;?>&cd=<?php echo " Toner"; ?>">Epson</a></li> <li><a href="table.php?id=<?php echo "HP" ;?>&cd=<?php echo " Toner"; ?>">HP</a></li> <li><a href="table.php?id=<?php echo "IBM/Lenovo" ;?>&cd=<?php echo " Toner"; ?>">IBM/Lenovo</a></li> <li><a href="table.php?id=<?php echo "Kyocera/Mita" ;?>&cd=<?php echo " Toner"; ?>">Kyocera/Mita</a></li> <li><a href="table.php?id=<?php echo "Konica-Minolta/Minolta QMS " ;?>&cd=<?php echo " Toner"; ?>"> Konica-Minolta/Minolta QMS </a></li> <li><a href="table.php?id=<?php echo "Konica" ;?>&cd=<?php echo " Toner"; ?>">Konica</a></li> <li><a href="table.php?id=<?php echo "Lexmark" ;?>&cd=<?php echo " Toner"; ?>">Lexmark</a></li> <li><a href="table.php?id=<?php echo "Minolta" ;?>&cd=<?php echo " Toner"; ?>">Minolta</a></li> <li><a href="table.php?id=<?php echo "Okidata" ;?>&cd=<?php echo " Toner"; ?>">Okidata</a></li> <li><a href="table.php?id=<?php echo "Ricoh" ;?>&cd=<?php echo " Toner"; ?>">Ricoh</a></li> <li><a href="table.php?id=<?php echo "Samsung" ;?>&cd=<?php echo " Toner"; ?>">Samsung</a></li> <li><a href="table.php?id=<?php echo "TallyGenicom" ;?>&cd=<?php echo " Toner"; ?>">Tally Genicom</a></li> <li><a href="table.php?id=<?php echo "Tektronix" ;?>&cd=<?php echo " Toner"; ?>">Tektronix</a></li> <li><a href="table.php?id=<?php echo "Toshiba" ;?>&cd=<?php echo " Toner"; ?>">Toshiba</a></li> <li><a href="table.php?id=<?php echo "Unisys" ;?>&cd=<?php echo " Toner"; ?>">Unisys</a></li> <li><a href="table.php?id=<?php echo "Xerox" ;?>&cd=<?php echo " Toner"; ?>">Xerox</a></li> <li><a href="table.php?id=<?php echo "Xero Ink Sticks" ;?>&cd=<?php echo " Toner"; ?>">Xerox Ink Sticks</a></li> <li><a href="table.php?id=<?php echo "Gestetner" ;?>&cd=<?php echo " Toner"; ?>">Gestetner</a></li> <li><a href="table.php?id=<?php echo "Lanier" ;?>&cd=<?php echo " Toner"; ?>">Lanier</a></li> <li><a href="table.php?id=<?php echo "TROY" ;?>&cd=<?php echo " Toner"; ?>">TROY</a></li> <li><a href="table.php?id=<?php echo "Lexmark/Troy" ;?>&cd=<?php echo " Toner"; ?>">Lexmark/Troy</a></li> <li><a href="table.php?id=<?php echo "Okidata" ;?>&cd=<?php echo " Toner"; ?>">Okidata</a></li> <li><a href="table.php?id=<?php echo "Sharp" ;?>&cd=<?php echo " Toner"; ?>">Sharp</a></li> <li><a href="table.php?id=<?php echo "Piteny Bowes /Imagistics" ;?>&cd=<?php echo " Toner"; ?>">Piteny Bowes /Imagistics</a></li> <li><a href="table.php?id=<?php echo "Panasonic" ;?>&cd=<?php echo " Toner"; ?>">Panasonic</a></li> <li><a href="table.php?id=<?php echo "Savin" ;?>&cd=<?php echo " Toner"; ?>">Savin</a></li> <li><a href="table.php?id=<?php echo "HP/ Troy" ;?>&cd=<?php echo " Toner"; ?>">HP/ Troy</a></li> <li><a href="table.php?id=<?php echo "Source Technologies" ;?>&cd=<?php echo " Toner"; ?>">Source Technologies</a></li> <li><a href="table.php?id=<?php echo "Ricoh/SindoRicoh" ;?>&cd=<?php echo " Toner"; ?>">Ricoh/SindoRicoh</a></li> <li><a href="table.php?id=<?php echo "Royal Copystar/Copystar" ;?>&cd=<?php echo " Toner"; ?>"> Royal Copystar/Copystar</a></li> <li><a href="table.php?id=<?php echo "Source Technologies" ;?>&cd=<?php echo " Toner"; ?>"> Standard Register</a></li> </ul> </div> <div class="boxright right"> <?php include("connection.php"); session_start(); $_SESSION['brand']=$_POST['brand']; $_SESSION['type']=$_POST['type']; $_SESSION['sort']=$_POST['sort']; if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; }; $start_from = ($page-1) * 23; $select="select * from $chun where brand = '$_SESSION[brand]' or sort='$_SESSION[sort]' or type ='$_SESSION[type]' LIMIT $start_from, 18"; $result2=mysql_query($select, $connection) or die (mysql_error()); ?> <h1 >Inkjet and Toner Cartridges for the printing device </h1> <p class="writeword">PTi is a leading Remanufacturer and distributor of compatible cartridges and orginal product. We also offer the most comprehensive selection of remanufactured ink cartridges for HP printers at low prices. Along with our 100% Quality Guaranteed HP toner cartridges, we also offer high quality compatible inkjet cartridges for many printers at highly competitive prices. All our products are proudly manufactured in the U.S.A. Enter your search criteria at the top of the page to view details on a specific cartridge. For our award winning customer service, call (780) 4523801 </p> <table class="tableinsert"> <tr> <th>Pti Item#</th> <th>OEM Part#</th> <th>Machine Compatibilty</th> <th>Color</th> <th>Dealer price</th> <th>OEM Price</th> </tr> <?php while ($row=mysql_fetch_array($result2)) { ?> <tr> <td><?php echo $row['item'];?></td> <td><a href="ddl.php?wd=<?php echo $row['id'] ;?>"><?php echo $row['oempart'];?></a></td> <td><?php echo $row['compatibility'];?></td> <td><?php echo $row['colorful'];?></td> <td>$<?php echo $row['comprice']; ?></td> <td><?php echo $row['oemprice']; ?></td> </tr> <?php }; ?> </table> <?php $sql = "select count(*) from $chun where brand = '$_SESSION[brand]' or type ='$_SESSION[type]' or sort='$_SESSION[sort]' "; $rs_result = mysql_query($sql,$connection); $row = mysql_fetch_row($rs_result); $total_records = $row[0]; $total_pages = ceil($total_records / 23); for ($i=1; $i<=$total_pages; $i++) { ?> <div class="trunpage"><a href='table2.php?page=<?php echo "$i" ; ?>&id=<?php echo $_SESSION['brand'];?>&cd=<?php echo $_SESSION['type'];?>&td=<?php echo $_SESSION['sort'];?>' ><?php echo "$i" ; ?></a> </div> <?php } ?> </div> <div class="lineone"></div> <div class="footer"> <p>Copyright 2007-2010 www.ptiimaging.ca Inc. Canada All rights reserved. You can reach us at : By Mail: 17873 106a ave, Unit 101 Edmontn Alberta T5S 1V8 By phone: 1-780-452-3801 By Fax: 1-780-452-3832 By email: ptican@telus.net </p> </div> </div> </body> </html> I have this code: Quote
$result = mysql_query($sql); The problem is that when I choose an option from the dropdown (in this case Majestic Lanes) and click submit, it sends me to this URL: https://test.com/forum/index.php?%2Fsearch%2F%26q%3D+%0D%0A%26type%3Dcms_records7%26search_and_or%3Dand%26search_in%3Dtitles=Majestic+Lanes I need it to send me to this URL: https://test.com/forum/index.php?/search/&q=Majestic%20Lanes%20&type=cms_records7&search_and_or=and&search_in=titles I don't know PHP well enough to fix the code myself. Can anyone assist with this please? Sorry this page is not available or has been accessed in error An error occurred in script 'C:\xampp\htdocs\public_html\login\plugins\delete_product.php' on line 45: Undefined variable: id Date/Time: 8-24-2010 00:50:10 Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET] => Array ( [id] => 2 ) <?php # Script 9.2 - delete_product.php // This page is for deleting a album. require_once ('../includes/config.inc.php'); // Check for a valid product ID, through GET or POST: if ( (isset($id)) && (is_numeric($id)) ) { // From editproducts.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form submission. $id = $_POST['id']; } else { echo '<p class="error">Sorry this page is not available or has been accessed in error</p>'; } echo $id; require_once(MYSQL); // Check if the form has been submitted: if (isset($_POST['submitted'])) { if ($_POST['sure'] == 'Yes') { // Delete the record. // Make the query: $q = "DELETE FROM products WHERE product_id='$id' LIMIT 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Print a message: echo '<p>The Product has been deleted.</p>'; } else { // If the query did not run OK. echo '<p class="error">The Product could not be deleted due to a system error.</p>'; // Public message. echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message. } // Make the query: $q = "DELETE FROM photos WHERE product_id='$id'"; $r = @mysqli_query ($dbc, $q); } else { // No confirmation of deletion. echo '<p>The Product has NOT been deleted.</p>'; } } else { // Show the form. // Retrieve the albums information: $q = "SELECT name FROM products WHERE product_id='$id' Limit 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); $form = $_SERVER['PHP_SELF']; // Create the form: echo '<form action="' . $form . '" method="post"> <h1>Delete ' . $row[0] . '?</h1> <p>Are you sure you want to delete ' . $row[0] . '?<br /> <p><b>Warning if you delete this album all content inside of it will be losed!</b><br /> <input type="radio" name="sure" value="Yes" /> Yes <input type="radio" name="sure" value="No" checked="checked" /> No</p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } } mysqli_close($dbc); ?> Hi guys.I've got a problem.I'm building my php browsergame and i'm stuck into the inventory page.I have a code that seems ok to me but it won't work.Here it is: $inventory = array(); $query = sprintf("SELECT id, item_id, quantity FROM user_items WHERE user_id = '%s'", mysql_real_escape_string($userID)); $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $item_query = sprintf("SELECT name FROM items WHERE id = '%s'", mysql_real_escape_string($row['item_id'])); $item_result = mysql_query($item_query); list($row['name']) = mysql_fetch_row($item_result); array_push($inventory,$row); } I've spotted the problem.The $inventory array is empty.I checked it with if(empty($inventory)) .Thanks in advance and keep in mind that I'm a noob yet. hello I need to fix code display problem. The code below cause the disorder problem. When I delete the part of it , the code display in the right way. I do not really understand it . The template try to use bx_textarea to display code,so I find the function in it. Finally , I found this function cause the disorder code problem. Code: [Select] <?php echo bx_highlight(bx_textarea($view_query_result['jdescription']), $kwd_search);?> Code: [Select] if ($char == "<") { $skip=1; } elseif ($char == ">") { $skip=0; } elseif ($char == " ") { $wrap=0; } if ($skip==0) { $wrap=$wrap+1; } Code: [Select] function bx_wordwrap($a_str, $a_break_length=75) { $length = strlen($a_str); for ($i=0; $i<=$length; $i=$i+1) { $char = substr($a_str, $i, 1); if ($char == "<") { $skip=1; } elseif ($char == ">") { $skip=0; } elseif ($char == " ") { $wrap=0; } if ($skip==0) { $wrap=$wrap+1; } $res_str = $res_str . $char; if ($wrap>$a_break_length) { $res_str = $res_str." "; $wrap=0; } } return $res_str; } function bx_textarea($text) { return nl2br(preg_replace('/\t/',' ',bx_wordwrap($text, 75))); }//end function bx_textarea($text) Can somebody please help me sort this code out I have wirtten/got from a tutorial from phpfreaks - http://www.phpfreaks.com/tutorial/basic-pagination. The code correctly knows the number of pages needed in order to display the records from the database, but it displays all records on each page. I have 4 records and want 2 records to be shown on each page, but the code below displays all 4 records on both pages. Can someone please shed some light onto how I can display the first 2 records on the first page, and the second 2 records on the second page? code below: Code: [Select] <?php //Connect to the database $user="username"; $password="password"; $database="database"; $con = mysql_connect("localhost",$user,$password) or die ('Could not connect: ' . mysql_error()); mysql_select_db($database, $con) or die( "Unable to select database"); // Determine number of rows in database $query = mysql_query("SELECT * FROM vids"); $numrows=mysql_num_rows($query); // number of rows to show per page $rowsperpage = 2; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $result = mysql_query("SELECT * FROM vids"); while($row = mysql_fetch_array($result)) { $id = $row['id']; $url = $row['url']; $page_url = $row['page_url'];; $title = $row['title']; $desc = $row['desc']; $date_add = $row['date_add']; $date_rec = $row['date_rec']; $place = $row['place']; $altitude = $row['altitude']; $jump_no = $row['jump_no']; //Display video echo "<div class='sky_cont'> <div class='sky_vid'><a class='video' href=\"$url\"><img src='http://www.netlinksurveyors.co.uk/test/images/lgo.jpg' alt=\"$title\" Border='0' /></a></div> <p><h4><a href=\"$page_url\" target='_blank'>$title</a></h4>$desc</p> </div>"; } /****** build the pagination links ******/ // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\quantities.php on line 21 This is the error message. This is the code. simple array query to display contents of table and I cant see where i have made the mistake. hopefully someone can help. <?php mysql_connect ("localhost", "******", "*****") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); $query = mysql_query("SELECT * FROM quantities"); while ($row = mysql_fetch_array($query)) { //line referred to in error message echo "<br /> ID: " .$row ['id']. " material : " .$row ['material']. "quantity:" .$row['quantity']. "<br />";} ?> Please point out the probably glaring error. I'm relatively new to this and I am really not finding php easy to learn. Friends this is a very strange problem i,m facing i made a form by which you can enter comments to a topic i get the comment title and comment topic and date and the name and e mail of the one who insert a comment according to these variables $id1=$row2['id']; echo "$id1"; //Comment poster,s name $name =strip_tags(@$_POST['coname']); //Comment title $title =strip_tags(@$_POST['comtitle']); //ment poster,s email $mail =strip_tags(@$_POST['comemail']); //comment $com =strip_tags(@$_POST['limitedtextarea']); //comment,s date $d= date("Y-m-d"); notice that i,m printing the topic id and i used the variable $id1 to get it inorder to use it to show the comments for this topic later and it shows the right id for the shown topic then i used this code to insert these variable into the database if(isset($_POST['add']) and $_POST['add']=='comm'){ $insertcomm =mysql_query("INSERT INTO comments (com_name,com_title,com_mail,comment,com_date,tid) VALUES ('$name','$title','$mail','$com','$d','$id1')") or die("comments were not inserted"); if(isset($insertcomm)){ echo "comment inserted ";} } hi folks I have a problem with the code to change the password, it shows the message all time when I send the form: old password dont match! <?php session_start(); $user = $_SESSION['first_name']; if ($user) { //user is logged in if ($_POST['submit']) { //check fields $oldpassword = md5($_POST['oldpassword']); $newpassword = md5($_POST['newpassword']); $repeatnewpassword = md5($_POST['repeatnewpassword']); //check password against db //connect db $connect = mysql_connect("*******","****","****") or die(""); mysql_select_db("****") or die(""); $queryget = mysql_query("SELECT password FROM users WHERE username='$user'") or die("Query didnt work !!!"); $row = mysql_fetch_assoc($queryget); $oldpassworddb = $row['password']; //check password if ($oldpassword==$oldpassworddb) { //check to new password if ($newpassword==$repeatnewpassword) { //success //change password in db $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$user'") or die (""); session_destroy(); die("YOUR PASSWORD HAS BEEN CHANGED.<a href='login_form.html'>RETURN</a> TO THE LOGIN PAGE"); } else die("new password dont match"); } else die("old password dont match"); } else { echo" <form action='changepassword.php' method='POST'> Old password: <input type='text' name='oldpassword'><br/> New password: <input type='password' name='newpassword'><br/> Repeat new password: <input type='password' name='repeatnewpassword'><br/> <input type='submit' name='submit' value='change password'> </form>"; } } else echo("YOU MUST BE LOGGED IN!!!!.<br><a href='login_form.html'>RETURN</a> TO THE LOGIN PAGE"); ?> please help thanks! Registration.php Code: [Select] <html> <head> <script type="text/javascript"> function a() { var x = document.login.username.value; var y = document.login.pass.value; if(x==""&& y=="") { alert("Please insert all message!"); return false; } if(x=="") { alert("Please insert an username!"); return false; } if(y=="") { alert("Please insert an password!"); return false; } } </script> </head> <?php session_start(); mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); //session_start(); $username = $_POST['username']; $password = $_POST['pass']; if (isset($_POST["submit"])) { $log = "SELECT * FROM regis WHERE username = '$username'"; $login = mysql_query($log); $number = mysql_num_rows($login); if ($number == 0) { print "That user does not exist in our database. <a href=registration.php><input type='button' value='Register'></a>"; } if ($number > 0) { $_SESSION['is_logged_in'] = 1; } if(!isset($_SESSION['is_logged_in'])) { } else { echo "<meta http-equiv='refresh' content='0; url=form2.php'>"; } } else { ?> <body> <table border="0"> <form name="login" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return a()"> <tr><td colspan=2><h1>Login</h1></td></tr> <tr><td>Username:</td> <td><input type="text" name="username" maxlength="40"></td></tr> <tr><td>Password:</td> <td><input type="password" name="pass" maxlength="50"></td></tr> <tr><td><input type="submit" name="submit" value="Register"></a></td> <td><input type="submit" name="submit" value="Login"></td></tr> </form> </body> <?php } ?> </html> form2.php Code: [Select] <?php session_start(); if (!isset($_SESSION['is_logged_in'])) { header("Location:login.php"); die(); // just to make sure no scripts execute } ?> <?php mysql_connect("localhost","root") or die(mysql_error()); mysql_select_db("cute") or die(mysql_error()); $message=$_POST['message']; $n=$_POST['username']; if(isset($_POST['submit'])) //if submit button push has been detected { if(strlen($message)>1) { $message=strip_tags($message); $IP=$_SERVER["REMOTE_ADDR"]; //grabs poster's IP $checkforbanned="SELECT IP from ipbans where IP='$IP'"; $checkforbanned2=mysql_query($checkforbanned) or die("Could not check for banned IPS"); if(mysql_num_rows($checkforbanned2)>0) //IP is in the banned list { print "You IP is banned from posting."; } else { $thedate = date("U"); //grab date and time of the post $insertmessage="INSERT into chatmessages (name,IP,postime,message) values('$n','$IP','$thedate','$message')"; mysql_query($insertmessage) or die("Could not insert message"); } } } ?> <html> <head> <script type="text/javascript"> function addsmiley(code) { var pretext = document.smile.message.value; this.code = code; document.smile.message.value = pretext + code; } function a() { var x = document.smile.message.value; if(x=="") { alert("Please insert an message!"); return false; } } </script> <style type="text/css"> body{ background-color: #d8da3d } </style> </head> <body> <form name="smile" method="post" action="form2.php" onSubmit="return a()" > Your message:<br><textarea name='message' cols='40' rows='2'></textarea><br> <img src="smile.gif" alt=":)" onClick="addsmiley(':)')" style="cursor:pointer;border:0" /> <img src="blush.gif" alt=":)" onClick="addsmiley('*blush*')" style="cursor:pointer;border:0" /> <input type="hidden" name="username" value="<?php echo $n;?>"> <input type='submit' name='submit' value='Send' class='biasa' ></form> <br> <br> </body> </html> My problem is after i login it redirect to login page although im had put after login page its need to go to form2.php page may i know which problem because now only im learning session Hi everyone I just getting back to PHP after a break but have forgot how to build a HTML table row. Here is the part of the code that builds up rows for a html table... while($rows = mysql_fetch_array($qry)){ $table .= " <tr> <td><input type=\"checkbox\" name=\"C1\" value=\"ON\"></td> <td width=\"87\">$rows['ref']</td> <td width=\"178\">$rows['transactionReferenceNumber']</td> <td>$rows['totalAmountReceived']</td> <td>$rows['myItemQuantity']</td> <td>$rows['flag_1']</td> <td>$rows['flag2']</td> </tr> "; } This causes an error as you might expect. Please tell me the best way to place the html code into $table This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350214.0 |