PHP - [jquery] Onmouseover Opacity Layer Except Selected Block (overlay) Crazy Behavior
Visit: http://testowa.testy...e/testy-na-mocz (the behavior is going crazy). Has anybody got maybe any clue on how to fix it to work correctly?
Code itself. http://jsfiddle.net/LYcm9/5/
Similar TutorialsI want when onmouseover on particular section to put an OPACITY #fff 0.2 layer on everything except the selected class i.e. table
Similarly as you have:
.tableHighlight:hover{background-color:#eee} <table id='table-main' class='tableHighlight'> ... but inversed (puts layer on everything else, but not the table itself) --- http://jsfiddle.net/LYcm9/1/ Here is the code I have right now:
<?php header('Content-type: image/png'); $grey = new ImagickPixel('#ebebeb'); $orange = new ImagickPixel('#0f92d6'); $image = new Imagick('assets/lop.png'); $layer = new Imagick('assets/lop-base.png'); $layer->thumbnailImage(200, 0); $image->thumbnailImage(200, 0); $layer->paintOpaqueImage($grey, $orange, 100); // Place layer on image $image->compositeImage($layer, Imagick::COMPOSITE_SOFTLIGHT, 0, 0); // Let's merge all layers (it is not mandatory). $image->flattenImages(); echo $image; ?>It's putting the layers on top of eachother very nice. The thing is is that this involves some heavy shading at times depending on the bunny breeds. Here is what the base image ($image) looks like: And here is what the overlay ($layer) looks like: This is what the outcome looks like versus the intended result: I've tried almost all of their composite constants.. I can't figure out how to do this or the best way of going about it. Because the colors are going to be dynamic throughout the site so I can't just save a .png of every color combination.. and there will be more colors layered on top of eachother like markings/patterns/etc. Thanks for any help! I have this loop on a shorturl website i own that selects domains from my website and lists them in a dropdown list where users can select one domain to use as url shortener. The problem is that when a users selects and entry from the dropdown list this created only the [[[main_url]]] entry from the database table bellow can be used. When someone selectes "coolartistname.site.com the submit button cannot be pressed. in other words it's not adding the SELECTED attribute other than the [[[main_url]]] domain. Can anyone see on the code bellow why this would happen?
**Index.php** // get base urls $shortUrlDomains = getShortUrlDomains(); <?php foreach ($shortUrlDomains AS $k => $shortUrlDomain) { // active domains only if (($shortUrlDomain['premium_only'] !== '1') && ($shortUrlDomain['premium_only'] !== $Auth->id)) { continue; } echo '<option value="' . (int)$k . '"'; if (isset($_REQUEST['shortUrlDomain'])) { if ($k == (int)$_REQUEST['shortUrlDomain']) { echo 'SELECTED'; } } echo '>'; echo $shortUrlDomain['domain']; if ($disabled == true) { echo ' (' . safeOutputToScreen(t('unavailable', 'unavailable')) . ')'; } '</option>'; } echo '</optgroup>'; ?> FUNCTIONS.PHP function getShortUrlDomains() { // if we already have it cached if(defined('_SETTINGS_SHORT_URL_DOMAINS')) { return unserialize(_SETTINGS_SHORT_URL_DOMAINS); } // get connection $db = Database::getDatabase(true); // load from database $domains = $db->getRows("SELECT id, domain, premium_only, status FROM url_domain ORDER BY premium_only ASC, id ASC"); // organise and replace site url $rs = array(); foreach($domains AS $domain) { if($domain['domain'] == '[[[main_url]]]') { $domain['domain'] = _CONFIG_SITE_FULL_URL; } $rs[$domain{'id'}] = $domain; } **MYSQL DATABASE** url_domain (id, domain, premium_only, status, date_created, owner) VALUES (1, '[[[main_url]]]', 0, 'enabled', '2019-03-02 08:13:00', 1) (14, 'coolartistname.site.com', 6, 'enabled', '2020-04-18 19:21:59', 6);
Hello. I'm currently trying to write a code to merge two separate images together, but for the life of me I can't find anything that works. Basically what I'm trying to do is add a "marking" (cat_stripes.png) to a pet image (cat.png). In the future I also want to use this for adding items to pets and things like that. Both of the images have transparent backgrounds, so that needs to be taken into account. If you haven't got a clue what I'm talking about, look up Wajas or similar virtual pet sites to get an idea of how the markings work. I just need something simple, since I don't have a site set up yet and I'm just testing some things out for a future project. I don't have any codes at the moment, since nothing has worked so far. I'm pretty new to GD too (I'm familiar with all the basic php stuff, so don't panic), so you might need to explain some of the more advanced stuff to me. Any help with this would be really appreciated, thanks. (: hey guys im trying to impliment a overlay to images uploaded by the user to allow to delete and crop...now im not sure if im going aroung this the right way (but it works sort of)...the problem im having is that the overlay.gif which is a transparent image which has 2 small images at the top of each corner...but when the original image is hovered over the overlay is out of position showing the 2 small images at the bottom of the div and not at the top where it should be.
im guessing it is a css issue...any advise would be greatly appreciated...thank you
#overlay { width: 110px; height: 110px; } .selected-image{ width: 110px; height: 110px; } #overlay:hover .selected-image { opacity: 0.4; filter: alpha(opacity=40); } #overlay:hover { background-image: url('overlay.gif'); width: 110px; height: 110px; } <div id="overlay"><img class="selected-image" src="logo.png" /></div> Need another set of eyes... I am getting: Quote Warning: Invalid argument supplied for foreach() in ... on line 83 $dup = array(); // Create an array to store the duplicate entries. foreach($fileList as $filename) { if (($handle = fopen(UPLOAD_PATH.$filename, "r")) != FALSE) { // Create the input array while(($data = fgetcsv($handle, 0, ",")) != FALSE) { $sql = "SELECT id FROM leads.prospect WHERE (email='{$data[3]}' OR phone='" . $format->stripPhoneChars($data[2]) . "') LIMIT 1"; $result = $db->query($sql); if (mysql_num_rows($result) == 0) { $sql = "INSERT IGNORE INTO leads.prospect (email, phone, ip, firstName, lastName, resort) VALUES ('" . trim($data[3]) . "', '" . $format->mysqlSafe($data[2]) . "', '" . $format->mysqlSafe($data[5]) . "', '" . $format->mysqlSafe($data[0]) . "', '" . $format->mysqlSafe($data[1]) . "', '" . $format->mysqlSafe($data[4]) . "')"; $result = $db->query($sql); $added++; } else { $dup = array_push($dup, array($data[0], $data[1])); } } fclose($handle); // Close the file } else { echo "<p>Could not load file $filename</p>"; } } echo "$added records added."; // Show me the duplicate data! echo "<h2>This is the data that would be dumped into the duplicate CSV file:</h2> <h3>" . count($dup)." Duplicates:</h3><ol>"; print_r($dup); echo $dup; foreach($dup as $d) { // <-------------------------------------- LINE 83 echo "<li>$d[0] $d[1] $d[2] $d[3]</li>"; } echo "</ol>"; Hi guys, I am currently working on one of my assignments that requires PHP and think of myself as a beginner programmer, only having knowledge of Python and JavaScript. So I have a page that allows me to upload files to the server(no problem here), then I created a drop down menu that shows list of these and depending on which is selected can be viewed after clicking on a submit button(again no problem here). The problem occurs that after clicking submit to save the changes, it refreshes variable containing which file is the target and doesn't save the changes. Tried using sessions, but with no success and I am going absolutely crazy with this. I have been trying to resolve the issue for 5 hours straight. Here is the code if anyone is keen to help me out: <html> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>P2</title> <style> .uploadbox { background-color: skyblue; border: 1px, solid black; margin: 10px; padding: 5px; width: 20%; height: 10%; line-height: 50px; } .selectbox { background-color: skyblue; border: 1px, solid black; margin: 10px; padding: 5px; width: 25%; max-height: 50%; } </style> </head> <body> <h1>File Upload</h1> <form class="uploadbox" action="upload.php" method="post" enctype="multipart/form-data"> Select to upload: <input type="file" name="fileUpload1" id="fileUpload1"> <input type="submit" value="Upload file" name="submit"> </form> <br> <?php session_start(); $dirpath="uploads/"; $filenames=""; if(is_dir($dirpath)) { $files=opendir($dirpath); if($files) { while(($filename=readdir($files))!=false) if($filename!="." && $filename!="..") { $filenames=$filenames."<option>$filename</option>"; } } } $url = 'index.php'; $_SESSION['Open'] = htmlEntities($_POST['Open']); $file="uploads/".$_SESSION['Open']; // check if form has been submitted if (isset($_POST['text'])) { // save the text contents $newcontent = $_POST['text']; file_put_contents($file, $newcontent); // redirect to form again //header(sprintf('Location: %s', $url)); //printf(htmlspecialchars($url)); // exit(); } // read the textfile $text = file_get_contents($file); echo($newcontent); echo($file); echo($_SESSION['Open']); ?> <div class="selectbox"> <form action="" method="post"> <select name="Open"><?php echo $filenames; ?></select> <input type="submit" value="Open"/> </form> <form action="" method="post"> <textarea style="width:90%; height:20%;" name="text"><?php echo htmlspecialchars($text) ?></textarea> <br> <input type="submit" value="Save"/> </form> </div> </body> </html>
So i am currently coding database connection class and i have encountered very strange behavior from my script. base.class.php: Code: [Select] <?php class base{ private $settings; function get_settings(){ $settings["dbhost"] = 'localhost'; $settings["dbuser"] = '*****'; $settings["dbpass"] = '*****'; $settings["dbname"] = 'core'; return $settings; } } ?> database.class.php Code: [Select] <?php require_once 'base.class.php'; class database extends base{ private $query_now; private $link; public function __construct(){ $settings = base::get_settings(); $dbhost = $settings["dbhost"]; $dbuser = $settings["dbuser"]; $dbpass = $settings["dbpass"]; $dbname = $settings["dbname"]; $this->link = mysql_connect($dbhost, $dbname, $dbpass) or die ("Could not connect to the mysql database"); mysql_select_db($dbname, $this->link) or die ("Could not select the database"); } function query($query){ $this->query_now = $query; return mysql_query($query, $this->link); } function getArray($result){ return mysql_fetch_array($result); } } ?> When i try to create an instance of database class, i get mysql_connect error. I have tried to echo my array and it seems that correct information is being passed over. Now the strange thing is if i remove my password from the base class i don't get a mysql_connect error but this time instead i get "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'core'@'localhost' (using password: YES) " In case you are wondering, does my mysql database user has a password, the answer is: yes for sure... (Also i have tried to setup a simple script for connecting to my database and everything worked fine) So any ideas? I'm returning a table row that contains information about a file, but it seems in IE versions older than 10, it is cutting off some of the returned json when being used.
The data is being returned properly as seen in the following json:
{"file_name":"<i class='video'><\/i> <a href=\"\/Development\/test(4).mp4\" class=\"is_file\" target=\"_blank\">test(4).mp4<\/a>"}But when you use it, it cuts off the html. A simple alert will return </i> test(4).mp4</a>and same when appending it and the sort. It is also happening for another part of HTML that is being returned properly in the json. It is working for everything else that is returned. I have been searching around for a very long time trying to find why this is happening. Has anyone other than me encountered this? This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353396.0 Okay, real simple issue, hopefully someone has a simple solution. I have a single web page that needs to connect to TWO different databases. I've written everything in OO, and I'm getting a crazy situation where vars seem to be bleeding into each other. The problem goes like follows: I declare two SEPARATE database instances like so: require_once '/blah/classes/db/class.DBCMS.php'; require_once '/blah/classes/db/class.DBC.php'; $db1 = new DBC(); $db2 = new DBCMS(); I then pass in the $db(n) variables to a separate class to be used to process data like so: $publisher = new htmlCreator1($db1); $publisher = new htmlCreator2($db2); My problem is thus: INSIDE the respective different classes, my references to the $db vars seem to be colliding between instances. So $this->db->connection from db2 is referencing db1. The objects are defined like so: class htmlCreator1 { var $db; function __construct($db) { $this->db = $db; } } Shouldn't the respective $this->db's maintain their own namespace without extra work? I'm getting errors saying that tables in db2 aren't in db1 because of this collision as per the internal db instance vars. I have experimented with renaming all respective vars to unique names and still get the error. I'm crazy aren't I? Any help would be greatly appreciated. thanks, Dr. ok this works fine and everything but when here when i try to let the admin changes stuff and goes to change the venue a list show appear and it does but when it save it save it as RBB FIELD <option value="RED BULL ARENA">RED BULL ARENA</option><option value="RBB FIELD ">RBB FIELD </option><option value="RED BULL ARENA">RED BULL ARENA</option> why does it do that?? HElp ANYONE Code Code: [Select] <?php if (isset($_GET['eid'])){ $newid = $_GET['eid']; $sqlCommand = "SELECT * FROM events WHERE id='$newid' LIMIT 1"; $out = mysql_query($sqlCommand); $row = mysql_fetch_assoc($out); $eventid = $row["id"]; $eventname = $row["eventname"]; $eventtype = $row["typeevent"]; $eventinfo = $row["eventinfo"]; $date = $row["date"]; $time = $row["time"]; $livetickets = $row["sale"]; $numtickets = $row["numtickets"]; $pricestudents = $row["studentsprice"]; $priceseniors = $row["seniorsprice"]; $priceadults = $row["adultsprice"]; $venues = $row["venue"]; $category = $row["category"]; $query = mysql_query("SELECT venuename FROM venue"); while ($row = mysql_fetch_array($query)){ $venues .= '<option value="' . $row['venuename'] . '">' . $row['venuename'] . '</option>'; } $form = "<form action='eevent.php' method='post' enctype='multipart/form-data'> <table> <tr> <td>REQUIRED FIELDS *</td> <td></td> </tr> <tr> <td>Event Name*</td> <td><textarea cols='17' rows='1' name='eventname' />$eventname</textarea></td> </tr> <tr> <td>Type of event*</td> <td><textarea cols='17' rows='1' name='typeevent' />$eventtype</textarea></td> </tr> <tr> <td>Event Inforamtion*</td> <td><textarea name='eventinfo' cols='40' rows='5'>$eventinfo</textarea></td> </tr> <tr> <td>Date</td> <td><input type='text' size='10' name='date' value='$date' /></td> </tr> <tr> <td>Time</td> <td><input type='text' size='10' name='time' value='$time' /></td> </tr> <tr> <td>When tickets go on sale</td> <td><input type='text' size='10' name='sale' value='$livetickets' /></td> </tr> <tr> <td>Number of Tickets Available </td> <td><input type='text' size='5' name='numtickets' value='$numtickets' /></td> </tr> <tr> <td><h4>Ticket Prices</h4></td> </tr> <tr> <td>STUDENTS</td> <td>$<input type='text' size='3' name='studentsprice' value='$pricestudents'/></td> </tr> <tr> <td>SENIORS</td> <td>$<input type='text' size='3' name='seniorsprice' value='$priceseniors'/></td> </tr> <tr> <td>ADULTS</td> <td>$<input type='text' size='3' name='adultsprice' value='$priceadults' /></td> </tr> <tr> <td>SELECT VENUE</td> <td> <select name='venue'> <option value='$venues'>$venues</option> </select> </td> </tr> <tr> <td>SELECT CATEGORY</td> <td> <select name='category'> <option value='$category'>$category</option> <option>FOOTBALL</option> <option>BASKETBALL</option> <option>HOCKEY</option> <option>DRAMA</option> <option>MUSIC</option> <option>DANCE</option> <option>VISUAL ARTS</option> </select> </td> </tr> <tr> <td></td> <td><input type='hidden' name='saveevent' value='$newid'/></td> <td><input type='submit' name='savechanges' value='Save Changes'/></td> </tr> </table> </form>"; echo "$form"; } if ($_POST['saveevent']){ $newid = mysql_real_escape_string($_POST['saveevent']); $eventname = mysql_real_escape_string($_POST['eventname']); $eventtype = mysql_real_escape_string($_POST['typeevent']); $eventinfo = mysql_real_escape_string($_POST['eventinfo']); $date = mysql_real_escape_string($_POST['date']); $time = mysql_real_escape_string($_POST['time']); $livetickets = mysql_real_escape_string($_POST['sale']); $numtickets = mysql_real_escape_string($_POST['numtickets']); $pricestudents = mysql_real_escape_string($_POST['studentsprice']); $priceseniors = mysql_real_escape_string($_POST['seniorsprice']); $priceadults = mysql_real_escape_string($_POST['adultsprice']); $venues = mysql_real_escape_string($_POST['venue']); $categorys = mysql_real_escape_string($_POST['category']); $sqlCommand = "UPDATE events SET eventname='$eventname', typeevent='$eventtype', eventinfo='$eventinfo', date='$date', time='$time', sale='$livetickets', numtickets='$numtickets', studentsprice='$pricestudents', seniorsprice='$priceseniors', adultsprice='$priceadults', venue='$venues', category='$categorys' WHERE id='$newid'"; $out = mysql_query($sqlCommand); echo "SAVE CHANGES COMPLETED!"; } ?> hey, thanks in advance if someone can help me x y auto 1 2 a 5 3 b 4 6 c 1 2 d 7 7 e 4 6 f 5 3 b 9 4 h 4 6 f I need query to get from table auto_history(x, y, auto) only these cars, that are in the same place with other cars The result must be : a - because (it has x=1 and y=2 AND d has also x=1 and y=2), so they are in the same place d - because (it has x=1 and y=2 and a has also x=1 and y=2), so they are in the same place .... so, that's what my sql result must give a, c, d, f For some reason both admin and home return home's contents but everything else returns it's own contents... <?php if(!isset($_GET['p'])) { $result = mysql_query("SELECT * FROM body WHERE name='home'"); ?> <script type="text/javascript">alert("home");</script> <?php } else{ $result = mysql_query("SELECT * FROM body WHERE name='" . $_GET['p'] . "'"); ?> <script type="text/javascript">alert("SELECT * FROM body WHERE name='<?php echo $_GET['p']; ?>'");</script> <?php } $row = mysql_fetch_array($result); function changeStuff($str) { $str = str_replace("[link=","<a href='",$str); $str = str_replace("[/link]","</a>",$str); $str = str_replace("[img]http://","<img src='",$str); $str = str_replace("[/img]","' />",$str); $str = str_replace("[b]","<b>",$str); $str = str_replace("[/b]","</b>",$str); return $str; } ?> if(!isset($_GET['p'])) { include("home.php"); } else{ include($_GET['p'] . ".php"); } echo changeStuff($row['content']); ?> There are three rows in my body table. They are as follows 1) (name) = home (content) = this is home page 2) (name) = admin (content) = this is admin page 3) (name) = eq (content) = this is equipment page When $_GET['p'] = home It displays this is home page When $_GET['p'] = admin It displays this is home page When $_GET['p'] = eq It displays this is equipment page The javascript alerts are all displaying the correct information so i don't understand what is fudging it up... Okay, so I'm a relative newbie to PHP. I've been learning for a few months now, and while I get some bits and can fix most of my errors (with a little help from google occasionally), this one's something I can't explain. Basically, I've been building an admin panel so I can edit various content on a website, as you'd gather. It was all going pretty well, until something I did meant that my forms now do nothing. When I press update on the edit forms or add on the...well..add forms, they go back to the prefilled in content. Here is my add form: <?php include('/home/charioti/public_html/andalasia/admin/skin/header.php'); //form not yet submitted //display initial form if (!$_POST['submit']) { ?> <h1>Add Content</h1><div class="cont"> <table align="center"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <tr> <td>Title:</td><td><input type="text" name="title" id="title"></td></tr> <tr><td>Content:</td><td><textarea name="content">text here</textarea></td></tr> <tr><td></td><td><input type="submit" name="submit" value="add"></td></tr></table></form> <?php } else { include('/home/charioti/public_html/andalasia/admin/conf.php'); //set up error list array $errorList = array(); $title = $_POST['title']; $content = $_POST['content']; //validation if(trim($_POST['title']) == '') { $errorList[] = 'Invalid entry: activity name'; } if(trim($_POST['content']) == '') { $errorList[] = 'Invalid entry: answer'; } //check for errors if(sizeof($errorList) == 0) { //db connect $connection = mysql_connect($host, $user, $pass) or die('Unable to connect!'); //db select mysql_select_db($db) or die('Unable to select database!'); //generate and execute query $query = "INSERT INTO info(title, content, date) VALUES('$title', '$content', NOW())"; $result = mysql_query($query) or die("Error in query: $query . " . mysql_error()); // print result echo 'content added! <a href=/admin/index1.php>home</a>'; //close database connection mysql_close($connection); } else { //errors found // print as list echo ' The following errors were encountered:'; echo '<br>'; echo '<ul>'; for($x=0; $x<sizeof($errorList); $x++) { echo "<li>$errorList[$x]"; } echo '</ul>'; } } include('/home/charioti/public_html/andalasia/admin/skin/footer.php'); ?> My header file, incase I've messed something the <? session_start(); if(!session_is_registered(username)){ header("location:/admin/index.php"); } ?> <HTML> <HEAD> <TITLE>Andalasia ~ admin: <?php echo basename($_SERVER["PHP_SELF"]); ?></TITLE> <LINK REL="STYLESHEET" HREF="/admin/skin/style.css" TYPE="TEXT/CSS"> </HEAD> <BODY> <TABLE CLASS="CON"> <TR> <TD> <IMG SRC="/admin/skin/adpo.png" style="border-top:0px solid #A10543"> </TD> </TR> <TR> <TD> <TABLE style="font:8pt arial"> <TR> <TD CLASS="nav" style="width:200px"> <DIV CLASS="navi"> <p class="header">navigation</p> <a href="" target="__blank">Guild HQ</a> <a href="/" target="__blank">Web HQ</a> <a href="/admin/index1.php">Admin HQ</a> <a href="/admin/logout.php">logout</a></DIV> <DIV CLASS="navi"> <p class="header">points</p> <?php include('/home/charioti/public_html/andalasia/admin/points.php')?> </DIV> <DIV CLASS="navi"> <P CLASS="header">update posts</p> <?php include('/home/charioti/public_html/andalasia/admin/news/list.php')?> <a href="/admin/news/add.php">Add a post</a> </DIV> <DIV CLASS="navi"> <P CLASS="header">information posts</p> <?php include('/home/charioti/public_html/andalasia/admin/info/list.php')?> <a href="/admin/info/add.php">Add a post</a> </DIV> <DIV CLASS="navi"> <P CLASS="header">activities</p> <a href="/admin/activities/onsite.php">Onsite activities</a> <a href="/admin/activities/offsite.php">Web-hosted activities</a> <a href="/admin/activities/creative.php">Creative web activities</a> </DIV> <DIV CLASS="navi"> <P CLASS="header">Graphics</p> <h2>Guild layouts</h2> <?php include('/home/charioti/public_html/andalasia/admin/layouts/layl.php')?> <a href="/admin/layouts/add.php">Add layout</a> <h2>Userlookups</h2> <?php include('/home/charioti/public_html/andalasia/admin/lookups/list.php')?> <a href="/admin/lookups/add.php">Add lookup</a> <h2>Banners</h2> <a href="/admin/banners/banners.php">Banners</a> <h2>Fonts</h2> <?php include('/home/charioti/public_html/andalasia/admin/fonts/list.php')?> <a href="/admin/fonts/add.php">Add font</a></DIV> <DIV CLASS="navi"> <P CLASS="header">Members</p> <?php include('/home/charioti/public_html/andalasia/admin/users/list.php')?> <a href="/admin/users/add.php">Add user</a> </DIV> <DIV CLASS="navi"> <!-- BEGIN CBOX - www.cbox.ws - v001 --> <div id="cboxdiv" style="text-align: center; line-height: 0"> <div><iframe frameborder="0" width="200" height="305" src="http://www2.cbox.ws/box/?boxid=2184566&boxtag=evz64m&sec=main" marginheight="2" marginwidth="2" scrolling="auto" allowtransparency="yes" name="cboxmain" style="border:#11011A 1px solid;" id="cboxmain"></iframe></div> <div><iframe frameborder="0" width="200" height="75" src="http://www2.cbox.ws/box/?boxid=2184566&boxtag=evz64m&sec=form" marginheight="2" marginwidth="2" scrolling="no" allowtransparency="yes" name="cboxform" style="border:#11011A 1px solid;border-top:0px" id="cboxform"></iframe></div> </div> <!-- END CBOX --> </DIV> </TD> <TD CLASS="c" VALIGN="TOP" style="width:600px"> And my edit file: <? // edit.php - edit a layout ?> <!-- page header - snip --> <? // includes include("/home/charioti/public_html/andalasia/admin/skin/header.php"); include("/home/charioti/public_html/andalasia/admin/conf.php"); // form not yet submitted // display initial form with values pre-filled if (!isset($_POST['submit'])) { // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // generate and execute query $id = mysql_escape_string($_GET['id']); $query = "SELECT title, content, id FROM info WHERE id = '$id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if a result is returned if (mysql_num_rows($result) > 0) { // turn it into an object $row = mysql_fetch_object($result); // print form with values pre-filled ?> <h1>Update post - ID <? echo $id; ?></h1> <div class=cont> <table class=view align=center> <form action="<? echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="hidden" name="id" value="<? echo $id; ?>"> <tr> <td valign="top"><b>Title</b></td> <td><input size="50" maxlength="250" type="text" name="title" value="<? echo $row->title; ?>"></td> </tr> <tr> <td valign="top"><b>Content:</b></td> <td><textarea name=content><? echo $row->content; ?></textarea></td> </tr> <tr> <td colspan=2><input type="Submit" name="submit" value="Update"></td> </tr> </form> </table> </div> <? } // no result returned // print graceful error message else { echo "<h1>Error!</h1><div class=cont>That post could not be located in our database.</div>"; } } else { // form submitted // start processing it // set up error list array $errorList = array(); $count = 0; // validate text input fields $title = mysql_escape_string($_POST['title']); $content = mysql_escape_string($_POST['content']); $id = mysql_escape_string($_POST['id']); if (!$title) { $errorList[$count] = "Invalid entry: title"; $count++; } if (!$content) { $errorList[$count] = "Invalid entry: content"; $count++; } // check for errors // if none found... if (sizeof($errorList) == 0) { // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // generate and execute query $query = "UPDATE info SET title = '$title', content = '$content' WHERE id = '$id'"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // print result echo "<h1>Success!</h1><div class=cont>Update successful. <a href=/admin/index1.php>Go back to the main menu</a>.</font></div>"; // close database connection mysql_close($connection); } else { // errors occurred // print as list echo "<h1>Errors:</h1><div class=cont><font size=-1>The following errors were encountered: <br>"; echo "<ul>"; for ($x=0; $x<sizeof($errorList); $x++) { echo "<li>$errorList[$x]"; } echo "</ul></font></div>"; } } include('/home/charioti/public_html/andalasia/admin/skin/footer.php'); ?> I started off working with templates from my book and from various sources, so I've tried reseting my pages to those and reworking them, and I've deduced that it's probably something to do with my header file, I just can't work out what or whereabouts the problem is. Any help you can offer would be greatly appreciated. (: I'm trying to setup my database class so that by default it will create all of the tables and triggers required for my application to run. I've got everything working except for it adding the trigger. Here's the relevant code (slightly obfuscated for security reasons): private function check_consistency() { $database_query = <<<QUERY CREATE TABLE IF NOT EXISTS d2b_users ( id INT NOT NULL AUTO_INCREMENT, obfuscated INT NOT NULL, obfuscated VARCHAR(50) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated BOOL NOT NULL DEFAULT '1', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS d2b_statistics ( id INT NOT NULL, obfuscated BIGINT NOT NULL DEFAULT '0', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; delimiter | CREATE TRIGGER d2b_auto_statistics AFTER INSERT ON d2b_users FOR EACH ROW BEGIN INSERT INTO d2b_statistics SET id = NEW.id; END; | delimiter ; QUERY; if(!$consistency = $this->link->multi_query($database_query)) { die("Failed to create/verify the default database tables."); } return true; } I've also tried removing the delimiter and the colon after the INSERT line in the trigger and I still can't get it to add properly. What's annoying is that I'm able to take the code for the trigger from above and go into phpmyadmin and paste it into the SQL and it will add and work correctly. However, I'm trying to get my class to do that automatically so the php application automatically installs itself on other servers. What am I doing wrong? Code: [Select] $winning_numbers = explode("|", "8|18|3,8|18|3"); while($ticket = $DB->fetch_row($query)) { $correct_numbers = 0; $correct = 0; $numbers_chosen = @explode("|","8|18|3,8|18|3"); $your_numbers = array(); $array1 = array_count_values($numbers_chosen); $array2 = array_count_values($winning_numbers); foreach($array1 as $number1 => $count1) { foreach($array2 as $number2 => $count2) { if($number2 == $number1 and $count2==$count1) $correct_numbers += $count2; } } $use = 0; echo $correct_numbers; echo "<br>"; As you can see, my $correct_numbers variable will spit out "3" because it matches 3 each INDIVIDUAL numbers from $numbers_chosen in the arrays. Now my problem is. This code wasn't supposed to take in a "," to. So essentially This should display "6" because I want it to read through each , as a new Array/Group if you will. So let's say if I changed it to: $winning_numbers = explode("|", "2|18|3,8|18|2"); $numbers_chosen = @explode("|","8|18|3,8|18|3"); It would echo out "4" As it only matches 4 of them. Once I know how to do this, I will have a full functioning lottery System on my site, I am very anxious for replies, Hope you can Help. Thank you. TLDR??: I want $correct_numbers to beable to count arrays with the comma's to Why is it when a save a youtube video on my db it gives me this <iframe width="220" height="240" src="http://www.youtube.com/embed/DCZ2l1BbWyY?wmode=opaque" frameborder="0" allowfullscreen></iframe><br> i have to save it twice so it can be view why if you want to see my edit videos page i will add it here I am trying to force the "default" behavior in the Switch statement below. Why does having a "0" trigger the first Switch statement and not the last one?? switch (0){ /* switch ($resultsCode){ */ // Insert Succeeded. case 'ACCOUNT_MEMBER_ACCT_CREATED': echo '<h1>Member Account Created</h1>'; echo '<p>Congratulations!</p> <p>Your account has been created, and a confirmation e-mail sent to: "' . $email . '"</p> <p>Please click on the link in that e-mail to activate your account.</p>'; break; // Insert Failed. case 'ACCOUNT_MEMBER_ACCT_FAILED': echo '<h1>Account Creation Failed</h1>'; echo '<p>You could not be registered due to a system error.</p>'; echo '<p>Please contact the System Administrator.</p>'; break; // Default Error. default: echo '<h1>Error</h1>'; echo '<p>Oops! A system error has occurred. Please try again.</p>'; echo '<ul class="button2"> <li> <a class="testButton" href="' . BASE_URL . 'members/create_account.php">Create Account</a> </li> </ul>'; break; } Debbie Hello. I could use some advice on the best way to handle my shopping cart. My website will sell subscriptions along with more traditional items like books, t-shirts, etc. For subscriptions, I have these business rules... 1.) Only non-members can purchase a "trial subscription". 2.) Once you are a "member", then no more trials for you! 3.) You can purchase multiple subscriptions (e.g. into the future), BUT I only allow you to purchase ONE subscription at a time. (My system would allow multiple purchases at once, but I don't ant people accidentally signing up for 2 years and then i have to clean things up. Also, I want the transition from a "trial" to a "full paid" subscription to be clear.) 4.) if I ever offer multiple "trial" offers, then you only get to take advantage of one, and then after that it's on to full paid subscriptions for you - although I will run "promos".
Here is the problem... Nothing stops a non-member (or a member) from adding a "paid" and a "trial" subscription into their shopping cart. Or multiple "trial" subscriptions. Or multiple "paid" subscriptions. (Maybe someone adds a paid subscription on Friday, then the weekend comes, and on Monday they notice the trial subscription offer and add that forgetting about the paid subscription.) Or maybe someone is trying to "game" things, and adds 3 "trial" subscriptions and tries to check out?!
How should my website (gracefully) handle these scenarios?
1.) Am I aggressive up front, and prevent people from adding a 2nd subscription to their shopping cart as they shop? 2.) Or do I allow them to go wild while shopping, but then address the issue at checkout? 3.) Should my code be doing the work, or is the onus on the user to go in and clean up their shopping cart? 4.) If I address this issue at checkout, then do I need to add extra functionality to adjust their shopping cart from the checkout page on-the-fly? Or do I send them back to their actual shopping cart page and make them clean things up there? 5.) What do I do if someone has already added other items to their cart previously (e.g. T-shirts). Do I handle the "Get this offer" separately hoping to get them signed up ASAP, and then leave the T-shirts in their cart to purchase later? Or do I handle everything at once? (If they just have a "trial" subscription and a T-shirt, no worries. But if they have a "paid" subscription and then add a "trial" subscription and are looking for a quick checkout, then the scenarios/concerns above come into play...)
The stuff I was asking about last night is what got me to thinking about all of this. The flow was supposed to go... User sees "get one month for $1" on the home page, clicks the button, gets a trail-offer details paid, clicks "Get this offer", and wah-lah, they are on the checkout page! But if they already have things in their cart or maybe click the offer button 10 times, then things get messier. My concern is that converting a user to a paid member is the #1 goal, and I don't want other things to get in the way, whether that is a complicated checkout or things getting distracted purchasing other things like T-shirts! At the same time, if you want to buy multiple things, all the better as long as you follow my business rules.
So what's the best way to not be a pain to shoppers, but to maintain the rules I mention above? Edited September 9, 2020 by requinix edited at author's request |