Jump to content

Zane

Administrators
  • Posts

    4,362
  • Joined

  • Last visited

  • Days Won

    11

Everything posted by Zane

  1. all you have to do is write a script that disables voting... then go to cpanel's crontab entry and tell it to run everyday at 00:00. You don't have to put the time in your PHP code. It should look something like this 0 0 * * * disablevoting.php but you don't want disablevoting.php to be available to the public, you might want to put it out of the web root.
  2. If you have access to a control panel, then you can set up a crontab. It's very straightforward... especially if you read that tutorial I provided.
  3. $_SESSION['id'] = $row['id']; but in order for it to work properly you'll have to put that snippet BEFORE the query, yet inside the while loop (or else $row won't exist). In other words, you should have $_SESSION['id'] set before you even run a query with it. // Set the users session ID include("Connections/connect_to_mysql.php"); This is where the session should be set... you probably have something wrong in connect_to_mysql.php
  4. Ok, so what you're saying is. This script <br /> function dump(arr,level) {<br /> var dumped_text = "";<br /> if(!level) level = 0;<br /> <br /> //The padding given at the beginning of the line.<br /> var level_padding = "";<br /> for(var j=0;j<level+1;j++) level_padding += " ";<br /> <br /> if(typeof(arr) == &#039;object&#039;) { //Array/Hashes/Objects <br /> for(var item in arr) {<br /> var value = arr[item];<br /> <br /> if(typeof(value) == &#039;object&#039;) { //If it is an array,<br /> dumped_text += level_padding + "&#039;" + item + "&#039; ...\n";<br /> dumped_text += dump(value,level+1);<br /> } else {<br /> dumped_text += level_padding + "&#039;" + item + "&#039; => \"" + value + "\"\n";<br /> }<br /> }<br /> } else { //Stings/Chars/Numbers etc.<br /> dumped_text = "===>"+arr+"<===("+typeof(arr)+")";<br /> }<br /> return dumped_text;<br /> }<br /> $(document).ready(function() {<br /> $(&#039;div.message-error&#039;).hide();<br /> $(&#039;div.message-success&#039;).hide();<br /> $(&#039;li&#039;).remove(&#039;.titleName&#039;); <br /> $(&#039;li&#039;).remove(&#039;.stipulationName&#039;);<br /> $(&#039;li&#039;).remove(&#039;.competitorName&#039;);<br /> <br /> for ( var matchNum = 0; matchNum < <?php echo $numMatches ?>; matchNum++ ) {<br /> var titlesCount = $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;).size();<br /> if(titlesCount == 0){$(&#039;ul#titlesDefended&#039;+ matchNum).append(&#039;<li titleID="0" class="notitle">There are no titles being defended.&#039;);}<br /> var stipulationsCount = $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;).size();<br /> if(stipulationsCount == 0){$(&#039;ul#stipulationsAdded&#039;+ matchNum).append(&#039;<li stipulationID="0" class="nostipulation">There are no stipulations for this match.&#039;);}<br /> var competitorsCount = $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;).size();<br /> if(competitorsCount == 0){$(&#039;ul#competitors&#039;+ matchNum).append(&#039;<li competitorID="0" class="nocompetitor">There are no competitors for this match.&#039;);}<br /> }<br /> <br /> $("#bookerForm").validate({ <br /> rules: {<br /> introduction: {<br /> required: true<br /> },<br /> matchtypeID: {<br /> required: true<br /> },<br /> liCompetitors: {<br /> required: true<br /> },<br /> matchwriterID: {<br /> required: true<br /> },<br /> matchTitle: {<br /> required: true<br /> },<br /> preview: {<br /> required: true<br /> },<br /> segment: {<br /> required: true<br /> }<br /> },<br /> messages: {<br /> introduction: "Please enter the event introduction!",<br /> matchtypeID: "Please choose the type of match!",<br /> liCompetitors: "Please choose atleast 2 competitors!",<br /> matchwriterID: "Please choose a match writer!",<br /> matchTitle: "Please enter a match title!",<br /> preview: "Please enter a preview!",<br /> segment: "Please choose a segment writer!"<br /> },<br /> submitHandler: function(form) {<br /> var eventName = $("#event").val();<br /> var eventID = $("#eventID").val();<br /> var introduction = $("#introduction").val();<br /> var subArray = new Array;<br /> var matchArray = new Array;<br /> var matchArrayIndex = 0;<br /> var segmentArray = new Array;<br /> var segmentArrayIndex = 0;<br /> var matchNumX = new Array;<br /> var matchTypeIDX = new Array;<br /> var titlesIDListX = new Array;<br /> var stipulationsIDListX = new Array;<br /> var competitorsIDListX = new Array;<br /> var matchWriterIDX = new Array;<br /> var matchTitleX = new Array;<br /> var previewX = new Array; <br /> var segmentNumX = new Array;<br /> var segmentWriterIDX = new Array;<br /> var segmentOrderX = new Array;<br /> var typeX = new Array;<br /> var typeX2 = new Array;<br /> var i = 0;<br /> <br /> for(i=0;i<<?php echo $numMatches ?>; i++) {<br /> <br /> var matchNum = i + 1;<br /> var matchTypeID = $(&#039;select#matchTypeDrop&#039;+ matchNum).val(); <br /> var liTitles = $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;);<br /> var titlesIDList = "";<br /> var j = 0;<br /> $(&#039;ul#titlesDefended&#039;+ matchNum +&#039; li&#039;).each(function(){<br /> var liTitle = $( liTitles[ j ] );<br /> <br /> // only start appending commas in after the first characterID<br /> if( j > 0 ) {<br /> titlesIDList += ","; <br /> }<br /> <br /> // append the current li element&#039;s characterID to the list<br /> titlesIDList += liTitle.attr( &#039;titleID&#039; );<br /> j++;<br /> });<br /> var j = 0;<br /> var liStipulations = $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;);<br /> //alert(liStipulations);<br /> var stipulationsIDList = "";<br /> $(&#039;ul#stipulationsAdded&#039;+ matchNum +&#039; li&#039;).each(function(){<br /> var liStipulation = $( liStipulations[ j ] );<br /> //alert(liStipulation);<br /> <br /> // only start appending commas in after the first characterID<br /> if( j > 0 ) {<br /> stipulationsIDList += ","; <br /> }<br /> <br /> // append the current li element&#039;s characterID to the list<br /> stipulationsIDList += liStipulation.attr( &#039;stipulationID&#039; );<br /> //alert(liStipulation.attr( &#039;stipulationID&#039; ));<br /> j++;<br /> });<br /> //alert(stipulationsIDList);<br /> var j = 0;<br /> var liCompetitors = $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;);<br /> var competitorsIDList = "";<br /> $(&#039;ul#competitors&#039;+ matchNum +&#039; li&#039;).each(function(){<br /> var liCompetitor = $( liCompetitors[ j ] );<br /> <br /> // only start appending commas in after the first characterID<br /> if( j > 0 ) {<br /> competitorsIDList += ","; <br /> }<br /> <br /> // append the current li element&#039;s characterID to the list<br /> competitorsIDList += liCompetitor.attr( &#039;competitorID&#039; );<br /> j++;<br /> });<br /> var matchWriterID = $(&#039;select#matchWriter&#039; + matchNum + &#039;&#039;).val();<br /> var matchTitle = $(&#039;input#matchTitle&#039;+ matchNum +&#039;&#039;).val();<br /> var preview = $(&#039;textarea#preview&#039;+ matchNum +&#039;&#039;).val();<br /> var type = $("input#type").val();<br /> typeX.push(type);<br /> matchNumX.push(matchNum);<br /> matchTypeIDX.push(matchTypeID);<br /> titlesIDListX.push(titlesIDList);<br /> stipulationsIDListX.push(stipulationsIDList);<br /> competitorsIDListX.push(competitorsIDList);<br /> matchWriterIDX.push(matchWriterID);<br /> matchTitleX.push(matchTitle);<br /> previewX.push(preview);<br /> matchArray[matchArrayIndex] = new Object();<br /> matchArray[matchArrayIndex][&#039;type&#039;] = typeX; <br /> matchArray[matchArrayIndex][&#039;matchNum&#039;] = matchNumX;<br /> matchArray[matchArrayIndex][&#039;matchtypeID&#039;] = matchTypeIDX;<br /> matchArray[matchArrayIndex][&#039;titlesIDList&#039;] = titlesIDListX;<br /> matchArray[matchArrayIndex][&#039;stipulationsIDList&#039;] = stipulationsIDListX;<br /> matchArray[matchArrayIndex][&#039;competitorsIDList&#039;] = competitorsIDListX;<br /> matchArray[matchArrayIndex][&#039;matchWriterID&#039;] = matchWriterIDX;<br /> matchArray[matchArrayIndex][&#039;matchTitle&#039;] = matchTitleX;<br /> matchArray[matchArrayIndex][&#039;preview&#039;] = previewX;<br /> }<br /> for(i=0;i<<?php echo $numSegments ?>; i++) {<br /> var segmentNum = i + 1;<br /> var segmentWriterID = $(&#039;select#segmentWriter&#039; + segmentNum + &#039;&#039;).val();<br /> var segmentOrder = $(&#039;select#segmentOrder&#039; + segmentNum + &#039;&#039;).val();<br /> var type = $("input#type2").val();<br /> typeX2.push(type);<br /> segmentNumX.push(segmentNum);<br /> segmentWriterIDX.push(segmentWriterID);<br /> segmentOrderX.push(segmentOrder);<br /> segmentArray[segmentArrayIndex] = new Object(); <br /> segmentArray[segmentArrayIndex][&#039;type&#039;] = typeX2; <br /> segmentArray[segmentArrayIndex][&#039;segmentNumber&#039;] = segmentNumX;<br /> segmentArray[segmentArrayIndex][&#039;segmentWriterID&#039;] = segmentWriterIDX;<br /> segmentArray[segmentArrayIndex][&#039;segmentOrder&#039;] = segmentOrderX;<br /> }<br /> alert(dump(matchArray));<br /> alert(dump(segmentArray));<br /> var dataString = &#039;masterArray=&#039; + masterArray;<br /> dataString += &#039;&eventID=&#039; + eventID + &#039;&submitBooking=True&#039;; <br /> $.ajax({<br /> type: "POST",<br /> url: "processes/bookings.php",<br /> data: dataString, <br /> success: function() {<br /> $(&#039;div.message-error&#039;).hide();<br /> $("div.message-success").html("<h6>Operation successful<p>" + eventName + " saved successfully.");<br /> $("div.message-success").show().delay(10000).hide("slow");<br /> return true;<br /> }<br /> });<br /> return false; <br /> } <br /> });<br /> });<br /> Card Lineup for </pre> <form action="#" id="bookerForm"> Introduction Introduction: Required Match # Match Type: - Select - mysqli_data_seek( $matchtypesResult, 0 ); while ( $row = mysqli_fetch_array ( $matchtypesResult, MYSQL_ASSOC ) ) { print "".$row['matchType']."\r"; } ?> Required Title On The Line: - Select - mysqli_data_seek( $titlesResult, 0 ); while ( $row = mysqli_fetch_array ( $titlesResult, MYSQL_ASSOC ) ) { print "".$row['titleName']."\r"; } ?> Stipulation: - Select - mysqli_data_seek( $stipulationsResult, 0 ); while ( $row = mysqli_fetch_array ( $stipulationsResult, MYSQL_ASSOC ) ) { print "".$row['stipulation']."\r"; } ?> Competitors: - Select - mysqli_data_seek( $charactersResult, 0 ); while ( $row = mysqli_fetch_array ( $charactersResult, MYSQL_ASSOC ) ) { print "".$row['characterName']."\r"; } ?> Required Match Writer: - Select - mysqli_data_seek( $matchwriterResult, 0 ); while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { print "".$row['name']."\r"; } ?> Required Match Title Required Preview: Required } ?> 0) { ?> Segment Segment Writer: - Select - mysqli_data_seek( $matchwriterResult, 0 ); while ( $row = mysqli_fetch_array ( $matchwriterResult, MYSQL_ASSOC ) ) { print "".$row['name']."\r"; } ?> Required Segment After: - Select - Introduction for( $j = 1; $j print "Match $j\r"; } ?> Required } ?> </form> <br><br><br><br><div class="message message-error"> Required field missing Please fill in all required fields. </div> <br><div class="message message-success"> Operation succesful Booking was added to the database. </div> <b outputs this '0' ... 'type' ... '0' => "Match" '1' => "Match" 'matchNum' ... '0' => "1" '1' => "2" 'matchtypeID' ... '0' => "1" '1' => "1" 'titlesIDList' ... '0' => "3,2" '1' => "3,2" 'stipulationsIDList' ... '0' => "2,1" '1' => "2,1" 'competitorsIDList' ... '0' => "10,3" '1' => "11,1" 'matchWriterID' ... '0' => "1" '1' => "1" 'matchTitle' ... '0' => "match title1" '1' => "match title2" 'preview' ... '0' => "preview1" '1' => "preview2" '0' ... 'type' ... '0' => "Segment" '1' => "Segment" 'segmentNumber' ... '0' => "1" '1' => "2" 'segmentWriterID' ... '0' => "1" '1' => "1" 'segmentOrder' ... '0' => "introduction" '1' => "1" but you want it to output this? BEFORE ORDERING Introduction Type- Introduction segmentTitle- Introduction preview- This is just a test preview for the next event. Hope you all come out to see us wrestle! Match #1 type- Match matchNum- 1 matchTitle- Match Title 1 competitorsIDList- 1,2 matchwriterID- 1 preview- This is the preview for match #1. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 0 Match #2 type- Match matchNum- 1 matchTitle- Match Title 2 competitorsIDList-1,2,3 matchwriterID- 1 preview- This is the preview for match #2. stipulationsIDList- 2,3 matchTypeID- 3 titlesIDList- 1 Match #3 type- Match matchNum- 1 matchTitle- Match Title 3 competitorsIDList- 1,2 matchwriterID- 3 preview- This is the preview for match #3. stipulationsIDList- 4,6 matchTypeID- 1 titlesIDList- 2 Match #4 type- Match matchNum- 1 matchTitle- Match Title 4 competitorsIDList- 1,2 matchwriterID- 1 preview- This is the preview for match #4. stipulationsIDList- 4,6 matchTypeID- 1 titlesIDList- 0 Match #5 type- Match matchNum- 1 matchTitle- Match Title 5 competitorsIDList- 1,2 matchwriterID- 2 preview- This is the preview for match #5. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 3 Match #6 type- Match matchNum- 1 matchTitle- Match Title 6 competitorsIDList- 1,2 matchwriterID- 2 preview- This is the preview for match #6. stipulationsIDList- 3,5 matchTypeID- 1 titlesIDList-2 Match #7 type- Match matchNum- 1 matchTitle- Match Title 7 competitorsIDList- 1,2 matchwriterID- 3 preview- This is the preview for match #7. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 1 Segment #1 type- Segment segmentNum- 1 segmentWriterID- 1 segmentOrder (matchNum or Introduction)- introduction Segment #2 type- Segment segmentNum- 2 segmentWriterID- 2 segmentOrder (matchNum or Introduction)- 1 Segment #3 type- Segment segmentNum- 3 segmentWriterID- 2 segmentOrder (matchNum or Introduction)- 1 Segment #4 type- Segment segmentNum- 4 segmentWriterID- 1 segmentOrder (matchNum or Introduction)- 3 Segment #5 type- Segment segmentNum- 5 segmentWriterID- 1 segmentOrder (matchNum or Introduction)-6 AFTER ORDERING Introduction Type- Introduction segmentTitle- Introduction preview- This is just a test preview for the next event. Hope you all come out to see us wrestle! Segment #1 type- Segment segmentNum- 1 segmentWriterID- 1 segmentOrder (matchNum or Introduction)- introduction Match #1 type- Match matchNum- 1 matchTitle- Match Title 1 competitorsIDList- 1,2 matchwriterID- 1 preview- This is the preview for match #1. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 0 Segment #2 type- Segment segmentNum- 2 segmentWriterID- 2 segmentOrder (matchNum or Introduction)- 1 Segment #3 type- Segment segmentNum- 3 segmentWriterID- 2 segmentOrder (matchNum or Introduction)- 1 Match #2 type- Match matchNum- 1 matchTitle- Match Title 2 competitorsIDList-1,2,3 matchwriterID- 1 preview- This is the preview for match #2. stipulationsIDList- 2,3 matchTypeID- 3 titlesIDList- 1 Match #3 type- Match matchNum- 1 matchTitle- Match Title 3 competitorsIDList- 1,2 matchwriterID- 3 preview- This is the preview for match #3. stipulationsIDList- 4,6 matchTypeID- 1 titlesIDList- 2 Segment #4 type- Segment segmentNum- 4 segmentWriterID- 1 segmentOrder (matchNum or Introduction)- 3 Match #4 type- Match matchNum- 1 matchTitle- Match Title 4 competitorsIDList- 1,2 matchwriterID- 1 preview- This is the preview for match #4. stipulationsIDList- 4,6 matchTypeID- 1 titlesIDList- 0 Match #5 type- Match matchNum- 1 matchTitle- Match Title 5 competitorsIDList- 1,2 matchwriterID- 2 preview- This is the preview for match #5. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 3 Match #6 type- Match matchNum- 1 matchTitle- Match Title 6 competitorsIDList- 1,2 matchwriterID- 2 preview- This is the preview for match #6. stipulationsIDList- 3,5 matchTypeID- 1 titlesIDList-2 Segment #5 type- Segment segmentNum- 5 segmentWriterID- 1 segmentOrder (matchNum or Introduction)-6 Match #7 type- Match matchNum- 1 matchTitle- Match Title 7 competitorsIDList- 1,2 matchwriterID- 3 preview- This is the preview for match #7. stipulationsIDList- 0 matchTypeID- 1 titlesIDList- 1
  5. SELECT id, firstname FROM `Members` WHERE id=idLIMIT 1 There is no space between id and LIMIT. Also, the fact that you have id=id in your query answers this puzzle. Essentially, that query says Get all users whose id is equal to their id... which is all of them. So now I'm back to my second post on this thread.. or third I can't remember. You never set $_SESSION['id'] to contain an actual id. Once you do that, you should have a working query... you won't even need that LIMIT duct tape.
  6. According to your code, there is no reason for it to show all users. Even if the id in the SESSION was incorrect, you should still get either an error or the wrong result. There is a fix to this, but it will not answer this mind boggling question. On your query... add LIMIT 1 to the end. //Formulate Query //This is the best way to perform an SQL query $query = "SELECT id, firstname FROM `Members` WHERE id={$_SESSION['id']} LIMIT 1"; Then you're sure to only get one result, but like I said... this is, how you say... afro-engineered.
  7. You should never validate with Javascript. Especially if this is an end-user application where the user can literally turn Javascript off. I suggest you redo your validation in PHP.
  8. post your revised query, echo the $sql variable if there is one.... there should be if there's not. Neither of those examples you showed should make the script echo every user in the table. The only problem with the last one is that you're declaring $numrows to 1 instead of comparing it. Otherwise, they should all work fine. It's the query that's getting all the users, it's the only possible reason. Either post the revised code or post the echoed query.
  9. If it's showing all the users, then it has to be your query. Furthermore, since you only expect ONE result... why use a loop? The loop is creating all the names, but it will only loop through what your query retrieves so you must have some query issues. Post your revised code and let's see if we can't spot it this time.
  10. No, that's not it either. Try clicking Browse.
  11. Can you post the actual data in the database rather than an EXPLAIN
  12. Dear tab4trouble, Could you please not start duplicate threads.
  13. Well, if it's displaying every user, then you obviously have duplicate ids somewhere in your table. I can't think of any other reason why it would show every user when you are restricting it to an id that you claim is both auto increment and a primary key. Talking to your host won't help anything, it might just make it worse. Something is defunct in your code and I can't seem to spot it. All I can really say is to go check your database and see if there are duplicates.
  14. It should, perhaps you don't have auto-increment checked in your id field... in which case you probably don't have a primary key set either.
  15. if (isset($_SESSION['username'])) { You check for this variable but I don't see where you actually declared it.
  16. I like it. I don't exactly have any great advice for you, but your design is the perfect balance between minimalistic and easy on the eyes. EDIT: well, one thing I would add is a favicon.
  17. An the error message was..
  18. You have the solution: crontabs Now google it. Here's a resource I find myself. http://adminschoice.com/crontab-quick-reference
  19. You need two tables. One for your products of course. A second for all your keywords In the keywords table you'd have - an id - the keyword name - the product id To find all the keywords for a specific product you will need to JOIN the keywords table to the products. SELECT * FROM products p JOIN keywords k ON k.product = p.id To delete a keyword, simply search for it by name and product id DELETE FROM keywords WHERE keyword = "someword" AND product='5'
  20. //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); You are calling mysql_query twice. First to execute the query and then again to query the same query you created; which won't work. Change it to this. //Formulate Query //This is the best way to perform an SQL query $sql= "SELECT * FROM `Members` WHERE username={$_SESSION['username']}"; $query = mysql_query($sql); $numrows = mysql_num_rows($query);
  21. The object created in File2 is not the same object in File3
  22. You need to execute the query.... $result = mysql_query($sql); /// This is the execution if (mysql_num_rows($result) > 0){ while($row = mysql_fetch_object($result)){ $string .= "".$row->name." - "; $string .= $row->phone.""; $string .= " \n"; }
  23. It depends on your search script/query.. but typically No it wouldn't turn them both up. The query would need to use a LIKE clause with wildcards on either end SELECT * FROM table WHERE field LIKE '%Test%'
  24. So long as the query has the information you want, then yea.. use one query per table. Though if you start limiting your queries with WHERE and LIMIT clauses you're least likely to have that information. I'm not saying don't use WHERE and LIMIT, I'm saying.. don't waste valuable data and then recreate it.
  25. Select everything you can from one table. If you repeat a select for one value of the same table then you're not doing it right. In other words... your code is redundant. You could have easily checked the email value after you selected * from users in the beginning.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.