PHP - I'm Confused About Composer And Repositories
I want to install this package:
https://github.com/composer/installers
from GitHub, I can easily git clone it but I think its better I get experienced with composer. In the readme they onyl give one example, one involving CakePHP:
{ "name": "you/ftp", "type": "cakephp-plugin", "require": { "composer/installers": "~1.0" } }but I that isn't much help to me since I'm not making composer.json files to hold a single framework or plugin, my json files look more like this: { "name": "example-app", "require": { "cakephp/cakephp": ">=2.5.1", "cakephp/debug_kit": "2.2.*", "slywalker/boost_cake": "*", "CakeDC/tags": "1.*", "CakeDC/utils": "*", "CakeDC/migrations": "*", "FriendsOfCake/crud": "*", "CakeDC/search": "*", "paulredmond/chosen-cakephp": "*" }, "config": { "vendor-dir": "Vendor/" }, "extra": { "installer-paths": { "app/Plugin/Tags": ["CakeDC/tags"], "app/Plugin/BoostCake": ["slywalker/boost_cake"] } } }Right now I'm working on a WordPress one and it is 10 times longer than that. So what I was wondering is if its better to split it up into a few composer.json files. As in one file for setting up the framework and configuring it, when its done, it calls a second composer.json file that will take care of installing the plugins. Like this I suppose I could store a bunch of composer.json files in a central location, each of them has a specific purpose, so if I need to use one of them for a project, I just call composer.phar file (which I can access globally), and use that global keywork to make the json file operate like its in my projects directory. I don't understand what this autoload thing is about at all, but its nice the way it lets you run scripts at particular times during the execution of the json file. Is this actually a better way to work with composer, by chaining separate composer.json files together? A big issue is the name conflict thing, is there a way to make composer.phar process files with different names? It be a pain in the ass having to make the scripts alter the filenames. That gets me thinking about something. Can we define variables in composer.json files? If not, I suppose its not very hard to do it anyway by editing the file. I was thinking there that a composer file generator would be pretty useful. Like say on CakePHPs website, theres a page that lets you check plugins and features that you want for your new installation, then it makes a composer.json file for you. Similar Tutorialsphp74 is installed as my primary php, but I am also working with a different framework that can only use php73 and set up a separate pool to deal with it. Recently, my installed composer1 told me I should upgrade to composer2 and I did so, but then found that the previously mentioned other framework also doesn't work with composer2 but only composer1. When updating a package with composer, sometimes I get composer errors or even worse no composer errors but PHP errors later on where classes don't exist, and I think it relates to using the wrong version of PHP (and maybe even composer). Is it always required to consistently use composer with a single version of PHP? Anything to worry about different versions of composer or will I just get a message. Any other best practices? Any issues how I set up composer below? Thanks! curl -sS https://getcomposer.org/installer | php # or if desired, use resulting composer.phar as: $ php (or php73) composer.phar update/install/etc chmod +x composer.phar sudo mv composer.phar /usr/local/bin/composer sudo ln -s /usr/local/bin/composer /usr/local/bin/composer2 curl -sS https://getcomposer.org/installer | php73 chmod +x composer.phar sudo mv composer.phar /usr/local/bin/composer2_73 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php --version=1.10.19 chmod +x composer.phar sudo mv composer.phar /usr/local/bin/composer1 php73 composer-setup.php --version=1.10.19 chmod +x composer.phar sudo mv composer.phar /usr/local/bin/composer1_73 rm composer-setup.php
I'm beginning to study Composer and am developing a system where I separate the files core application files, as follows:
/root |-- /src |-- /App |-- /DBConfig |-- /Controller |-- /Model |-- /Core |-- /Helper |-- /Controller |-- /ModelSo, to set this setting in composer.json file and get access to all classes both /App much /Core would be this way? "autoload" : { "psr-X" : { "App\\" : "/src", "Core\\" : "/src" } }Or is there a more correct way? I have also read about PSR-0 vs PSR-4 and I am still somewhat in doubt which one to use. In my case what should I implement, PSR-0 or PSR-4? I've only seen composer packages using vendor name and package name namespace. Is it possible to use deeper namespace such as the following? For instance, package: { "name": "notioncommotion/my-sub-namespace/my-package", "description": "MyPackage located in MySubNamespace.", ... } is used in some project: { "require": { "notioncommotion/my-sub-namespace/my-package": "^1.2" } } If not, what do you think were the reasons composer does not allow? Thanks Hi.
My sys admin guy has informed me that installing composer is unlikely. They're a bit jumpy about security around here.
I tried to download and run Laravel on it's own but I'm getting errors when I go to http://example.com/t...laravel/public/
Warning: require(/var/www/html/test/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/test/laravel/bootstrap/autoload.php on line 17 Fatal error: require(): Failed opening required '/var/www/html/test/laravel/bootstrap/../vendor/autoload.php' (include_path='.:/php/includes:/var/www/html/php/includes:/jpa/release/jpa/includes:/usr/share/pear:/usr/share/php/phpmailer:/apache/htdocs/applications/surveys/Includes:/var/lib/ZF1/library') in /var/www/html/test/laravel/bootstrap/autoload.php on line 17I'm very new to Laravel and I am basically assuming that the reason for these errors is because i haven't installed all the various dependancies. And that you can only install all the dependancies through Composer. Is this the case? I downloaded the Laravel framework from GitHub Unfortunately.. My only real experience of PHP Frameworks is CodeIgniter. So I've never expoled/used "packages" or "dependancies" and don't really know where they are, or where they go, or what they do! I managed to get Laravel up and running on my personal computer (using Composer).... But, as I've said, I might not be able to do this on my day job server. Any tips? ----- Update ----- Is there a chance I am just misunderstanding the word "Dependancies"? It's not a word I often use. Does it just mean "The PHP files that make up the Laravel Framework"? Edited by Korferer, 19 November 2014 - 08:11 AM. I think I am close, but not sure if I am quite there. Am I doing this correctly? I have several entity classes which will use class type inheritance:
MyNamespace\MyApp\Vehicle\Vehicle #MyNamespace.MyApp.Vehicle.Vehicle.dcm.yml MyNamespace\MyApp\Vehicle\Vehicle: type: entity table: vehicle_table inheritanceType: JOINED discriminatorColumn: name: discriminator_column type: string discriminatorMap: vehicle: Vehicle groundVehicle: MyNamespace\MyApp\Vehicle\GroundVehicle\GroundVehicle airVehicle: MyNamespace\MyApp\Vehicle\AirVehicle\AirVehicle repositoryClass: Vehicle id: id: type: integer generator: strategy: AUTO fields: grandParentItem1: type: string grandParentItem2: type: string #MyNamespace.MyApp.Vehicle.AirVehicle.AirVehicle.dcm.yml MyNamespace\MyApp\Vehicle\AirVehicle\AirVehicle: type: entity table: air_vehicle extends: MyNamespace\MyApp\Vehicle\Vehicle inheritanceType: JOINED discriminatorMap: airVehicle: AirVehicle airplane: MyNamespace\MyApp\Vehicle\AirVehicle\Airplane\Airplane rocket: MyNamespace\MyApp\Vehicle\AirVehicle\Rocket\Rocket repositoryClass: AirVehicle id: id: associationKey: true fields: parentItem1: type: string parentItem2: type: string #MyNamespace.MyApp.Vehicle.AirVehicle.Rocket.Rocket.dcm.yml MyNamespace\MyApp\Vehicle\AirVehicle\Rocket\Rocket: extends: MyNamespace\MyApp\Vehicle\AirVehicle\AirVehicle type: entity table: rocket_table id: id: associationKey: true repositoryClass: Rocket fields: childItem1: type: string childItem2: type: string I haven't shown GroundVehicle or Train, Car, and Airplane, but they are almost identical to AirVehicle and Rocket, respectively.
I've discovered that the barebone entities need to be manually created prior to using orm:generate-entities else I get class not found errors, and have created them as shown below. [michael@devserver doctrine]$ find inheritance_src -name "*.php" -exec cat {} \; <?php namespace MyNamespace\MyApp\Vehicle\AirVehicle\Airplane; class Airplane extends \MyNamespace\MyApp\Vehicle\AirVehicle\AirVehicle{} <?php namespace MyNamespace\MyApp\Vehicle\AirVehicle\Rocket; class Rocket extends \MyNamespace\MyApp\Vehicle\AirVehicle\AirVehicle{} <?php namespace MyNamespace\MyApp\Vehicle\AirVehicle; abstract class AirVehicle extends \MyNamespace\MyApp\Vehicle\Vehicle{} <?php namespace MyNamespace\MyApp\Vehicle\GroundVehicle\Car; class Car extends \MyNamespace\MyApp\Vehicle\GroundVehicle\GroundVehicle{} <?php namespace MyNamespace\MyApp\Vehicle\GroundVehicle\Train; class Train extends \MyNamespace\MyApp\Vehicle\GroundVehicle\GroundVehicle{} <?php namespace MyNamespace\MyApp\Vehicle\GroundVehicle; abstract class GroundVehicle extends \MyNamespace\MyApp\Vehicle\Vehicle{} <?php namespace MyNamespace\MyApp\Vehicle; abstract class Vehicle{} I then am able to successfully create the entities using orm:generate-entities, schema using orm:schema-tool:create, and repositories using orm:generate-repositories. Does everything seem correct? A couple of issues which I have my doubts: Locating the classes in inheritance_src/MyNamespace/MyApp instead of inheritance_src/MyApp. I tried to do the later and modify my psr-4 autoloader to use "MyNamespace\\": "inheritance_src/", but could not get it working without first creating the entities, editing them to add the "abstract" and "extend" portions, and then moving them to one directory lower. Needing to manually create the barebone classes in the first place. My meta-data definitions includes "extends: MyNamespace\MyApp\Vehicle\Vehicle", so I would thought it would not be necessary. Locate both the entities and repositories in the same folder. For that matter, I will probably be locating my service in the same folder as well. It seems that most frameworks will locate all the entities in one folder (with of course subdirectories), repositories in another, services in another, etc. The way I am doing seems to be organized domain modules as described by https://mnapoli.fr/organizing-code-into-domain-modules/. Any compelling reasons to do it one way or the other?
Thank you Quick question about the dependency manager Composer with PHP. I have it installed and am pulling in a few libraries, it works pretty well as far as I can tell. I have a question that might be dumb, so I apologize in advance. When connecting to your application it's still required to use the lines similar to the following? <script src="vendor/components/jquery/jquery.min.js"></script> <link rel="stylesheet" href="vendor/twbs/bootstrap/dist/css/bootstrap.css" > Also I'm trying to figure out how to install the x3dom library, but cannot get composer to do it. (https://www.x3dom.org/) Good morning, people! I'm having the following problem in my projectx in php: I created a project with Composer in php where I put php to listen to the public folder from the command prompt. However, when I upload the project to the site or to the xampp htdocs, the result of displaying the index (domain / projectx / public) is white. It does not display anything or any warning. Running with the php server via prompt listening directly to the public folder the project runs normally. The structure of the project is this (it has an attached image too): projeto x -App -Controller (folder with controllers) -Model (folder with models) -View (folder with views) -Connection (DB connection class) -Route (Class that manages the routes accessed in the browser and instantiates the necessary controllers) -public -.htaccess -index.php (Application start page that instantiates the Route class to determine the flow of the application) -vendor -composer (folder with composer files) -autoload.php composer.json composer.lock composer.phar When I include files in the public folder and access directly, the file works normally. That is, the server is listening to all folders.
Could you help me with this? If I have to configure something on the server or in my project? I am new to PHP and would greatly appreciate your help. Right now, I'm grateful! Application running on the latest version of Composer. Tested on php version 5.6.40 and 7.1
I just updated a site as follows: cd /var/www/concrete5 composer update Among other changes, the following were made (more on this later): - Updating concrete5/core (8.5.2 => 8.5.4): Downloading (100%) - Updating doctrine/collections (1.6.4 => 1.6.5): Downloading (100%) - Updating doctrine/lexer (1.2.0 => 1.2.1): Downloading (100%) - Updating doctrine/inflector (1.3.1 => 1.4.3): Downloading (100%) - Updating doctrine/cache (1.10.0 => 1.10.1): Downloading (100%) - Updating doctrine/annotations (1.10.2 => 1.10.3): Downloading (100%) - Updating doctrine/common (2.12.0 => 2.13.3): Downloading (100%) - Updating doctrine/instantiator (1.3.0 => 1.3.1): Downloading (100%) - Updating doctrine/orm (v2.7.2 => v2.7.3): Downloading (100%)
errno: 150 "Foreign key constraint is incorrectly formed I expected I should have first used concrete5's update script, but too late for that. So, then I changed composer.json require concrete5/core from ^8.5 to 8.5.2 hoping to return to the previous state. Concreete5 was downgraded as desired, but now I get the following error: Class 'Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain' not found On another concrete5 site which still works, I have the following two files, however, on the broken one I only have the second: vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:13: class MappingDriverChain extends \Doctrine\Persistence\Mapping\Driver\MappingDriverChain vendor/doctrine/persistence/lib/Doctrine/Persistence/Mapping/Driver/MappingDriverChain.php:17:class MappingDriverChain implements MappingDriverSo, now I will attempt to downgrade doctrine from 2.7.3 to 2.7.2. The base composer.json file has no reference to Doctrine, but there are two other related composer files: vendor/concrete5/doctrine-xml/composer.json { "name": "concrete5/doctrine-xml", "description": "Define database structure via XML using Doctrine data types", "keywords": [ "doctrine", "xml", "structure", "database", "schema" ], "homepage": "https://github.com/concrete5/doctrine-xml", "license": "MIT", "autoload": { "psr-4": { "DoctrineXml\\": "src/" } }, "require": { "php": ">=5.3" }, "require-dev": { "doctrine/dbal": "2.5.*" } } vendor/concrete5/dependency-patches/composer.json { "type":"library", "license":"MIT", "name":"concrete5/dependency-patches", "description":"Patches required for concrete5 dependencies", "homepage":"https://github.com/concrete5/dependency-patches", "authors":[ { "name":"Michele Locati", "email":"michele@locati.it", "role":"author", "homepage":"https://mlocati.github.io" } ], "require":{ "mlocati/composer-patcher": "^1.0.0" }, "extra":{ "patches": { "doctrine/annotations:1.2.7": { "Fix access array offset on value of type null": "doctrine/annotations/access-array-offset-on-null.patch" }, "doctrine/orm:2.5.14": { "Fix UnitOfWork::createEntity()": "doctrine/orm/UnitOfWork-createEntity-continue.patch" }, "zendframework/zend-stdlib:2.7.7": { "Fix ArrayObject::unserialize()": "zendframework/zend-stdlib/ArrayObject-unserialize-continue.patch" }, "sunra/php-simple-html-dom-parser:1.5.2": { "Fix minus in regular expressions": "sunra/php-simple-html-dom-parser/minus-in-regular-expressions.patch" }, "phpunit/phpunit:4.8.36": { "Avoid each() in Getopt": "phpunit/phpunit/Getopt-each.patch" }, "tedivm/jshrink:1.1.0": { "Fix continue switch in Minifier": "tedivm/jshrink/fix-minifier-loop.patch", "Update to upstream version 1.3.2": "tedivm/jshrink/update-upstream-1.3.2.patch" }, "zendframework/zend-code:2.6.3": { "Fix continue switch in FileGenerator and MethodReflection": "zendframework/zend-code/switch-continue.patch" }, "zendframework/zend-http:2.6.0": { "Remove support for the X-Original-Url and X-Rewrite-Url headers": "zendframework/zend-http/no-x-original-url-x-rewrite.patch" }, "zendframework/zend-mail:2.7.3": { "Fix idn_to_ascii deprecation warning": "zendframework/zend-mail/fix-idn_to_ascii-deprecation-warning.patch" }, "zendframework/zend-validator:2.8.2": { "Fix idn_to_ascii/idn_to_utf8 deprecation warning": "zendframework/zend-validator/fix-idn_to_-deprecation-warning.patch" } } } } Neither seem to be applicable, but the doctrine version has to be specified somewhere. How does composer determine which version and how can I downgrade the dependency package? Thanks
PS. As a hack solution, I replaced the entire vendor/doctrine directory from one from another site, and have things working. Still, want to know how to do this right. Edited June 12, 2020 by NotionCommotionI've got my own proprietary framework. I call it Brain. It uses composer, and installation is done with a single composer file, which is handy. Here's an example:
{ "name": "skunkbad/brain-test", "description": "My Awesome App", "license": "proprietary", "minimum-stability": "dev", "repositories": [ { "type": "hg", "url": "ssh://hg@bitbucket.org/skunkbad/brain" } ], "require": { "skunkbad/brain": "default" }, "scripts": { "post-install-cmd": "Brain\\Statics\\BrainInstallScript::run" } }Brain has it's own dependencies, which aren't all really dependencies, but I've added them all to its composer.json file so I get everything I want for a new project. Here is it's composer.json: { "name": "skunkbad/brain", "version": "1.0.0", "type": "framework", "license": "Proprietary", "authors": [ { "name": "Robert B Gottier", "email": "xXxXxXxXx@gmail.com", "homepage": "http://brianswebdesign.com", "role": "Developer" } ], "require": { "pimple/pimple" : "v2.0.0", "swiftmailer/swiftmailer": "v5.2.0", "dompdf/dompdf" : "0.6.1", "phpseclib/phpseclib" : "0.3.6", "stripe/stripe-php" : "v1.15.0", "firephp/firephp-core" : "dev-master", "doctrine/dbal" : "v2.4.2" }, "autoload": { "psr-4": { "Brain\\": "/", "App\\": "../../../App/" }, "classmap": [ "Statics/" ] } }In Windows terminal, I can run composer install or composer install --prefer-dist, and it seems that especially when the doctrine packages are being downloaded or cloned (whatever it does), its super slow. Some of them hang for so long that occasionally the terminal will give me a message indicating a particular package timed out (5 mins). So I was wondering if this is just the norm. Feels like I'm on dial-up, but my internet connection is Verizon FiOS (fiber optic). Here is an example of the time-out message I get from Composer: Failed to download doctrine/common from source: The process "git clone --no-checkout "git://github.com/doctrine/common.git" "C:\XXXxxx" && cd /D "C:\XXXxxx" && git remote add composer "git://github.com/doctrine/common.git" && git fetch composer" exceeded the timeout of 300 seconds. I timed my install, and composer/common actually hung for about 7 mins. Total time was 9.5 mins. According to I would like to try to use JWT for my PHP and these are my step
on domain/app/
so I have
and on the login.php try{ echo "1"; require_once('vendor/autoload.php'); use firebase\JWT\JWT; echo "2"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; }
It's not show any thing and error "HTTP ERROR 500" I notice plenty of CakePHP plugins don't have composer.json files in their github repositories (I'm not sure where composer downloads from if you don't specify a repository, is it github?) so I can't automatically download and update them. For composer to recognise and download the plugins, all thats needed is the composer.js file itself isn't it? Why wouldn't plugin authors just spend an extra 10 minutes and make a composer.js file? I'm guessing theres something I'm missing here, it must not be that simple. I only started using composer so I don't really know what its about yet.
Hallo, I have a strange problem with a freshly installed composer project that is not loading the dependencies as the documentation states it should. composer require phpmailer/phpmailer
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); // define('BASE_PATH', rtrim(preg_replace('#[/\\\\]{1}#', '/', realpath(dirname(__FILE__))), '/') . '/'); // require BASE_PATH . 'vendor/autoload.php'; require __DIR__ . '/vendor/autoload.php'; Edited June 23, 2020 by JacobSeated I like to set up websites for people who don't have the know how to do it themselves, I mainly set them up wordpress sites cuz thats pretty easy for them to modify and maintain themselves. To save myself time, I decided to learn how to do it with Composer (what a brilliant tool that it). Can anyone who uses composer for this kinda thing, can you post your composer.json files here. Also, if anyone can show me a better way of doing things, it'd be much appreciated. Heres the one I made:
{ "name": "acme/brilliant-wordpress-site", "description": "My brilliant WordPress site", "repositories":[ { "type":"composer", "url":"http://wpackagist.org" } ], "require": { "johnpbloch/wordpress": ">=3.8.0", "wpackagist-plugin/captcha":">=3.9", "wpackagist-plugin/tinymce-advanced":">=4.0.0", "wpackagist-plugin/wordpress-importer":"*", "wpackagist-theme/hueman":"*", "wpackagist-theme/eclipse":"*", "wpackagist-theme/raindrops":"*" }, "extra": { "installer-paths": { "mysite": ["johnpbloch/wordpress"], "mysite/wp-content/plugins/{$name}": ["type:wordpress-plugin"], "mysite/wp-content/themes/{$name}": ["type:wordpress-theme"] } }, "autoload": { "psr-0": { "Acme": "src/" } } }I think I'm doing this in a silly way though. I read about these composer installer things on github, but I didn't figure out how to use them so instead I used the installer-paths key to make the autoloader put the files in the right place. Heres a composer.json file I found which is better cuz it uses a post installation script: { "require": { "wordpress/core": "3.5.2", "wordpress/twentytwelve": "1.1", "wordpress/akismet": "2.5.7", "wordpress/google-sitemap-generator": "3.2.9", "wordpress/google-analytics-for-wordpress": "4.3.3", "wordpress/wordpress-importer": "0.6.1" }, "repositories": [ { "type": "composer", "url": "https://raw.github.com/wordpressoncomposer/composer-repository/master/" }, { "type": "vcs", "url": "https://github.com/wordpressoncomposer/installer" } ], "scripts": { "post-install-cmd": "Wordpress\\Composer\\InstallerTasks::wpConfig" }, "extra": { "wordpress_coredir": "wordpress/core", "wordpress_wp_contentdir": "wordpress/wp-content", "wordpress_wp_config": { "site_url": "http://localhost", "db_host": "localhost", "db_user": "root", "db_pass": "", "db_name": "wordpress" } }, "minimum-stability": "dev" }I'm gonna start using these scripts once I figure out how to use them. Where are the scripts stored? I haven't a clue what this autoload thing is all about either, is it a tool for moving files into the appropriate directories? See how the first file gets wordpress from packagist, and the second one gets it from github. Is there a difference? If I was to add that post-install-cmd key to the first composer.json file, would it still work? In other words, do both repositories contain identical packages.
Dear All.
This is my command for composer require_once 'vendor/autoload.php'; $operator = "http://ltcservice..com:5577/Services.asmx?WSDL"; $privateKey = "BDX89Cxfpp"; $headerSMS = "TEST"; // TEST $userid = "BDX"; $txtTel ="2059545445659"; $newRegCode_exp = rand(); $messageBody = "Test SMS"; //$serverIP = $_SERVER['REMOTE_ADDR']; $serverIP = "172.28.17.61"; $trans_id = "BDX".rand(); //$trans_id = "123456"; $data = $serverIP.$trans_id; $messageBody = $serverIP.$trans_id; echo '<br/>'.$data. " >=> " . exec("java -jar encrypt.jar ".$data." ".$privateKey, $key); echo '<br/>'.$key[1]. " >=> " . exec("java -jar decrypt.jar ".$key[1]." ".$privateKey, $output); echo '<br/> encrypt result >=> '.$key[0]; if($key[0]=="OK"){ $header = array('userid' => $userid, 'trans_id' => $trans_id, 'key' => $key[1], ); echo '<br/>'; print_r($header); $client = new SoapClient($operator); $msg = array( 'msisdn' => $txtTel, 'message' => $messageBody, 'headerSMS' => $headerSMS, 'header' => $header, ); $requestmsg = array('msg'=>$msg); echo '<br/>'; print_r($msg); $data = $client->SendSMS($requestmsg); echo '<br/>'; print_r($data); } Error Fatal error: Uncaught Error: Class 'SoapClient' not found in C:\xampp\htdocs\sms\SEND_SMS\testSendSMS.php:27 Stack trace: #0 {main} thrown in C:\xampp\htdocs\sms\SEND_SMS\testSendSMS.php on line 27
So just seen this http://www.ultramegatech.com/2009/07/using-mysql-prepared-statements-in-php/ from another topic, and am a bit confused now, I started coding a little while back, but did not get introduced to mysqli until very recently, should I change all my normal mysql queries to the mysqli prepared statements like in the website/tutorial stated? does this mean I won't have to use mysql_real_escape_string and it is more secure in general? Would really like some input, much appreciated. Hi all im trying to create a simple user registration page using php and mysql i created the database and tables locally and tested it and it works great so I did the same for on my sever and in the my mysqli connection script I changed the database name/passwords etc to match the hosting. when i tested the script I get: Notice: Constant DB_USER already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 3 Notice: Constant DB_PASSWORD already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 5 Notice: Constant DB_HOST already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 7 Notice: Constant DB_NAME already defined in /home/lkennet1/public_html/xxx.co.uk/mysqli_connect.php on line 9 Easy to fix right. dont definine it twice. but im not defining it anywhere but my registration page and the only call i make to it is whne i use Code: [Select] require_once("mysqli_connect.php"); next mind boggling error is this: Table 'example_wrdp2.users' doesn't exist ok so to fix this I create the database right. well I have and it still dont work and I dont know why its choosing example_wrdp2 on my server i have 5 databases: example_wrdp1 example_wrdp2 example_wrdp3 example_wrdp4 example_myNewDatabase I don't understand why its not using example_myNewDatabase which i am specifying in my db connect script. Im totally lost and stuck with this. I am getting this error Quote Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/a6658518/public_html/view/register.php on line 83 Code: [Select] <html> <body> <pre> <?php $Fname = $_POST["Fname"]; $Lname = $_POST["Lname"]; $mail = $_POST["mail"]; if (!isset($_POST['submit'])) { ?> <form method="post" action="<?php echo $PHP_SELF;?>"> First Name:<input type="text" size="12" maxlength="12" name="Fname"><br /> Last Name:<input type="text" size="12" maxlength="36" name="Lname"><br /> Email:<input type="text" size="12" maxlength="36" name="mail"><br /> This must be a valid email! <input type="submit" value="submit" name="submit"> </form> <? } else { if (isset($_COOKIE["dsc"])) { echo "Whoops! You already got a serial number!" } else { $myFile = $Fname; $myFile .= ".vl"; $myFile = $loca .= myFile$; if (file_exists($myFile)) { echo "We seem to have another serial key with that name already made! Please email emery.cairns@gmail.com if you think this is an error"; } else { $fh = fopen($myFile, 'w') or die("Whoops! I had an error, please contact my owner at emery.cairns@gmail.com, code: file unwriteable"); $stringData = getSerial(); fwrite($fh, $stringData); fclose($fh); echo "Hello, ".$Fname." ".$Lname.".<br />"; echo "Thanks for registering with us, the email with your serial key and name will show up in your inbox shortly!.<br />"; echo "Please make sure it does not end up in your junk mail!"; $expire=time()+60*60*24*60; setcookie("dsc", "Serial given within 60 days", $expire); $to = $mail; $serial = getSerial(); $subject = "Dhpos Self Checkout"; $message = "Hello!, your serial number for D.S.C is {$serial} and your name is {$Fname} Thanks for downloading DSC, we hope you enjoy the program. You recived this message because you requested a serial number from http://dhposselfcheckout.tk, if you did not, please disregard this message."; $from = "emery.cairns@gmail.com"; $headers = "From:" . $from; if ( $to == "emery.cairns@gmail.com" ) { echo "mail stop"; } else { mail($to,$subject,$message,$headers); } } } } ?> <br /> </pre> </body> </html> why does this code display this webpage? brandysstudioofdance.com/checkOut.php Code: [Select] <?php session_start(); if (isset($_SESSION['cart'])){ foreach ($_SESSION['cart'] as $key => $value){ //echo "Product Number $key Quantity $value<br />"; } } require_once("functions.php"); //DatabaseConnection(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ordering doggy treats</title> <link href="doggyTreats.css" rel="stylesheet" type="text/css" /> <style type="text/css"> #order { margin-right: auto; margin-left: auto; } .orderRow{ padding-bottom: 50px; } h2 { text-align: center; } </style> </head> <body> <?php $errors=array(); if(isset($_POST['submit'])){ validate_input(); if(count($errors) !=0) { display_form(); } else { display_form(); } function validate_input() { global $errors; if($_POST["fname"] == " ") { $errors['fname']="<span style=\"color:red;\"> Please enter your first name </span>"; } } } //logo(); navBar(); extract($_POST); if(!isset($submit)) { echo "<table id=\"order\">"; function display_form() { global $errors; ?> <form action="php_self" method="post" name="checkOut"> <caption><h2>Customer Information </h2> </caption> <tr class = "orderRow"> <td> First Name:<br /> <input name="fname" type="text" size="10" maxlength="20" value="<?php echo $_POST[fname] ?>"> <br /> <br /> <!--<?php echo $errors['fname']; ?> --> </td> <td> Last Name: <br /> <input name="lname" type="text" size="10" maxlength="20" /> </td> <td> Address: <br /> <input name="address " type="text" size="25" /> </td> </tr> <tr class = "orderRow"> <td> City: <br /> <input name="city " type="text" size="15" maxlength="20" /> </td> <td> State: <br /> <select name = "state"> <option selected value ="Please choose a state"/> Please choose a state</option> <option value = "AL" />AL</option> <option value = "AK" />AK</option> <option value = "AR" />AR</option> <option value = "AZ" />AZ <option value = "CA" />CA <option value = "CO" />CO <option value = "CT" />CT <option value = "DE" />DE <option value = "DC" />DC <option value = "FL" />FL <option value = "GA" />GA <option value = "HI" />HI <option value = "IA" />IA <option value = "ID" />ID <option value = "IL" />IL <option value = "IN" />IN <option value = "KS" />KS <option value = "KY" />KY <option value = "LA" />LA <option value = "MA" />MA <option value = "ME" />ME <option value = "MD" />MD <option value = "MI" />MI <option value = "MN" />MN <option value = "MO" />MO <option value = "MS" />MS <option value = "MT" />MT <option value = "NC" />NC <option value = "ND" />ND <option value = "NE" />NE <option value = "NH" />NH <option value = "NJ" />NJ <option value = "NM" />NM <option value = "OH" />OH <option value = "OK" />OK <option value = "OR" />OR <option value = "PA" />PA <option value = "RI" />RI <option value = "SC" />SC <option value = "SD" />SD <option value = "TN" />TN <option value = "TX" />TX <option value = "UT" />UT <option value = "VA" />VA <option value = "VT" />VT <option value = "WA" />WA <option value = "WI" />WI <option value = "WV" />WV <option value = "WY" />WY </select> </td> <td> Zip Code:<br /> <input name="zipcode" type="text" size="5" maxlength="5" /> </td> </tr> <tr class = "orderRow"> <td> Phone <br /> Please include area code <br /> <input name="phone" type="text" size="13" maxlength="13" /> </td> <td> Fax:<br /> <input name="" type="text" size="13" maxlength="13" /> </td> <td> Email: <br /> <input name="email " type="text" size="15" maxlength="30" /> </td> </tr> <tr class = "orderRow"> <td> Please choose method of payment: <br /> Check <input name="check " type="radio" value="Check " /> Money Order <input name="money " type="radio" value="Money order " /><br />PayPal<input name="paypal" type="radio" value="Paypal" /> </td> </tr> <tr> <td colspan = "6"> <h2> Pet Information </h2></td> </tr> <tr> <td> Name: <br /> <input name="petName" type="text" size="10" maxlength="20" /> </td> <td> Age: <br /> <select name="age"> HEREDOC; for ($age =1; $age <=20; $age ++) { print "<option value=\"age\"> $age</option>"; } echo <<<HEREDOC </select> </td> <td> Breed:<br /> <select name = "breed"> <option selected value ="Please choose a breed"/> Please choose a breed <option value = "I don't know" />I don't know <option value = "Affernpincher" />Affernpincher <option value = "Afghan Hound" />Afghan Hound <option value = "Airedale Terrier" /> Airedale Terrior <option value = "Akita" /> Akita <option value = "Alaskan Malamute" /> Alaskan Malamute <option value = "Standard American Eskimo Dog"/> Standard American Eskimo Dog <option value = "Miniature American Eskimo Dog"/>Miniature American Eskimo Dog <option value = "Toy American Eskimo Dog"/> Toy American Eskimo Dog <option value = "American Foxhound" /> American Foxhound <option value = "American Staffordshire Terrier" /> American Staffordshhire Terrier <option value = "American Water Spaniel" /> American Water Spaniel <option value = "Australian Shepherd Dog"/> Anatolian Shepherd Dog <option value = "Australian Cattle Dog"/> Australian Cattle Dog <option value = "Australian Shepherd"/> Australian Shepherd <option value = "Australian Terrier" /> Australia Terrier <option value = "Basenji" /> Basenji <option value = "Basset Hound" /> Basset Hound <option value = "Beagle" /> Beagle <option value = "Bearded Collie" /> Bearded Collie <option value = "Beauceron" /> Beauceron <option value = "Bedington Terrier"/> Bedington Terrier <option value = "Belgin Malinois"/> Belgin Malinois <option value = "Belgian Sheepdog"/> Belgian Sheepdog <option value = "Belgian Tervuren"/> Belgian Tervuren <option value = "Bernese Mountain Dog"/> Bernese Mountain Dog <option value = "Bichon Frise"/> Bichon Frise <option value = "Black and Tan Greyhound" /> Black and Tan Greyhound <option value = "Black Russian Terrier" /> Black Russian Terrier <option value = "Bloodhoung" /> Bloodhound <option value = "Border Collie" /> Border Collie <option value = "Border Terrier"/> Border Terrier <option value = "Borzoi"/> Borzoi <option value = "Boston Terrier"/> Boston Terrier <option value = "Bouvier des Flandres"/> Bouvier des Flandres <option value = "Boxer"/> Boxer <option value = "Briard"/> Briard <option value = "Brittany" /> Brittany <option value = "Brussels Griffon" /> Brussels Griffon <option value = "Bulldog" /> Bulldog <option value = "Bullmastiff" /> Bullmasttiff <option value = "Bull Terrier" /> Bull Terrier <option value = "Cairn Terrier" /> Cairn Terrier <option value = "Canaan Dog" /> Canaan Dog <option value = "Cardigan Welsh Corgi" /> Cardigan Welsh Corgi <option value = "Cavalier King Charles Spaniel" />Cavalier King Charles Spaniel <option value = "Chesepeake Bay Retriever" />Chesapeake Bay Retriever <option value = "Chilauhua" /> Chilauhua <option value = "Chinese Created" /> Chinese Crested <option value = "Chinese Shar-Pei" /> Chinese Shar-Pei <option value = "Chow Chow" /> Chow Chow <option value = "Clumber Spaniel" /> Clumber Spaniel <option value = "Cocker Spaniel" /> Cocker Spaniel <option value = "Collie" /> Collie <option value = "Curly-Coated Retrieve" /> Curly-Coated Retriever <option value = "Dachshound" /> Dachshund <option value = "Dalmation" /> Dalmation <option value = "Dandle Dimonnt" /> Dandie Dinmont Terrier <option value = "Doberman Pincher" /> Doberman Pincher <option value = "Dogue de Bordeaux" /> Dogue de Bordeaux <option value = "English Cocker Spaniel" /> English Cocker Spaniel <option value = "English Foxhound" /> English Foxhound <option value = "English Setter" /> English Setter <option value = "English Springer" /> English Springer <option value = "English Toy Spaniel" /> English Toy Spaniel <option value = "Field Spaniel" /> Field Spaniel <option value = "Finnish Spitz" /> Finnish Spitz <option value = "Flat-Coated Retriever" /> Flat-Coated Retriever <option value = "French Bulldog" /> French Bulldog <option value = "German Shepherd Dog" /> German Shepherd Dog <option value = "German Shorthaired Pointer"/>German Shorthaired Pointer <option value = "German Wirehaired Pointer" /> German Wirehaired Pointer <option value = "Giant Schnauzer" /> Giant Schnauzer <option value = "Glen of Imaal Terrier" /> Glen of Imaal Terrier <option value = "Golden Retriever" /> Golden Retriever <option value = "Gorden Setter" /> Gorden Setter <option value = "Great Dane" /> Great Dane <option value = "Greater Swiss Mountain Dog" /> Greater Swiss Mountain Dog <option value = "Great Pyrenees" /> Great Pyrenees <option value = "Greyhound" /> Greyhound <option value = "Harrier" /> Harrier <option value = "Havanese" /> Havanese <option value = "Ibizen Hound" /> Ibizen Hound <option value = "Irish Setter" /> Irish Setter <option value = "Irish Terrier" /> Irish Terrier <option value = "Irish Water Spaniel" /> Irish Water Spaniel <option value = "Irish Wolfhound" /> Irish Wolfhound <option value = "Italian Greyhound" /> Italian Greyhound <option value = "Jack Russell Terrier" /> Jack Russell Terrier <option value = "Japanese Chin" /> Japanese Chin <option value = "Keeshound" /> Keeshound <option value = "Kerry Blue TErrier" /> Kerry Blue Terrier <option value = "Komondor" /> Komondor <option value = "Kuvasz" /> Kuvasz <option value = "Labradar Retriever" /> Labrador Retriever <option value = "Lakeland Terrier" /> Lakeland Terrier <option value = "Lhasa Apso" /> Lhasa Apso <option value = "Lowchen" /> Lowchen <option value = "Maltese" /> Maltese <option value = "Standard Manchester Terrier" /> Standard Manchester Terrier <option value = "Mastiff" /> Mastiff <option value = "Miniature Bull Terrier" /> Miniature Bull Terrier <option value = "Miniature Pinche" /> Miniature Pinscher <option value = "Miniature Poodle" /> Miniature Poodle <option value = "Miniature Schnauzer" />Miniature Schnauzer <option value = "Mutt" />Mutt <option value = "Neopolitan Mastiff" />Neopolitan Mastiff <option value = "Newfoundland " /> Newfoundland <option value = "Newfolk Terrier" />Norfolk Terrier <option value = "Norwegian Elkhound" /> Norwegian Elkhound <option value = "Norwich Terrier" /> Norwich Terrier <option value = "Nova Scotia Duck Tolling Retriever" /> Nova Scotia Duck Tolling Retriever <option value = "Old English Sheepdog" />Old English Sheepdog <option value = "Otterhound" /> Otterhound <option value = "Papillon" />Papillon <option value = "Parson Russell Terrier" /> Parson Russell Terrier <option value = "Pekingese" />Pekingese <option value = "Pembroke Welsh Corgi" />Pembroke Welsh Corgi <option value = "Petit Basset Griffon Vendeen" />Petit Basset Griffon Vendeen <option value = "Pharch Hound" />Pharoh Hound <option value = "Plott" /> Plott <option value = "Pointer" /> Pointer <option value = "Polish Lowland Sheepdog" />Polish Lowland sheepdog <option value = "Pomeranian" /> Pomeranian <option value = "Portuguese Water Dog" />Portuguese Water Dog <option value = "Pug" />Pug <option value = "Pull" />Puli <option value = "Rhodesian Ridgeback" />Rhodesian Ridgeback <option value = "Rottweiler" />Rottweiler <option value = "ASaint Bernard" /> Saint Bernard <option value = "Saluki" /> Saluki <option value = "Samoyed" />Samoyed <option value = "Schipperke" />Schipperke <option value = "Scottish Doverhound" />Scottish Deerhound <option value = "Scottish Terrier" />Scottish Terrier <option value = "Sealyham Terrier" />Sealyham Terrier <option value = "Shetland Sheepdog" />Shetland Sheepdog <option value = "Shiba Inu" />Shiba Inu <option value = "Shih Tzu" />Shih Tzu <option value = "Siberian Husky" />Siberian Husky <option value = "Silky Terrier" />Silky Terrier <option value = "Skye Terrier" />Skye Terrier <option value = "Smooth Fox Terrier" />Smooth Fox Terrier <option value = "Soft Coated Wheaten Terrier" />Soft Coated wheaten Terrier <option value = "Spinone Italiano" />Spinone Italiano <option value = "Staffordshire Bull Terrier" />Staffordshire Bull Terrier <option value = "Standard Poodle" />Standard Poodle <option value = "Standard Schnauer" /> Standard Schnauzer <option value = "Suseex Spaniel" />Sussex Spaniel <option value = "Swedish Vallhound" />Swedish Vallhund <option value = "Tibertan Mastiff" />Tibetan Mastiff <option value = "Tibertan Spaniel" />Tibetan Spaniel <option value = "Tibetan Terrier" />Tibetan Terrier <option value = "Toy Fox Terrier" />Toy Fox Terrier <option value = "Toy Manchester Terrier" />Toy Manchester Terrier <option value = "Toy Poodle" />Toy Poodle <option value = "Vizela" />Vizela <option value = "Weimaraner" />Weimaraner <option value = "Welsh Springer Spaniel" />Welsh Springer Spaniel <option value = "Welsh Terrier" />Welsh Terrier <option value = "West Highland White Terrier" />West Highland White Terrier <option value = "Whippet" />Whippet <option value = "Wire Fox Terrier" />Wire Fox Terrier <option value = "Wirehaired Pointing Griffon" />Wirehaired Pointing Griffon <option value = "Yorkshire Terrier" />Yorkshire Terrier </td> </select> </tr> <tr> <td>Nutritional Needs:</td> <td><textarea name="nutritionalNeeds" cols="17" rows="5"></textarea> </td> </tr> <tr> <td>Special Instructions</td> <td><textarea name="specialInstructions" cols="17" rows="5"></textarea> </tr> <tr> <td colspan = "6"><h2>Order Information</h2></td> </tr> <tr> HEREDOC; <?php /*foreach($key as $value){ echo $value; }*/ ?> echo <<<HEREDOC </tr> <tr> <td> <input name="Submit" type="submit" value="Order Treats!" /></td><td><input name="reset" type="submit" value="Cancel Order" /> </td> </tr> </table> </form> HEREDOC; <?php } } footer(); ?> </body> </html> Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>"; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END This shows all my subforums on my forum, but 1 problem, if I try to seperate them, like let's say with a "comma" by using: Code: [Select] //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END It will show the , BEFORE the link? so weird, here is the function: Code: [Select] $forum_data['subforums'] = "<br> <span class=desc4>Subforums:</span> "; foreach($this->children[ $forum_data['id'] ] as $idx => $data) { //-------------------------------------- // Check permissions... //-------------------------------------- if ( $std->check_perms($data['read_perms']) != TRUE ) { continue; } // Do the news stuff first if (isset($data['last_title']) and $data['last_id'] != "") { if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) ) { $this->news_topic_id = $data['last_id']; $this->news_forum_id = $data['id']; $this->news_title = $data['last_title']; } } if ($data['last_post'] > $newest['last_post']) { //Subforum last_title? $newest['last_post'] = $data['last_post']; $newest['fid'] = $data['id']; //$newest['id'] = $data['id']; $newest['last_id'] = $data['last_id']; $newest['last_title'] = $data['last_title']; $newest['password'] = $data['password']; $newest['last_poster_id'] = $data['last_poster_id']; $newest['last_poster_name'] = $data['last_poster_name']; $newest['status'] = $data['status']; $newest['star'] = $data['star']; } $newest['posts'] += $data['posts']; $newest['topics'] += $data['topics']; $printed_children++; //mod_KaLiTe_Subforums BEGIN $forum_data['subforums'] .= "<a href=?z={$data[id]}>, "; $forum_data['subforums'] .= $data['name']; $forum_data['subforums'] .= "</a>"; //mod_KaLiTe_Subforums END } How can I make it so it doesn't show the , before the FIRST link on that subforums variable, but only after every link and beyond? Okay I got it working by moving it ontop Code: [Select] $forum_data['subforums'] .= "<a href=?z={$data[id]}>{$data['name']}</a>, "; //mod_KaLiTe_Subforums END $printed_children++; but now it shows the , after the last link, how do I make it so it doesn't show the comma for the last child? Hi I'm trying to do a php website using notepad++ but when I save it and I test it out on a web browser it gives me my coding instead of a form. How do I fix this. Thank you |