Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. try change header('Content-Length: '.filesize($local_file)); to header('Content-Length: '.filesize(dirname.(__FILE__)."/".$local_file));
  2. This doesn't seam like a php question but a Javascript one..!
  3. Wrong section you shoud post in the Third Party PHP Scripts Yes you can, your need to explain what you mean by show then ? you could write a small script that pulls the data direct from the database!
  4. try this $valwash= preg_replace('/^1$/', 'YES', $val);
  5. first $noticia2[category] is wrong unless you have category as a constant.. if PHP doesn't find a category constant it will use "category" (a string) instead however its good pratice to use a string to start with so $noticia2['category'] reason you add the {} is because If a dollar sign ($) is encountered, the parser will greedily take as many tokens as possible to form a valid variable name. So you need to enclose the variable name in curly braces to explicitly specify the end of the name. more info See "Variable parsing" section in string types paret of the manual you could concatanate it instead! ie echo "<option value='".$noticia2['category']."'>".$noticia2['category']."</option>"; Why is it working.. Well php is smart and is assuming what you mean!!
  6. if you wanted to just get the includes then instead of paraing the phpinfo.. just get it directly use ini_get('include_path')
  7. Well yes !! $_id=$_POST['_id']; // is never used (as $_POST['_id'] never set) also shouldn't all the '_id'= be 'client_id' then remove $c_id=$HTTP_GET_VARS['_id']; and replace '$c_id' 's with $client_id $HTTP_GET_VARS was deprecated, so use $_GET instead your echo'ed $noticia2[category]'s should be replaced with {$noticia2['category']}, same with $noticia[pic] to {$noticia['pic']} theirs a quick overview
  8. The trick i use is to find where the current scipt is first So for this setup -config.php +-class +-myclass.php <?php $root = dirname(__FILE__); //I am here! ?> <?php $here = dirname(__FILE__); include $here."/../config.php"; //back one from here and include config.php echo "root = $root<br>"; echo "here= $here<br>"; ?>
  9. open it and then validate it Something like <?php $data = get_file_contents("something.php?version=12"); if (preg_match('/^<\?xml/sim', $data)) { # file starts with <?xml } ?>
  10. change <?php echo "<input type='hidden' name='uiu' value='$id'>"?> to <?php echo "<input type='text' name='uiu' value='$id'>"?> to check the $id is correct as i don't see where your setting it!
  11. No the error is Here $(function(){ try this (no idea if the JS is any good) <?php function booklineup() { ?> <script type="text/javascript"> // this function waits for the page to load before // it executes any javascript. Otherwise the javascript // will start executing before all the elements are loaded $(function(){ // This hooks the "onchange" event of countries select box. // Whenever the select box changes, this function will run. $("select#country").change(function(){ // This is jQuery's AJAX method that retrieves // a JSON string from a remote URL and parses // it into a Javascript object. (in this case, an array) $.getJSON( // this is the path to the script that will handle the AJAX request "/select.php", // These are the request parameters we are sending as part // of the AJAX request. Think of them as URL parameters, ie // ?this=that&foo=bar. $(this).val() is a quick way to get // the value of the countries select box. {country: $(this).val()}, // this function will execute when the AJAX request returns function(arenas){ // build an HTML string of select options var options = ''; for (arena in arenas) { options += '<option value="' + arena + '">' + arena + '</option>'; } // update the arena select box with the new options $("select#arena").html(options); } }) }) ) <?php print '</script>'; $type = $_GET['type']; print'<form method=POST name=eventbooker>'; print'<input type=hidden name=action value=eventbooker>'; print'<input type=hidden name=routine value=savebooking>'; print'<input type=hidden name=eventtype value=recurring>'; print '<h1 class=backstage>Show Booking Management</h1><br />'; print '<form name="booklineup" method="post" action="backstage.php" id="booklineup">'; print '<table width="100%" class="table2">'; print '<tr>'; print '<td width="150" valign="center" class="rowheading">Show Name:</td>'; print '<td class="row3"><select name="showname class="dropdown">'; print '<option value="0">- Select -</option>'; $query = "SELECT * FROM shownames WHERE `type` = '$type'"; $result = mysql_query ( $query ); while ( $row = mysql_fetch_assoc ( $result ) ) { print "<option value=\"".$row['showname']."\">".$row['showname']."</option>\r"; } print '</select></td>'; print '<td class="row3" width="180"><span class="reduced">Set up in show Name Manager</span></td>'; print '</tr>'; print '<tr>'; print '<td width="150" valign="center" class="rowheading">Label:</td>'; print '<td class="row3"><input type="text" name="label" class="fieldtext40"></td>'; print '<td class="row3" width="180"><span class="reduced">e.g. Consecutive Number, Date</span></td>'; print '</tr>'; print '<tr>'; print '<td width="150" valign="center" class="rowheading">Air Date</td>'; print '<td class=row3><input type=text name=bookingdate class=fieldtext80>'; print "<a href=\"javascript:show_calendar('document.eventbooker.bookingdate', document.eventbooker.bookingdate.value);\">"; print '<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick the date"></a></td>'; print '<td class="row3"><span class="reduced">dd-mm-yyyy</span></td>'; print '</tr>'; print '<tr>'; print '<td class="rowheading" width="150" valign="center" class="rowheading">No. of Matches:</td>'; print '<td class="row3"><input type="text" name="numberofmatches" class="fieldtext40"></td>'; print '<td class="row3"><span class="reduced">More can be added later</span></td>'; print '</tr>'; print '<tr>'; print '<td class="rowheading">Country</td>'; print '<td class="row3" colspan="2"><select name="countryid" class="dropdown" onChange="ajaxGet();"><option value=0>- Select -</option>'; $query = 'SELECT * FROM arenas GROUP BY `country` ORDER BY `country`'; $result = mysql_query ( $query ); while ( $row = mysql_fetch_assoc ( $result ) ) { print "<option value=\"".$row['country']."\">".$row['country']."</option>\r"; } print '</select></td>'; print '</tr>'; print '<tr>'; print '<td class="rowheading">Arena</td>'; print '<td class="row3" colspan="2"><div id="arenaajax"><select name="arena" class="dropdown"><option value="0">- Select Arena -</select><input type="hidden" name="location" value="0"></div></td>'; print '</tr>'; print '</table><br />'; print '<input type="hidden" name="type" value="'.$type.'">'; print '<input type="submit" value="Add Booking" class="button" name="booklineup"><br /><br />'; print '<input type="button" value="Return to Booking Manager" class="button200"><br /><br />'; print '<h2 class="backstage"><input type="button" value="Return to Main Menu" class="button200"></form></h2>'; }
  12. your need to either put the JS on the main page or parsa the JS on the Ajax responce, if you dont it won't be available. http://www.w3schools.com/jsref/jsref_eval.asp
  13. think of it as a oneline if you know the lines for example <?php if($sales > 100) { echo "Target Hit"; }else{ echo "Target missed"; } ?> 6 lines of code for what!! a hit or miss! well thats all fine and dandy.. but some times you want to type less.. So we get this <?php echo ($sales > 100)?"Target Hit":"Target missed"; ?>
  14. its a short if (aka Ternary operator) ie $admin = ($name == "madtechie")?true:false; //is the same as if($name == "madtechie") { $admin = true; }else{ $admin = false; } //which of couse in this case would be the same as $admin = ($name == "madtechie"); //but you should get the idea! EDIT: forgot the false! part
  15. list($width, $height) = getimagesize("img.jpg"); echo "$width, $height";
  16. you need to add session_start(); (i missed that in my example) session_start(); //<-add this if($_SESSION['valid'] !== true) { header("Location: login.php"); } else { print "You are logged in"; } also add the 3 lines to function login_chk()
  17. Maybe try this! <?php include ('config.php'); if (isset($_GET['action'])) { if ($_GET['action'] == "add") { if (isset($_POST['add'])) { $addthing = $_POST['thing']; $addamount = $_POST['amount']; mysql_query("INSERT INTO Things SET ThingID='', Thing='$addthing', Amount='$addamount' WHERE AccountID='" . $AccountID . "'"); $added = "<div class=box>The thing has been added.</div>"; } } else { $added = "<div class=box>That category does not exist.</div>"; } } $things = mysql_query("SELECT * FROM Things WHERE AccountID='" . $AccountID . "'"); $allthings = 1; while ($getthings = mysql_fetch_array($things)) { $ThingID = $getthings['ThingID']; $Thing = $getthings['Thing']; $Amount = $getthings['Amount']; if ($allthings == 1) { $displaythings .= "$Thing<br>Amount: <b>$Amount</b>"; $allthings = 2; } else { $displaythings .= "$Thing<br>Amount: <b>$Amount</b>"; $allthings = 1; } } ?> <html> <head> <title>Test</title> <link rel=stylesheet type=text/css href=styles.css> </head> <body> <?php echo " Add Thing<br>$added <div class=box> <form method=post action=test.php?action=add> Thing: <textarea name=thing cols=35 rows=5></textarea> <br><br> Amount: <input type=text name=amount> <br><br> <input type=submit value='Add' name=add> </form> </div> <div align=center> <div id=container> <div class=box>Things</div> <a href=test.php?action=add>Add</a><br> $displaythings </div> </div> "; ?> </body> </html>
  18. No move it up like below.. that way it add to the DB before get the data from the DB <?php include('config.php'); function add() { if (isset($_POST['add'])) { $addthing = $_POST['thing']; $addamount = $_POST['amount']; mysql_query("INSERT INTO Things SET ThingID='', Thing='$addthing', Amount='$addamount' WHERE AccountID='".$AccountID."'"); $added = "<div class=box>The thing has been added.</div>"; } echo " Add Thing<br> ".$added." <div class=box> <form method=post action=test.php?action=add> Thing: <textarea name=thing cols=35 rows=5></textarea> <br><br> Amount: <input type=text name=amount> <br><br> <input type=submit value='Add' name=add> </form> </div>"; } if (isset($_GET['action'])) { $action = ($_GET['action']); if ($action == "add") { add(); } else { echo "That category does not exist."; } } $things = mysql_query("SELECT * FROM Things WHERE AccountID='".$AccountID."'"); $allthings = 1; while ($getthings = mysql_fetch_array($things)) { $ThingID = $getthings['ThingID']; $Thing = $getthings['Thing']; $Amount = $getthings['Amount']; if ($allthings == 1) { $displaythings .= " ".$Thing."<br> Amount: <b>".$Amount."</b>"; $allthings = 2; } else { $displaythings .= " ".$Thing."<br> Amount: <b>".$Amount."</b>"; $allthings = 1; } } ?> <html> <head> <title>Test</title> <link rel=stylesheet type=text/css href=styles.css> </head> <body> <div align=center> <div id=container> <div class=box> Things </div> <a href=test.php?action=add>Add</a><br> <?php echo $displaythings; ?> </div> </div> </body> </html>
  19. Well i do try Can you click the topic solved button please
  20. untested but try this <input type="checkbox" name="test" <?php echo (isset($_POST['test'])?"checked":""; ?>> break down.. if its set then add the string "checked"
  21. move the connection up also whats with all the ;; 's
  22. try this <?php function login_chk() { session_start(); //Added $_SESSION['valid'] = false; //added if (isset($_POST['submit'])) { $db = "moveitho_sitebuilder"; mysql_connect('localhost', 'moveitho_paul', 'test') or die(mysql_error()); mysql_select_db( $db) or die(mysql_error()); $username = mysql_real_escape_string($_POST['username']); $password_encoded = mysql_real_escape_string(base64_encode($_POST['password'])); if ($result = mysql_query("SELECT username, password, verified FROM users WHERE username='$username' AND password='$password_encoded' AND verified='yes'")) { if (mysql_num_rows($result) > 0) { echo "Login successful"; $_SESSION['valid'] = true; //added header( 'Location: loggedin.php' ) ; }else { echo "Login not successful."; } }else{ echo "SQL Error: " . mysql_error(); } } } ?> <?php //at the start of loggedin.php if($_SESSION['valid'] !== true) { header("Location: login.php"); } //rest of the page ?>
  23. Read here this was written awhile back but may still help
  24. Personally, 1 to 5 with half stars is 1 to 10.. so rate goes upto 10! to do the halfstar image.. just need to know what star to put on screen <?php $left = "leftsidestar.png" $right = "rightsidestar.png" //$row = array from DB containing rate $row['rate'] = 6; //ie (from 1 to 10) (or 5 x 2) $full = true; for($n=0;$n<$row['rate'];$n++) { $img = ($full)?$left:$right; echo "<img src='$img'>"; $full = !$full; } ?> @scarhand While your solution is sound, it will require more images and thus more downloads and more updating if the design was changed.. these are all pretty minor so not a big deal, however i would use 1 to 10 like star1.gif, star2.gif, star3.gif, etc because the user only see's the stars not the image names (and i think its easier not having 0.5.jpg) also the DB as you can use a tinyint. instead of a float Another (fancy) option is to create an image which is 5 stars long (max rating) Put it inside a div and set the class overflow to hidden now you could just workout the length.. so 5 star image is 100px thus each star is 20px or 10px per half star now just set the div length to rate * 10 ie 3*10 = 30 so div length=30px which makes 1 and a half stars visible! the good thing about this is you can have the stars different colour or whatever! and the code doesn't change. But thats going on a bit.. 101 ways to do the same thing
×
×
  • 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.