Jump to content

attock

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

attock's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. how does uploadify.php know about - dbconnect() function - $dbhost, $dbusername, $dbpassword & $dbname variables.. You should include a library file which contains the above listed function and variables, if not already included. Code: [select] <?php if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; if (move_uploaded_file($tempFile,$targetFile)) { dbconnect($dbhost, $dbusername, $dbpassword, $dbname);
  2. if you dont like preg_match then you might wana try sumthing like $arr = split('id="', $html); echo substr($arr[1],0,-1); using regular expressions would be the correct way of doing it.
  3. lolz sowwie.. Issue would be: It aint working Question would be: how come? any suggestions?
  4. I am trying to have a subdomain.ofasubdomain.domain.com and my conf looks like: <VirtualHost IP:80> ServerName amaq.xyz.domain.com ServerAdmin serveadmin@email.com DocumentRoot "/var/syscp/webs/amaq/" SuexecUserGroup "amaq" "amaq" <Directory "/var/syscp/webs/amaq/"> AddHandler fcgid-script .php .php3 .php4 .php5 FCGIWrapper /var/syscp/fcgi/amaq/amaq.xyz.domain.com/php-fcgi-starter .php FCGIWrapper /var/syscp/fcgi/amaq/amaq.xyz.domain.com/php-fcgi-starter .php3 FCGIWrapper /var/syscp/fcgi/amaq/amaq.xyz.domain.com/php-fcgi-starter .php4 FCGIWrapper /var/syscp/fcgi/amaq/amaq.xyz.domain.com/php-fcgi-starter .php5 Options +ExecCGI </Directory> ErrorLog "/var/syscp/logs/amaq-error.log" CustomLog "/var/syscp/logs/amaq-access.log" combined </VirtualHost> I am using SYSCP, which is an open source free management tool (like cpanel)
  5. I know we can use 'set @myVar = "blah" ' to store a value to @myVar. Similarly we can also do: set @myVar = 'Select * from xyz'; and then execure the string stored in @myVar as: PREPARE sql FROM @myVar; EXECUTE sql; // this would execute the query However, my question is there a way to do sumthing like this: set @myVar = EXECUTE('Select * from xyz' I wana store the results of execution into a variable. Thanks
  6. yeap you cannot. You have to make sure that your browser knows how to handle files. Here is an example how to prompt for download and disable auto play mp3 songs in internet explorer http://support.microsoft.com/kb/883255
  7. Replace: $sql4 = "SELECT * FROM Login WHERE username LIKE '$username';"; To: $sql4 = "SELECT * FROM Login"; Now it will display all users from Login table.
  8. What would be the difference between preg_match_all('~ & preg_match_all('/
  9. I think by default <form> submission method is set to 'GET', and since you are using $_POST in your php code here is what you can do: 1) change form submission method to post by using: <form name="demo" onSubmit="return validateFormOnSubmit(this)" action="verify.php?" method="post"> 2) Stick to get and change: <form name="demo" onSubmit="return validateFormOnSubmit(this)" action="verify.php?" method="get"> & in php use $_GET instead of $_POST
  10. actually you can, try this $blah = select($table, 'my grouping'); similar you can also try: $blah = select($table, $group = '', '', 'where this'); $blah = select($table, '', $column = '', 'where this'); Tops are the same. Where is what I use, you may find it handy: /*********************************************** * mysqlSearch(&$handle, $table, $arrSelect, $arrWhere, $order_field = '' , $order = '', $group = '', $limit = 100000, $arrJoins, $daKey) * * Generic table mysql fetch * $arrSelect = array ('id', 'carrier') or array('*' for all) \ OR LITERAL STRING e.g. array('literal: `id` as `theID`', `blah`) * $arrWhere = array ('id' => $id) * or Literal array('literal' => ' `id` = AND ( 99 OR `id` = 999)') * would result in AND ( `id` = AND ( 99 OR `id` = 999)' ) * $order_field = ORDER BY `the_field` * $order = ORDER BY `the_field` $order * $group = GROUP BY `carrier` * * @return array function mysqlSearch(&$handle, $table, $arrSelect, $arrWhere, $order_field = '' , $order = '', $group = '', $limit = 100000, $arrJoins = NULL, $daKey = NULL) { global $objResponse; # what needs to be selected? $strSelect = prepare_select($arrSelect); # what needs to be selected? $strWhere = prepare_where($arrWhere); # is there is no where, have a dummy one if (!$strWhere) $strWhere = ' 1 '; # any joins? $strJoins = prepare_joins($arrJoins); # run mysql now $query = ' SELECT ' . $strSelect .' FROM '.$table.' '. $strJoins .' WHERE '. $strWhere .' '.( $group ? ' GROUP BY ' . $group : ' ' ) .' '.( $order_field ? ' ORDER BY ' . $order_field . ' ' . $order : ' ' ) .' LIMIT '. $limit ; $result = mysqlRun($query, $handle , 'mySQL Fetch from ' . $table); if ($result) { while ($row = $result->fetch_assoc()) { if ($daKey) $arr[$row[$daKey]] = $row; else $arr[] = $row; } } return $arr; } /*************************************** * prepare_select($arrSlt) * * Returns a string of select criteria * */ function prepare_select($arrSelect) { if (is_array($arrSelect)) { foreach ($arrSelect as $k) { if ($strSelect) $strSelect .= ' , '; # literal string? if (preg_match('/literal:/',$k)) { $k = trim(str_replace('literal:','',$k)); $strSelect .= $k ; } else if ($k == '*') $strSelect .= $k; else $strSelect .= ' `'.$k.'` '; } } return $strSelect; } /*************************************** * prepare_where($arrWhere) * * Returns a string of where criteria * */ function prepare_where($arrWhere) { if (is_array($arrWhere)) { foreach ($arrWhere as $k => $v) { if ($strWhere) $strWhere .= ' AND '; # literal string? if (preg_match('/literal/',$k)) { $strWhere .= $v ; } else { $strWhere .= ' `'.$k.'` = "'.$v.'" '; } } } return $strWhere; } /*************************************** * prepare_joins($arrJoins) * * Returns a string of joins * */ function prepare_joins($arrJoins) { if (is_array($arrJoins)) { foreach ($arrJoins as $k => $v) { $strJoins .= $v ; } } return $strJoins; }
  11. nevermind, duplicate post.. already explained by ignace:D
  12. Here is what you can do: Solution 1: class database { // Each time this class is called, it will connect to the database function __construct($dbhost, $dbuser,$dbpass, $dbname) { // no it knows what $dbhost, $dbuser, $dbpass and $dbname are. $this->dbConnect($dbhost, $dbuser,$dbpass, $dbname); } // Creates a connection to the database function dbConnect($dbhost, $dbuser,$dbpass, $dbname) { ... as is ... } } // code.php then in code create an instance like this: $sqlConn = new database($dbhost, $dbuser,$dbpass, $dbname); // passing parms to __construct() Solution 2: not so kool class database { // Each time this class is called, it will connect to the database function __construct() { $this->dbConnect($dbhost, $dbuser,$dbpass, $dbname); } // Creates a connection to the database function dbConnect() { global $dbhost, $dbuser, $dbpass, $dbname; // now it knows what these are ... as is ... } } // code.php then in code create an instance like this: $sqlConn = new database(); Also, change: $sql = "INSERT INTO users (Username, Password, Email, FullName) VALUES ($username, $password, $email, $name)"; to: $sql = "INSERT INTO users (Username, Password, Email, FullName) VALUES ('$username', '$password', '$email', '$name')"; make sure that you have escaped $username, $password, $email & $name by using mysql_real_escape_string(); e.g. $username = mysql_real_escape_string($username); to prevent mysql injection.
  13. ToonMariner: Actually its a good idea plus a better solution, will give that a try. However eval() doesnt seem to be working in this senario, else why would I have posted this question
  14. Try, http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html
×
×
  • 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.