Jump to content

Spikerok

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by Spikerok

  1. If problem with $username then use next code $username = htmlspecialchars($_POST['username']); mysql_connect("$server", "$db_user", "$db_pass") or die(mysql_error()); mysql_select_db("singlese_messages") or die(mysql_error()); mysql_query("CREATE TABLE " . $username . " ( `id` INT( 50 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR( 75 ) NOT NULL , `subject` VARCHAR( 150 ) NOT NULL , `message` TEXT NOT NULL , `gift` VARCHAR( 50 ) NOT NULL, `new` VARCHAR( 5 ) NOT NULL , `date_created` VARCHAR( 50 ) NOT NULL , `date_modified` VARCHAR( 50 ) NOT NULL )") or die(mysql_error()); mysql_close(); btw why do you need to create table for every new user?
  2. talking to you is same as talking to a brick wall.
  3. clearly to be employed by google you need to have correct education. google and other big companies do employ fresh programmers
  4. company - team work. if your team is bad, you will suck and that's happens to most people. Freelancers - most of them ( about 99% ) can't !@#$ing "correctly" program or make some thing "real" of their own. If some one saying to have seriously worked for over 1-2 years ( maybe more ) then they should be able to produce some thing like google maps in no time.
  5. talking about different coding styles.. oh yh, there are several coding styles most common are Hindu and Chinese styles ^^
  6. <?php class myclass { public function __construct() { if(isset($_POST['submit'])) { myclass::check($_POST['link']); } myclass::form(); } private function check($link) { $link = explode(".", $link); switch($link[1]) { case 'jpg': print 'good'; break; case 'gif': print 'good'; break; case 'png': print 'good'; break; default: print 'incorrect format'; } } private function form() { print "<form action=\"\" method=\"post\">"; print "Image: <input name=\"link\" type=\"text\">"; print "<input type=\"submit\" name=\"submit\" value=\"submit\">"; print "</form>"; } } new myclass(); ?>
  7. You can try using ob_start() and in some mail boxes html is disabled by default. So in some thing like SquirrelMail html might be disabled when in hotmail it will be enabled.
  8. if you want to just go through all scripts, you can include all files in order you want and run cron job on that script
  9. If timing is important: we can try storing task number and time. So, we done task 1, set task = 2 and time when task 1 was done, so set time = 13:10. Then when time is 13:15, check if 13:15 - 13:15 = 00:05, then if difference between them is 00:05 or more do next task which is 2, and increase task by 1, and set new time once it gets to task 4, change task to 1. If time not important: if you have cron job every five minutes we just store task number. here is example of procedure: task = 1.. do task 1 task = task + 1 then next time cron runs file, task = 2.. do task 2 task = task + 1 for storage we can use database or file.
  10. check my other code above, it should work. here is example on what your script should do <?php class myclass { public function __construct() { if(isset($_POST['submit'])) { myclass::result($_POST['editor']); } myclass::show(); } private function show() { print "Which text editor do you use?<br /> \n"; print "<form method=\"post\" action=\"\"> \n"; print "<input type=\"checkbox\" name=\"editor[]\" value=\"Notepad\" /> \n"; print "Notepad<br /> \n"; print "<input type=\"checkbox\" name=\"editor[]\" value=\"Scite\" /> \n"; print "Scite<br /> \n"; print "<input type=\"checkbox\" name=\"editor[]\" value=\"Crimson Editor\" /> \n"; print "Crimson Editor<br /> \n"; print "<input type=\"checkbox\" name=\"editor[]\" value=\"Dreamweaver\" /> \n"; print "Dreamweaver<br /> \n"; print "<input type=\"checkbox\" name=\"editor[]\" value=\"vim\" /> \n"; print " vim<br /> \n"; print "<input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> \n"; print "</form>\n"; } private function result($editor) { $max = count($editor); for($i = 0; $i < $max; $i++) { print $editor[$i]; print "<br>\n"; } } } new myclass(); ?> I get $_POST['editor'] and then counting them and then using loop output all variables that array editor contains
  11. well you seem to use post method in script, try print_r($_POST['delete']);
  12. because array is created before starting class and class contains variable which is used in array, array thinks that the sql string with variable ( which are undefined ) in it is just a string. Well every thing that contained in array is a string, so i have changed array slightly. $array = array('rowcount' => array( 0 => 'SELECT domain_id FROM tbl_domain WHERE domain_id =|txtDomain|Domain already exists'); new process($this->registry, $array); and in function. $felder = explode('|', $this->array['rowcount'][$i]); $sql = $felder[0]; $sql .= "'" . $this->feld[$felder[1]] . "'";
  13. This is different way of writing it <?php // Check if we user submited form, if yes run check function with $_POST['fcheat'] if(isset($_POST['submitxyz'])) { check($_POST['fcheat']); } // Run funciton form(); form(); // Functions // This function called at line 5, $code = $_POST['fcheat'] function check($code) { if($code != 'rockon87') { print 'Invalid code'; return; } else { $cheat = 'Godmode'; // feeding display function with variable $cheat display($cheat); } } // display value $cheat function display($cheat) { print "You have been granted " . $cheat; } function form() { print "<form action=\"\" method=\"post\">"; print "Cheat: <input name=\"fcheat\" type=\"text\">"; print "<input type=\"submit\" name=\"submitxyz\" value=\"submit\">"; print "</form>"; }
  14. Should be some thing like that <?php class myclass { private $user_id; public function __construct() { $this->user_id = $_SESSION['user_id']; if(isset($_POST['button'])) { myclass::deleteEntry(); } else { myclass::viewform(); } } private function viewform() { myclass::includes(); print "<form enctype=\"multipart/form-data\" method=\"post\" action=\"\">" $query = "SELECT * FROM MESSAGES WHERE MessageTo='". $this->user_id . "' "; $result = mysqli_query($dbc,$query) or die ("Error in query: $query. ".mysql_error()); if (mysqli_num_rows($result)>0) { print "<table border=1>\n"; print "<tr>\n"; print "<td>MessageNo</td>\n"; print "<td>MessageFrom</td>\n"; print "<td>MessageTo</td>\n"; print "<td>Subject</td>\n"; print "<td>Message</td>\n"; print "<td>Reply</td>\n"; print "<td>Delete</td>\n"; print "</tr>\n"; while ($row = @ mysqli_fetch_array($result)) { print "<tr>\n"; print "<td> . $row[\'MessageNo\'] . </td> \n"; print "<td> . $row[\'MessageFrom\'] . </td>\n"; print "<td> . $row[\'MessageTo\'] . </td>\n"; print "<td> . $row[\'Subject\'] . </td>\n"; print "<td> . $row[\'Message\'] . </td> \n"; print "<td><input type=\"checkbox\" name=\"reply[]\" value=\" . $row['MessageNo'] . \" /></td>\n"; print "<td><input type=\"checkbox\" name=\"delete[]\" value=\" . $row['MessageNo']. \" />\n"; print "</tr> \n"; } print "</table>"; print "<label>\n"; print "<p>\n"; print "<input type=\"submit\" name=\"button\" id=\"button\" value=\"Submit\" />\n"; print "</label></p>\n"; print "</form>\n"; } else { print "No rows found!"; } } private function deleteEntry() { myclass::includes(); $delete = $_POST['delete']; $max = count($delete); for($i = 0; $i < $max; $i++) { $query = "DELETE FROM MESSAGES WHERE MessageNo = '" . $delete[$i] . "'"; $result = mysqli_query($dbc,$query); } if(mysqli_affected_rows($dbc) > 0) { header("Location: {$_SERVER['HTTP_REFERER']}"); } else { echo "Error in query: $query" . mysqli_error(); mysqli_close($dbc); exit; } } private function includes() { require_once('startsession.php'); require_once('connectvars.php'); } } new myclass(); ?>
  15. I have first page which calls object and contains array. $array = array('rowcount' => array( 0 => 'SELECT domain_id FROM tbl_domain WHERE domain_id = \'\" . $this->feld[\'txtDomain\'] . \"\'|Domain already exists', 1 => 'SELECT user_id FROM buga WHERE user_id = \'\" . $this->feld[\'txtID\'] . \"\'|User does not exist')); new process($this->registry, $array); then in class process i have function rowcount private function rowcount() { $max = count($this->array['rowcount']); for($i = 0; $i < $max; $i++) { $felder = explode('|', $this->array['rowcount'][$i]); $sql = stripslashes($felder[0]); $result = $this->registry['conn']->query($sql); $numrows = $result->rowCount(); if($numrows < 1){ $_SESSION['errorMessage']= $felder[1]; } } } array '$this->feld' is declared in class with values.
  16. <?php class myclass { private $cheat; public function __construct() { if(isset($_POST['submitxyz'])) { myclass::check($_POST['fcheat']); } myclass::form(); } private function check($code) { if($code != 'rockon87') { print 'Invalid code'; return; } else { $this->cheat = 'Godmode'; myclass::display(); } } private function display() { print "You have been granted " . $this->cheat; } private function form() { print "<form action=\"\" method=\"post\">"; print "Cheat: <input name=\"fcheat\" type=\"text\">"; print "<input type=\"submit\" name=\"submitxyz\" value=\"submit\">"; print "</form>"; } } $myclass = new myclass(); ?>
  17. I have array which contains next entry 'rowcount' => array( 0 => 'SELECT domain_id FROM tbl_domain WHERE domain_id = \'\" . $this->feld[\'txtDomain\'] . \"\'|Domain already exists' Given array is processed using next code. I'm calling this process after declaring array and filling it with values. $felder = explode('|', $this->array['rowcount'][0]); $sql = stripslashes($felder[0]); $result = $this->registry['conn']->query($sql); $numrows = $result->rowCount(); $this->feld[txtDomain] = 123 $sql = stripslashes($felder[0]); will show SELECT domain_id FROM `tbl_domain` WHERE `domain_id` = '" . $this->feld['txtDomain'] . "' when it should of changed '" . $this->feld['txtDomain'] . "' to 123 What could be done?
  18. hi, you might want to read this: http://www.tanzilo.com/2008/10/13/php-mysql-unicode-solution-to-chinese-russian-or-any-language/ you will see that you have to make those char encoding queries before inserting things in the database mysql_query("SET character_set_client=utf8", $dbLink); mysql_query("SET character_set_connection=utf8", $dbLink); you can change utf8 on any other char set you want hope this helps
  19. input, output works ok, but i have error with processing votes, when user have voted he will move to action.php where are script will check his ip, and will insert his vote in needed field. I believe checking function to check ip is working ok, but there is problem with inserting user's vote into database or can their be some thing else? my action.php script, where are all the main things are happening. And here im getting that error. <?php require_once '../library/config.php'; session_register("operation"); Header("Location: results.php"); $quer = mysql_query("SELECT * FROM current_poll WHERE Status='on' OR Status='paused'"); $status = mysql_fetch_array($quer); $poll_type=$status['type']; $answers=explode("|", $status['Answers']); $n=count($answers); if ($status['Status']=="paused") { $operation="paused"; exit; } $myquery = mysql_query("SELECT ip FROM current_poll_results WHERE ip='$REMOTE_ADDR' AND poll_id='$vote_id'"); $yes = mysql_fetch_array($myquery); if ($yes['ip']) { $operation="already_voted"; exit; } if ($_COOKIE["id"]==$vote_id) { $operation="already_voted"; exit; } else{ if ($poll_type!="check") { mysql_query("INSERT INTO current_poll_results VALUES ('$answer', '$REMOTE_ADDR')"); } elseif ($poll_type=="check") { for ($i=0; $i<$n; $i++){ $u = "ans_".$i; if (isset ($$u)) { if ($$u=="true") { mysql_query("INSERT INTO current_poll_results VALUES ('$i', '$REMOTE_ADDR')");} } } } $operation="ok"; setcookie ("id", $vote_id, time()+31536000); } ?>
×
×
  • 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.