[PHP] Re: mysql problem- I know it isn't strictly php
That last line always causes me problems, I think it is probably a difference in versions of mysql. Just change the last line to: ); without any of the text in their. It doesn't really do much anyway. Ross wrote: Hi all, I am trying to create a table on the remote server but it never seems to work CREATE TABLE `sheet1` ( `id` int(10) NOT NULL auto_increment, `title` varchar(255) NOT NULL default '', `fname` varchar(255) NOT NULL default '', `sname` varchar(255) default NULL, `job_title` varchar(255) default NULL, `organisation` varchar(255) default NULL, `email` varchar(255) default NULL, `street` varchar(255) default NULL, `city` varchar(255) default NULL, `postcode` varchar(255) default NULL, `office_tel` varchar(255) default NULL, `mobile` varchar(255) default NULL, `fax` varchar(255) default NULL, `web` varchar(255) default NULL, `add_info` varchar(255) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=303 ; There seems to be a problem with the last line (this is exported from my local server). I am just learning about mySql as I go so have no real clue about CHARSET and ENGINE (which I believe may be the problem) This is the error 1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARSET=latin1 AUTO_INCREMENT=303' at line 18 and this is what the manual says (not very helpful) a.. Error: 1064 SQLSTATE: 42000 (ER_PARSE_ERROR) Message: %s near '%s' at line %d Any help will be appreciated. R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: [mysql]Problem with PHP5
Ciprian, I may have missed whether or not you were able to resolve your problem from a couple days ago. In one of my development environments (Win2K), I decided to install PHP 5.0 with MySQL(i) 4.1.x support in IIS5.0 and Apache 2 (running on different ports). It took a bit more work than I intended, but here's what I did: FOR IIS (port 80): 1. downloaded and unzipped php-5.0.0-Win32.zip to c:\php 2. installed php as ISAPI 3. edited php-ini-recommended, tailored it to my environment, and copied it as php.ini into c:\winnt NOTE: extension_dir = c:\php\ext 4. tested phpinfo() without extensions 5. edited php.ini enabling needed extensions. NOTE: when uncommenting the line: extension=mysql.dll, changed line to read: extension=mysqli.dll 6. downloaded and unzipped mysql-4.1.3b-beta-win-noinstall.zip to c:\ 7. configured mysql per www.mysql.com install instructions 8. copied c:\mysql\bin\libmysql.dll to c:\winnt\system32 9. restarted IIS, and IIS started successfully, 10. reloaded phpinfo(), and noticed that mysqli was properly loaded, but now my old mysql_connect_db scripts don't work! Refer to the new mysqli PHP code: http://us3.php.net/manual/en/ref.mysqli.php 11. Here's a VERY basic example of the old mysql VS. new mysqli PHP code: OLD mysql: ?php // connect to the database mysql_connect(localhost, wong, password) or die (Could not connect to mySQL server); // select the database mysql_select_db(music) or die (Could not connect to database); // store result $result = mysql_query(SELECT * FROM artists) or die (mysql_error()); // display returned results while ($row = mysql_fetch_array($result)) { echo $row[artist], nbsp;nbsp;, $row[album]; echo BR /; } // free result mysql_free_result($result); ? NEW mysqli: ?php // connect to the database $link = mysqli_connect(localhost, wong, password, music); // check connection if (mysqli_connect_errno()) { printf(Connect failed: %s\n, mysqli_connect_error()); exit(); } // store query $query = SELECT * FROM artists; // store result $result = mysqli_query($link, $query); // loop thru rows using associative array while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo $row[artist], nbsp;nbsp;, $row[album]; echo BR /; } // free the result mysqli_free_result($result); // close the link mysqli_close($link); ? Additionally, for Apache 2 on Win2k (running on port 82): 1. Copied php.ini to c:\Apache Groups\Apache2 2. edited httpd.conf: - added LoadModule php5_module c:/php/php5apache2.dll - added AddType application/x-httpd-php .php 3. Restarted Apache server Hopes this helps. Dan Ciprian Constantinescu wrote: I have included the extension. Now I get Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified procedure could not be found I have in Windows\System32 the file libmysql.dll. I have also put it in the php\ext directory without any result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [mysql]Problem with PHP5
I have included the extension. Now I get Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified procedure could not be found I have in Windows\System32 the file libmysql.dll. I have also put it in the php\ext directory without any result. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [mysql]Problem with PHP5
Ciprian Constantinescu wrote: I have installed PHP5 and i get the following error from a script that was working on PHP4 Fatal error: Call to undefined function mysql_pconnect() in D:\htdocs\cdalex\Connections\listacon.php on line 9 MySQL is no longer embedded in PHP, as of PHP 5. Depending on your platform, you will either need to build PHP 5 with support for MySQL, or you will need to modify php.ini to load in the MySQL extension. -- Regards, Ben Ramsey http://benramsey.com --- http://www.phpcommunity.org/ Open Source, Open Community Visit for more information or to join the movement. --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Mysql Problem
Ian Barnes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I am generating a mysql statement and then printing it to a formatted field. Here is my code: $sql=SELECT * from tablename where name in ('Web','HTML','PHP') group by name; You are missing the closing quote here! Please set your error reporting to E_ALL while developing: ini_set('error_reporting', E_ALL); Regards, Torsten Roehr $mysql_rslt1 = mysql_query($sql, $mysql_bconn) or die (Could not get data); while ($rec1 = mysql_fetch_array ($mysql_rslt1)) { echo some stuff here; } Now the problem is it will leave out the last line of the reply. So it would leave out the 'PHP' line for the query above. Always the last line, and if for some reason i only have 1 in my query, it displays nothing, although if I do it manually using the mysql prompt, it works fine, and i get back the info I want. All the other lines format properly and the info is correct, just the last line doesnt display. Any ideas ? Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Mysql Problem
Hi, Yes that was my mistake. But even with the code, it still doesnt display the last one. If i didnt put a it wouldnt work at all. Thanks, Ian -Original Message- From: Torsten Roehr [mailto:[EMAIL PROTECTED] Sent: 28 May 2004 13:56 To: [EMAIL PROTECTED] Subject: [PHP] Re: Mysql Problem Ian Barnes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I am generating a mysql statement and then printing it to a formatted field. Here is my code: $sql=SELECT * from tablename where name in ('Web','HTML','PHP') group by name; You are missing the closing quote here! Please set your error reporting to E_ALL while developing: ini_set('error_reporting', E_ALL); Regards, Torsten Roehr $mysql_rslt1 = mysql_query($sql, $mysql_bconn) or die (Could not get data); while ($rec1 = mysql_fetch_array ($mysql_rslt1)) { echo some stuff here; } Now the problem is it will leave out the last line of the reply. So it would leave out the 'PHP' line for the query above. Always the last line, and if for some reason i only have 1 in my query, it displays nothing, although if I do it manually using the mysql prompt, it works fine, and i get back the info I want. All the other lines format properly and the info is correct, just the last line doesnt display. Any ideas ? Ian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL Problem
What's up Supposing that the filename of the you code is create_table.php. Try tipping in the URL: create_table.php?nueva_base=prueba EF. --- Que tal Suponiendo que el archivo del codigo se llama create_table.php. Prueba poniendo el la URL: create_table.php?nueva_base=prueba EF. Felipe R. [EMAIL PROTECTED] escribió en el mensaje news:[EMAIL PROTECTED] Hi everyone, first, sorry to all if my english is so poor. second, i have the follow question: when i create a existing MySQL DBase, what happend?? how can i avoid this problem?? i attached my create_table code. Thanks for all html head titleCreación de una Base de Datos/title /head body h2 Creando Base de Datos/h2 ?php $connection = mysql_connect(localhost,ferios,ferios) or die (No se puede conectar a MySQL); if (!$connection) { die (No se puede conectar a MySQL); } if (mysql_create_db($nueva_base)) { print (nbspnbspnbspnbsp Base de Datos font color=\red\ size=\5\$nueva_base/font Creada Satisfactoriamente!!BRBR); $db_list = mysql_list_dbs($connection); $indice=0; while($row = mysql_fetch_array($db_list)){ $bases[$indice]=$row[0]; $indice++; } mysql_close($connection); echo nbspnbspnbspnbspB Las Bases de Datos Disponibles son: /BBR; for($aux = 0; $aux $indice; $aux++) { echo nbspnbspnbspnbspnbspnbspnbspnbsp $bases[$aux]BR; } }else{ print (Ërror Creando la Base de Datos: . mysql_error()); } ? font size=3 pVolver a a href=http://localhost/administrador.htm;Administrador de Bases de Datos/a/font font size=3 pVolver a a href=http://localhost/nueva_base.htm;Crear un Base de Datos/a/font /body /html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL Problem
You know...maybe I should mention where this code is... I have my main file which loads using 'require.once' a second file called 'everything.php'. Inside everything.php is a class called 'mainclass' which is called by the mail file. This class ('mainclass') loads the MySQL class from the previous post which is stored in yet another file, using require.once. MainClass then calls the MySQL-CONNECT and MySQL-CHOOSEDB functions. I know this sounds a bit over the top, but it works...at least it did...until now. I thought I'd mention the circumstances in case that makes a difference, which I suspect it will. Thanks again! Lewis Orangehairedboy [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi everyone! I can't figure out why this doesn't work. The call to the CONNECT function works and it connects with no problem, and it does save the Resource ID in $this-DBLink[]...however, when CHOOSEDB is called, the Resource ID just saved is gone. $this-DBLink is just empty, and I can't figure out why... Can anyone offer insight on this one? class MySQL { var $DBLink = array(); function CONNECT ( $MyVars , $MyContents ) { $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . : . $MyVars[PORT] : $MyVars[HOST]; $this-DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); } function CHOOSEDB ( $MyVars , $MyContents ) { mysql_select_db( $MyVars[DATABASE] , $this-DBLink[$MyVars[LINK]] ); } } Thanks! Lewis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
Hi, Thursday, October 3, 2002, 6:01:53 PM, you wrote: O You know...maybe I should mention where this code is... O I have my main file which loads using 'require.once' a second file called O 'everything.php'. O Inside everything.php is a class called 'mainclass' which is called by the O mail file. O This class ('mainclass') loads the MySQL class from the previous post which O is stored in yet another file, using require.once. O MainClass then calls the MySQL-CONNECT and MySQL-CHOOSEDB functions. O I know this sounds a bit over the top, but it works...at least it O did...until now. I thought I'd mention the circumstances in case that makes O a difference, which I suspect it will. O Thanks again! O Lewis O Orangehairedboy [EMAIL PROTECTED] wrote in message O [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi everyone! I can't figure out why this doesn't work. The call to the CONNECT function works and it connects with no problem, and it does save O the Resource ID in $this-DBLink[]...however, when CHOOSEDB is called, the Resource ID just saved is gone. $this-DBLink is just empty, and I can't figure out why... Can anyone offer insight on this one? class MySQL { var $DBLink = array(); function CONNECT ( $MyVars , $MyContents ) { $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . : . $MyVars[PORT] : $MyVars[HOST]; $this-DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); } function CHOOSEDB ( $MyVars , $MyContents ) { mysql_select_db( $MyVars[DATABASE] , $this-DBLink[$MyVars[LINK]] ); } } Thanks! Lewis Looks like you change the name of the index from NAME to LINK and it should be $this-DBLink[$MyVars['LINK']] -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
I thought someone might mention that, but that is actually correct. The problem is that the variable assigned on the line $this-DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); dissapears and can't be retreived on the line mysql_select_db( $MyVars[DATABASE] , $this-DBLink[$MyVars[LINK]] );. For instance, if the first line saves $this-DBLink[TEST], when CHOOSEDB is called, the command PRINT $this-DBLink[TEST] will print nothing when the same line right after the variable is saved would produce something like Resource ID #38. That's the brain twister. Thanks though! ::Lewis Tom Rogers [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, Thursday, October 3, 2002, 6:01:53 PM, you wrote: O You know...maybe I should mention where this code is... O I have my main file which loads using 'require.once' a second file called O 'everything.php'. O Inside everything.php is a class called 'mainclass' which is called by the O mail file. O This class ('mainclass') loads the MySQL class from the previous post which O is stored in yet another file, using require.once. O MainClass then calls the MySQL-CONNECT and MySQL-CHOOSEDB functions. O I know this sounds a bit over the top, but it works...at least it O did...until now. I thought I'd mention the circumstances in case that makes O a difference, which I suspect it will. O Thanks again! O Lewis O Orangehairedboy [EMAIL PROTECTED] wrote in message O [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi everyone! I can't figure out why this doesn't work. The call to the CONNECT function works and it connects with no problem, and it does save O the Resource ID in $this-DBLink[]...however, when CHOOSEDB is called, the Resource ID just saved is gone. $this-DBLink is just empty, and I can't figure out why... Can anyone offer insight on this one? class MySQL { var $DBLink = array(); function CONNECT ( $MyVars , $MyContents ) { $host = ( $MyVars[PORT] ) ? $MyVars[HOST] . : . $MyVars[PORT] : $MyVars[HOST]; $this-DBLink[$MyVars[NAME]] = mysql_connect( $MyVars[HOST] , $MyVars[USERNAME] , $MyVars[PASSWORD] ); } function CHOOSEDB ( $MyVars , $MyContents ) { mysql_select_db( $MyVars[DATABASE] , $this-DBLink[$MyVars[LINK]] ); } } Thanks! Lewis Looks like you change the name of the index from NAME to LINK and it should be $this-DBLink[$MyVars['LINK']] -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL Problem
Here's a simplier version...and I'm still having a problem with it. It's driving me insane!!! :) class MySQL { function SET ( ) { $this-MYVAR = Hello World!; } function RETREIVE ( ) { print $this-MYVAR; } } $helpme = new MySQL; $helpme-SET; $helpme-RETREIVE; /* Prints NOTHING */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL Problem
-Original Message- From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]] Sent: 03 October 2002 09:39 Here's a simplier version...and I'm still having a problem with it. It's driving me insane!!! :) class MySQL { function SET ( ) { $this-MYVAR = Hello World!; } function RETREIVE ( ) { print $this-MYVAR; } } $helpme = new MySQL; $helpme-SET; $helpme-RETREIVE; /* Prints NOTHING */ I'm pretty sure you have to add () on the end of those function names to get PHP to actually *call* the function, so you need: $helpme-SET(); $helpme-RETREIVE(); Without the parentheses, PHP evaluates the name of the function (returning its handle), but then doesn't know what to do with it so just throws it away on seeing the terminating semicolon. As far as PHP is concerned, you could quite legitimately want to do something entirely different with the handle, such as assigning it to a variable -- PHP won't assume you want to call it as a function just because it happens to be a function name. For instance, the following should work (I think! - although I haven't tested it): $method = $helpme-SET; $method(); In fact, you can ask PHP to try and call anything as a function by appending parentheses, so this should work too: $method = SET; $helpme-$method(); Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem
Well, that's just a typo...of course there should be a () to make it call a function... The whole point to my postings is that I can't get the darn variable to stay in place!!! Look where it says Prints NOTHING. Does anyone know why it doesn't print Hello World??? ::Lewis Mike Ford [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... -Original Message- From: OrangeHairedBoy [mailto:[EMAIL PROTECTED]] Sent: 03 October 2002 09:39 Here's a simplier version...and I'm still having a problem with it. It's driving me insane!!! :) class MySQL { function SET ( ) { $this-MYVAR = Hello World!; } function RETREIVE ( ) { print $this-MYVAR; } } $helpme = new MySQL; $helpme-SET; $helpme-RETREIVE; /* Prints NOTHING */ I'm pretty sure you have to add () on the end of those function names to get PHP to actually *call* the function, so you need: $helpme-SET(); $helpme-RETREIVE(); Without the parentheses, PHP evaluates the name of the function (returning its handle), but then doesn't know what to do with it so just throws it away on seeing the terminating semicolon. As far as PHP is concerned, you could quite legitimately want to do something entirely different with the handle, such as assigning it to a variable -- PHP won't assume you want to call it as a function just because it happens to be a function name. For instance, the following should work (I think! - although I haven't tested it): $method = $helpme-SET; $method(); In fact, you can ask PHP to try and call anything as a function by appending parentheses, so this should work too: $method = SET; $helpme-$method(); Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL Problem with PHP
In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... I am using PHP and MySQL on a 2k dev box to be uploaded to a linux box I have a piece of SQL INSERT INTO `contracts` (`key`, `content`) VALUES (1,'blah blah blah character 39 is a single speach mark '+CHAR(39)+' blah blah blah') Instead of inserting: 'blah blah blah character 39 is a single speach mark ' blah blah blah It inserts 0 All variations work fine when there is no single speachies help? Look into addslashes and the various magic_quotes settings in you r php.ini. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL Problem with PHP
I just preg_replace(/\'/,\',$text) and all was good :o) David Robley [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... In article [EMAIL PROTECTED], [EMAIL PROTECTED] says... I am using PHP and MySQL on a 2k dev box to be uploaded to a linux box I have a piece of SQL INSERT INTO `contracts` (`key`, `content`) VALUES (1,'blah blah blah character 39 is a single speach mark '+CHAR(39)+' blah blah blah') Instead of inserting: 'blah blah blah character 39 is a single speach mark ' blah blah blah It inserts 0 All variations work fine when there is no single speachies help? Look into addslashes and the various magic_quotes settings in you r php.ini. -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: MySQL Problem with PHP
I just preg_replace(/\'/,\',$text) and all was good :o) That's what addslashes() is for. It handles single and double quotes, backslashes, and nulls, so you won't have any problems... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: MySQL Problem with PHP
On Wednesday, June 26, 2002, at 08:58 AM, John Holmes wrote: I just preg_replace(/\'/,\',$text) and all was good :o) That's what addslashes() is for. It handles single and double quotes, backslashes, and nulls, so you won't have any problems... Plus IIRC it's a C extension so it'll run faster anyway. Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php