Mysqli – Conexiunea la baza de date

Stefanescu Mihai 2 years ago PHP
Acest articol face parte din cursul Toate lectiile PHP. Te poti inscrie la acest curs aici!

Pentru a ne conecta la baza de date MySqli (MySql improved) ne pune la dispozitie doua metode, una procedurala si una oprientata pe obiecte.


Avem urmatoarea sintaxa:

$link = mysqli_connect("host","user","parola","baza_de_date") or die("Eroare: " . mysqli_error($link));

 Orientat pe obiecte

Avem urmatoarea sintaxa:

$mysqli = new mysqli("host", "user", "parola", "baza_de_date");
if ($mysqli->connect_errno) {
    echo "Nu ma pot conecta: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

Avem urmatorii parametri:

Parametru Descriere
host Host-ul pe care ruleaza baza de date.In mod default este localhost si portul este 3306
user User-ul care are acces la baza de date.
parola Parola userului care are acces la baza de date.
baza_de_date Baza de date la care dorim sa ne conectam.

Inchiderea conexiunii

Avem o functie ce ne ajuta sa inchidem conexiunea la baza de date. Aceasta functie are nevoie de un parametru resource (conexiunea la baza de date). Returneaza true in cazul in care a inchis conexiunea altfel returneaza false.


sau in stilul orientat pe obiecte



Programator de ~8 ani, am lucrat la proiecte din mai multe industrstrii, de la eCommerce la telecomunicatii la automatizari. In acest timp am folosi diferite tehnologii, de la PHP, MySQL, PostgreSql, RabbitMq, Redis, Memcached si altele.

Get in touch
Pentru nelamuriri, dubii, comentarii si chestii de pe suflet ne putem auzi pe Discord, Reddit sau poti deschide o discutie noua pe forum

Buy clomiphene citrate online # 6 months ago Hello there! Would you mind if I share your blog with my facebook group? There's a lot of people that I think would really enjoy your content. Please let me know. Thanks
Electrolyte Supplement # 5 months ago Can you tell us more about this? I'd like to find out some additional information.
tips for unemployed individuals # 5 months ago I have been exploring for a little for any high quality articles or blog posts in this kind of space . Exploring in Yahoo I eventually stumbled upon this web site. Studying this information So i am glad to exhibit that I've a very good uncanny feeling I found out exactly what I needed. I most indisputably will make sure to do not forget this website and provides it a glance regularly.
Sanford Morrow # 5 months ago Heya i'm for the first time here. I found this board and I to find It really useful & it helped me out a lot. I'm hoping to offer one thing back and aid others like you aided me.
Luke # 2 months ago Peculiar article, just what I was looking for.
cetirizine disponible sur ordonnance # 1 month ago I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an edginess over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this increase.
puedo comprar amoxicilline 500 mg sin receta en Colombia # 1 month ago Good respond in return of this query with genuine arguments and describing everything on the topic of that.
ansial sin receta en Bélgica # 1 month ago constantly i used to read smaller content which as well clear their motive, and that is also happening with this article which I am reading here.
cipro disponible sin receta en farmacia de Perú # 1 month ago It's actually a nice and useful piece of information. I am satisfied that you just shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
Dqrokq # 1 month ago order fenofibrate pill <a href="">tricor price</a> tricor 160mg over the counter
erbitrax à commander en ligne # 1 month ago I go to see everyday a few web sites and websites to read articles, however this blog provides feature based content.
Qzdxcf # 1 month ago buy zaditor 1mg online cheap <a href="">ziprasidone pills</a> how to get tofranil without a prescription
Wfcdpc # 1 month ago order minoxytop solution <a href="">cheap flomax 0.4mg</a> the best ed pill
Kesbhf # 1 month ago precose tablet <a href="">pill griseofulvin</a> how to buy griseofulvin
Scdmqi # 1 month ago buy cheap generic aspirin <a href="">aspirin over the counter</a> brand imiquad
Rosaura # 4 weeks ago Excellent post. I was checking constantly this blog and I am impressed! Extremely useful info specially the last part :) I care for such information a lot. I was seeking this certain info for a long time. Thank you and best of luck.
Llhact # 3 weeks ago buy dydrogesterone sale <a href="">buy empagliflozin without a prescription</a> jardiance 10mg ca
Louvenia # 3 weeks ago Woah! I'm really digging the template/theme of this blog. It's simple, yet effective. A lot of times it's challenging to get that "perfect balance" between user friendliness and visual appeal. I must say you've done a fantastic job with this. Also, the blog loads extremely quick for me on Opera. Exceptional Blog!
Kent # 3 weeks ago With havin so much content do you ever run into any issues of plagorism or copyright infringement? My website has a lot of completely unique content I've either created myself or outsourced but it seems a lot of it is popping it up all over the web without my authorization. Do you know any ways to help reduce content from being ripped off? I'd definitely appreciate it.
Kcrtyw # 3 weeks ago pill fludrocortisone <a href="">buy florinef 100 mcg generic</a> imodium online
Ffetid # 3 weeks ago order monograph pills <a href="">cheap colospa 135mg</a> cilostazol for sale online
Ihlnrj # 2 weeks ago prasugrel 10mg uk <a href="">buy dimenhydrinate without prescription</a> tolterodine cost
Iiufpz # 2 weeks ago mestinon canada <a href="">cheap pyridostigmine 60mg</a> order maxalt 10mg
Telynp # 2 weeks ago buy ferrous sulfate 100mg sale <a href="">buy ferrous online cheap</a> buy betapace 40 mg generic
Nydia # 2 weeks ago Asking questions are really good thing if you are not understanding something entirely, except this paragraph presents pleasant understanding yet.
Laydcg # 2 weeks ago where can i buy vasotec <a href="">purchase doxazosin for sale</a> duphalac buy online
Qfrlps # 1 week ago xalatan usa <a href="">buy xalatan online cheap</a> exelon order
Xljqar # 1 week ago order betahistine without prescription <a href="">betahistine generic</a> buy probenecid 500mg without prescription
Fgifbc # 1 week ago micardis 20mg cheap <a href="">buy micardis 80mg for sale</a> order molnunat 200 mg pill
Obtmks # 5 days ago order cenforce 50mg without prescription <a href="">naproxen 500mg pills</a> chloroquine brand
Opmnya # 2 days ago omnicef pills <a href="">omnicef 300mg without prescription</a> buy lansoprazole 30mg
Club-ul este dedicat membrilor si ofera access la mai multe zone ale website-ului.
Login Register

🔖 Bookmarks
✨ Pentru a sustine aceasta comunitate am sa te rog sa te autentifici sau sa te inregistrezi!

🌪️ Discord
Back to top
Folosim cookie-uri pentru a oferi functionalitatile critice ale aplicatiei Invata-Programare. Folosim cookie-uri si pentru a analiza traficul, pentru care e nevoie de consimtamantul dvs. explicit.