Jump to content

jazzman1

Staff Alumni
  • Posts

    2,713
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by jazzman1

  1. Hey Barand, I find your personal replies very usefully for me since I've been a member to this forum So I just wanted to use this CASE structure ( with optional expression) : CASE [ expression ] WHEN condition_1 THEN result 1 WHEN condition_2 THEN result 2 END So, I just forgot to add a column name to expression, it should have been something like that: $sql = "UPDATE tblpaqueteria t INNER JOIN guias g ON (g.id = t.guia_id) SET t.Estatus = 2, g.guia = CASE t.guia_id WHEN t.guia_id = 1 THEN g.guia = 10 WHEN t.guia_id = 2 THEN g.guia = 12 END WHERE t.guia_id IN(1,2)";
  2. That's extremely easy in CentOS. Open up a terminal as a regular user and just install "Remi" repository by redhat package manager (RPM) ## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 64 Bit ## su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm' password: (root pass) su -c 'rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm' password: In case you are on CentOS 32: ## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 32 Bit ## rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm Then, install Apache, MySQL 5.5.x (in case you're using mysql-server) & PHP 5.4.x ## Installing on RHEL/CentOS 5-6 ## su -c 'yum --enablerepo=remi,remi-test install httpd mysql mysql-server php php-common' password: Install a php 5.4.x modules, you can customize this process too: ## Installing on RHEL/CentOS 5-6 ## su -c 'yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo' Finally set the run-levels to Apache, MySQL ## Enable Apache and MySQL on Run-Levels ## # chkconfig --levels 235 httpd on # chkconfig --levels 235 mysqld on ## Apache Commands ## # /etc/init.d/httpd start # /etc/init.d/httpd stop # /etc/init.d/httpd status ## MySQL Commands ## # /etc/init.d/mysqld start # /etc/init.d/mysqld stop # /etc/init.d/mysqld status When I followed this guide few weeks ago, I've got an error for missing library named: libvpx. You can download it by wget and install it by rpm: wget ftp://ftp.pbone.net/mirror/atrpms.net/el6-x86_64/atrpms/stable/libvpx0-0.9.7.1-1_1.el6.x86_64.rpm su -c 'rpm -ivh libvpx0-0.9.7.1-1_1.el6.x86_64.rpm' That's all Hope, that helps you.
  3. He-he, I just forgot to add a table name to my CASE. Good for you
  4. Hey patchido, it sounds my CASE is wrong....I don't know....I should try to make a test with a real data.. I think, Barand could be provide us a better solution of this issue. jazz.
  5. I wanted to say, onto one web root directory we might would have multiple domain names, so onto one wed server we could also have multiple web root directories. Sorry about that.
  6. Yes, that's a correct utl address to this directory. Yes, you should use the string link given from the server - /homepages/23/d409796783/htdocs/marcinternational.com On one web server you would have multiple domain names like - host.com, host1.com, host2.com and so on, but only one of them is set up with primary status. So, all of them could have sub-domains like - sub.host.com, sub.host1.com and so on... So, go to the primary domain with name marcinternational.com and create a new sub-domain with name for example - images.marcinternational.com, then set the proper path to this sub-domain, it could be something like - /f/images (if you have a second folder named images containing yours images). After few minutes (depend of the hosting) the customers could reach those images by web address -images.marcinternational.com/first_image.jpg or with full url address - marcinternational.com/f/images/first_image.jpg
  7. @Doug_M, you did not mention by the fact of SELinux configuration above. You also said that you're using the same php version with the same configuration but obviously is not true. Hey mac_gyver, it's a good trick, where did you get that
  8. @mac_gyver can you prove your statement? If SELinux's configuration is enable by default you should not use php functions that talk to LDAP server as copy(), mkdir(), mail(), and so on..... I am CentOS (RedHat) user more than 13 years, so I'm almost 100% sure that the problem is there.
  9. SELinux doesn't allow your httpd daemon to talk to the LDAP server on the same machine, so I had the same problems from Centos 6+ versions. Speak with your sysadmin and change the configuration file of SELinux.
  10. Just create an php array (or js) with all posible right answers. When the new answer has been submited just check if this answer exist in that answers array. Then, define a new $_SESSION['results'] array setting up to 0 or NULL ($_SESSION['results'] = 0 ), so If the answer is correct set that session $_SESSION['results'] = $_SESSION['results'] + 1. Finally count the indexes of that array, display the results and unset($_SESSION['results']) That's all PS: Don't forget to use a session_start(), check the php.net documentation.
  11. EDIT: Re-reading my post I saw an error. $os = $_POST['os'][0] should be $os = $_POST['os'], sorry about that.
  12. No, you cannot save anything in "images.marcinternational.com" b/s it's a not directory. That's an URL point to IP addresses and directories to DNS (Domain Name Server) in your hosting account. So, those statements are completely wrong: function image_root(){ if($_SERVER['DOCUMENT_ROOT']=='/marcinternational.com/' || $_SERVER['DOCUMENT_ROOT']=='/marcltd.com/'){ return '/images.marcinternational.com/f/'; } } function image_webroot(){ if($_SERVER['DOCUMENT_ROOT']=='/marcinternational.com/' || $_SERVER['DOCUMENT_ROOT']=='/marcltd.com/'){ return '/images.marcinternational.com/f/'; } } Well, if the directory "/f" is a sub-directory of the web root directory named: marcinternational.com you shoud reach that directory by this URL: http://marcinternational.com/f // or by ip address http://212.227.212.89/f If you have one more directory to "/f" containing images just add it to your url address. Then, go to the control panel and make a new record to the DNS pointing to "/f" or "/images" (in case you have a sub-directory with the same name inside "/f")
  13. Ok, that's the test: <?php $ids = array(12, 13, 14); $os = array(23, 24, 154); $i = 0; $sql = "UPDATE tblpaqueteria t INNER JOIN guias g ON (g.id = t.guia_id) SET t.Estatus = 2, g.guia = CASE "; foreach ($os as $val) { $sql .= sprintf("WHEN t.guia_id = %u THEN g.guia = %u ", intval($ids[$i]), intval($val)); $i++; } $sql .= "END WHERE t.guia_id IN (".implode(", ", array_map('intval', $ids)).")"; echo '<pre>'.print_r($sql, true).'</pre>'; Results: So, replace $ids = $_POST['ids'] and $os = $_POST['os'][0] and try yourself. You could also customize my code make it much more readable creating a custom php functions or something else. Anyways that code has to work for you, if you got any errors just let's know. jazz.
  14. Yes master, I've buided the sql with CASE too , it looks like that for now: $sql = "UPDATE tblpaqueteria t INNER JOIN guias g ON (g.id = t.guia_id) SET t.Estatus = 2, g.guia = CASE WHEN t.guia_id = 1 THEN g.guia = 1 END WHERE t.guia_id IN(1,2)"; I need a little time to create the php code to make it dynamic
  15. It sounds like you have multiple web root directories seting up into one web server maybe as alias. So, make sure that the "/f" directory is located inside "/marcinternational.com" not inside "htdocs"
  16. I'll try to give you an example later, OK?! But, the question is, why do you want to update the same filed two or more times in the same sql statement. What is the point of that? The last update would be lost from the new one.
  17. I don't sure if we can use IN operator in the SET statement - check in the web. Another possible solution is to loop the result through php.
  18. More then one value where?
  19. Ah....you're using an array in your html with integer value. So, try this... $ids = implode(", ", array_map('intval', $_POST['ids'])); $sql = sprintf("UPDATE tblpaqueteria t INNER JOIN guias g ON (g.id = t.guia_id) SET t.Estatus = 2, g.guia = %u WHERE t.guia_id IN($ids)", intval($_POST['os'][0]));
  20. What was happened with my code above? Instead die("some text here") use die(mysql_error()) and let's see the error messages.
  21. Well, submit the form and give us the results back. echo '<pre>'.print_r($_POST['os'], true).'</pre>'; exit; $ids = implode(", ", array_map('intval', $_POST['ids'])); $sql = sprintf("UPDATE tblpaqueteria t INNER JOIN guias g ON (g.id = t.guia_id) SET t.Estatus = 2, g.guia = '%s' WHERE t.guia_id IN($ids)", mysql_real_escape_string($_POST['os']));
  22. No, the relationship for me is one-to-many b/s "cid" means "category_id", so every category should have one (zero it's possible too) or more images. That's why if him database structure is correct this code should be work properly: $pdo = new PDO('mysql:host=localhost;dbname=database', 'admin', 'root'); $cid = $_GET['cid']; // it's the value from the category id coming from the link $query = $pdo->prepare(" SELECT `i`.`img`, `c`.* FROM `images` as `i` INNER JOIN `cardId` as `c` ON (`i`.`cid` = `c`.`id`) WHERE `i`.`cid` IN (:cid) AND `c`.`status`=1"); $query->bindParam('cid', $cid); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { echo '<pre>'.print_r($row, true).'</pre>'; } $query = null;
  23. As Barand could be said - can you provide table structures and data? Every image should have an ID. This query is not very efficiency to me: $query = "SELECT i.img, i.cid FROM images i INNER JOIN cardId as c ON i.cid = c.id WHERE c.status = 1 ORDER BY c.id ASC LIMIT 10"; What should be happen if you have 100 images with 10 different categories and the very first 10 images belong only to 1 category. Your database logic it's sucks to me
  24. This is a cartesian join, we should avoid using it! It's too late - c.status = 1 it's time to go bed
  25. This is a cartesian join, we should avoid using it!
×
×
  • 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.