Re: [PHP-DB] mysql_insert_id() and JOIN
> Sorry my question... but why I must use JOIN if I can use SELECT * FROM > table1 AND table2 AND table3 WHERE table1.id=table2.id=table3 not? > thanks You can not use that syntax on MySQL (at least not on v5.0 or v5.1, I do not know about earlier versions). >// Emiliano Boragina _ >// Diseño & Comunicación // -- Niel Archer niel.archer (at) blueyonder.co.uk -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] A prepared statements question
>> >> [Redirected to PHP-DB: php...@lists.php.net] >> >> >> On Sun, Jul 12, 2009 at 00:31, Jason Carson wrote: >> > Hello everyone, >> > >> > I am having a problem getting my prepared statements working. Here is >> my >> > setup... >> > >> > index.php -> authenticate.php -> admin.php >> > >> > 1)index.php has a login form on it so when someone enters their >> username >> > the form redirects to another page I call authenticate.php. >> > >> > 2)In the authenticate.php file I want to use prepared statements to >> > interact with the MySQL database. I want to compare the username >> submitted >> > from the form with the username in the database. >> > >> > 3)If the login username was legitimate then you are forwarded to >> admin.php >> > >> > Its step 2 I am having problems with. Here is what I have but I don't >> > think it makes any sense and it doesn't work. >> > >> > >> > $link = mysqli_connect($hostname, $dbusername, $password, $database); >> > $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE >> > adminusers=?"); >> > mysqli_stmt_bind_param($stmt, 's', $username); >> > $result = mysqli_stmt_execute($stmt); >> > >> > $count=mysqli_num_rows($result); >> > >> > if($count==1){ >> > header("location:admin.php"); >> > } else { >> > echo "Failure"; >> > } >> > >> > Any help is appreciated. > > The main problem is you are not testing your results. With that code > you do not even know if you have a connection or not. I'd say there is > a good chance you do not have error reporting enabled or you would have > picked up the error straight away. > > mysqli_stmt_execute returns a boolean indicating success or failure. > You are trying to use it as a result set, which will not work. Replace: > > $count=mysqli_num_rows($result); > > with: > > mysqli_stmt_store_result($stmt); > $count = mysqli_stmt_num_rows($stmt); > >> >> -- >> >> daniel.br...@parasane.net || danbr...@php.net >> http://www.parasane.net/ || http://www.pilotpig.net/ >> Check out our great hosting and dedicated server deals at >> http://twitter.com/pilotpig >> >> -- >> PHP Database Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- > Niel Archer > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > That did it, everything is working now. Thank you very much :-) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql_insert_id() and JOIN
Sorry my question... but why I must use JOIN if I can use SELECT * FROM table1 AND table2 AND table3 WHERE table1.id=table2.id=table3 not? thanks + _ // Emiliano Boragina _ // Diseño & Comunicación // + _ // emiliano.borag...@gmail.com / // 15 40 58 60 02 /// + _ -Mensaje original- De: Emiliano Boragina [mailto:emiliano.borag...@gmail.com] Enviado el: Sábado, 11 de Julio de 2009 11:08 a.m. Para: 'php-db@lists.php.net' Asunto: RE: [PHP-DB] mysql_insert_id() and JOIN > Hi again > > I dont understand how to use this two > > I read php.net and other sites, but dont understand... http://dev.mysql.com/doc/ Available in the major languages, pick your filter and start reading. Having documentation in your own language may help a lot towards understanding. > I have this four tables: table1, 2, 3 and 4 > > So the SELECT is like this?: > > > $query_select = "SELECT * FROM table1 FULL JOIN table2 FULL JOIN table3 FULL > JOIN table4 ON table1.id=table2.id=table3.id=table4.id ORDER BY id ASC; > > mysql_query($query_select); > > ?> > > This is with FULL JOIN... How identificate the left table if I want to use > LEFT JOIN? The left table is the table to the left of the join. So: SELECT id FROM table1 LEFT JOIN table2... table1 is the left table and table2 is the right table (if you were to use a RIGHT JOIN). >> With my 4 tables the sql is like this?: >> SELECT * FROM table1 LEFT JOIN table2 LEFT JOIN table3 LEFT JOIN table4 WHERE table1.id = table2.id = table3.id = table4.id > > How is the UPDATE? > > And the INSERT I dont understand yet how is it? UPDATEs and INSERTs follow the same procedure. When you INSERT an entry into the main table, you then use the function mysql_insert_id() which will give you the value of the last 'id' column generated, which you can then use to insert data into the secondary tables. >> How is the the slq query with "mysql_insert_id()"? > > Im not to do a link between tables in PHPMyAdmin? > > > > Thank you very... VERY... much! > If you are using MySQL 4.1 or later you should use the mysqli extension and not the older mysql one. UNLESS you are relying on the older style passwords, which is a BAD idea. >> I dont know what version I use =S >> THANKS A LOT NEIL -- Niel Archer -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] resize 10 upload image
No, I don't =S + _ // Emiliano Boragina _ // Diseño & Comunicación // + _ // emiliano.borag...@gmail.com / // 15 40 58 60 02 /// + _ -Mensaje original- De: Phpster [mailto:phps...@gmail.com] Enviado el: Sábado, 11 de Julio de 2009 11:13 a.m. Para: Emiliano Boragina CC: Asunto: Re: [PHP-DB] resize 10 upload image On Jul 10, 2009, at 10:18 PM, "Emiliano Boragina" wrote: > Hi again > > How do I do to resize more than one image when I upload using php > and not > any library like the gd > > I have this: > > > > $folder="../products"; > > copy($_FILES['5']['tmp_name'],$folder.'/'.$_FILES['5']['name']); > > $picture5=$_FILES['5']['name']; > > copy($_FILES['6']['tmp_name'],$folder.'/'.$_FILES['6']['name']); > > $picture5=$_FILES['6']['name']; > > . > > . > > . > > > > thanks > > > > + > > _ > // Emiliano Boragina _ > // Diseño & Comunicación // > + > > _ > // emiliano.borag...@gmail.com / > // 15 40 58 60 02 /// > + > > _ > > > How do you expect to resize an image without using gd, do you have imagemagik installed? Bastien Sent from my iPod= -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] A prepared statements question
> > [Redirected to PHP-DB: php...@lists.php.net] > > > On Sun, Jul 12, 2009 at 00:31, Jason Carson wrote: > > Hello everyone, > > > > I am having a problem getting my prepared statements working. Here is my > > setup... > > > > index.php -> authenticate.php -> admin.php > > > > 1)index.php has a login form on it so when someone enters their username > > the form redirects to another page I call authenticate.php. > > > > 2)In the authenticate.php file I want to use prepared statements to > > interact with the MySQL database. I want to compare the username submitted > > from the form with the username in the database. > > > > 3)If the login username was legitimate then you are forwarded to admin.php > > > > Its step 2 I am having problems with. Here is what I have but I don't > > think it makes any sense and it doesn't work. > > > > > > $link = mysqli_connect($hostname, $dbusername, $password, $database); > > $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE > > adminusers=?"); > > mysqli_stmt_bind_param($stmt, 's', $username); > > $result = mysqli_stmt_execute($stmt); > > > > $count=mysqli_num_rows($result); > > > > if($count==1){ > > header("location:admin.php"); > > } else { > > echo "Failure"; > > } > > > > Any help is appreciated. The main problem is you are not testing your results. With that code you do not even know if you have a connection or not. I'd say there is a good chance you do not have error reporting enabled or you would have picked up the error straight away. mysqli_stmt_execute returns a boolean indicating success or failure. You are trying to use it as a result set, which will not work. Replace: $count=mysqli_num_rows($result); with: mysqli_stmt_store_result($stmt); $count = mysqli_stmt_num_rows($stmt); > > -- > > daniel.br...@parasane.net || danbr...@php.net > http://www.parasane.net/ || http://www.pilotpig.net/ > Check out our great hosting and dedicated server deals at > http://twitter.com/pilotpig > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Niel Archer -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: [PHP] A prepared statements question
Why don't using consider using PDO for this purpose? Examples can be found here: http://au.php.net/manual/en/pdo.prepare.php On Sun, Jul 12, 2009 at 2:52 PM, Daniel Brown wrote: >[Redirected to PHP-DB: php...@lists.php.net] > > > On Sun, Jul 12, 2009 at 00:31, Jason Carson wrote: > > Hello everyone, > > > > I am having a problem getting my prepared statements working. Here is my > > setup... > > > >index.php -> authenticate.php -> admin.php > > > > 1)index.php has a login form on it so when someone enters their username > > the form redirects to another page I call authenticate.php. > > > > 2)In the authenticate.php file I want to use prepared statements to > > interact with the MySQL database. I want to compare the username > submitted > > from the form with the username in the database. > > > > 3)If the login username was legitimate then you are forwarded to > admin.php > > > > Its step 2 I am having problems with. Here is what I have but I don't > > think it makes any sense and it doesn't work. > > > > > > $link = mysqli_connect($hostname, $dbusername, $password, $database); > > $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE > > adminusers=?"); > > mysqli_stmt_bind_param($stmt, 's', $username); > > $result = mysqli_stmt_execute($stmt); > > > > $count=mysqli_num_rows($result); > > > > if($count==1){ > > header("location:admin.php"); > > } else { > > echo "Failure"; > > } > > > > Any help is appreciated. > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > > daniel.br...@parasane.net || danbr...@php.net > http://www.parasane.net/ || http://www.pilotpig.net/ > Check out our great hosting and dedicated server deals at > http://twitter.com/pilotpig > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >