[PHP] What am I doing wrong?
I can't seem to understand PHP error trapping...I have it turned on in php.ini, and on the page in question, I have error_reporting(E_ALL); on the page in question below - the following code does NOT generate any errors, but it doesn't perform the insert eitherthe stored procedure exists, but even if I purposely misspell the stored procedure name, no errors are raised...any advice? ?php error_reporting(E_ALL); //submit the request //write entry into database $fname = $_POST[fname]; $lname = $_POST[lname]; $dept = $_POST[dept]; $phone = $_POST[phone]; $super = $_POST[super]; $groups = $_POST[groups]; //Assign the server connection to a variable $connect = mssql_connect('SERVERNAME,1433', 'username', 'password'); //Select your database and reference the connection mssql_select_db('DBName', $connect); // Create a new stored prodecure $stmt = mssql_init('sp_name'); // Bind the field names mssql_bind($stmt, '@fname',$fname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@lname',$lname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@dept',$dept,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@phone',$phone,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@super',$super,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@groups',$groups,SQLVARCHAR,false,false,8000); // Execute mssql_execute($stmt); header(Location: done.php); exit; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am I doing wrong?
[snip] I can't seem to understand PHP error trapping...I have it turned on in php.ini, and on the page in question, I have error_reporting(E_ALL); on the page in question below - the following code does NOT generate any errors, but it doesn't perform the insert eitherthe stored procedure exists, but even if I purposely misspell the stored procedure name, no errors are raised...any advice? ?php error_reporting(E_ALL); //submit the request //write entry into database $fname = $_POST[fname]; $lname = $_POST[lname]; $dept = $_POST[dept]; $phone = $_POST[phone]; $super = $_POST[super]; $groups = $_POST[groups]; //Assign the server connection to a variable $connect = mssql_connect('SERVERNAME,1433', 'username', 'password'); //Select your database and reference the connection mssql_select_db('DBName', $connect); // Create a new stored prodecure $stmt = mssql_init('sp_name'); // Bind the field names mssql_bind($stmt, '@fname',$fname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@lname',$lname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@dept',$dept,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@phone',$phone,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@super',$super,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@groups',$groups,SQLVARCHAR,false,false,8000); // Execute mssql_execute($stmt); header(Location: done.php); exit; ? [/snip] No PHP error occurs that is why you do not get an error. Insert this http://us.php.net/manual/en/function.mssql-get-last-message.php after the execute and you should get a message back from SQL Server -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am I doing wrong?
Thanks - actually, as I just figured out, there were PHP errors, but I never saw them because of the redirection header at the end... If I comment that out, I see that I didn't have execute permissions on the SP Thanks for the help! -Original Message- From: Jay Blanchard [mailto:jblanch...@pocket.com] Sent: Friday, April 17, 2009 12:17 PM To: David Stoltz; php-general@lists.php.net Subject: RE: [PHP] What am I doing wrong? [snip] I can't seem to understand PHP error trapping...I have it turned on in php.ini, and on the page in question, I have error_reporting(E_ALL); on the page in question below - the following code does NOT generate any errors, but it doesn't perform the insert eitherthe stored procedure exists, but even if I purposely misspell the stored procedure name, no errors are raised...any advice? ?php error_reporting(E_ALL); //submit the request //write entry into database $fname = $_POST[fname]; $lname = $_POST[lname]; $dept = $_POST[dept]; $phone = $_POST[phone]; $super = $_POST[super]; $groups = $_POST[groups]; //Assign the server connection to a variable $connect = mssql_connect('SERVERNAME,1433', 'username', 'password'); //Select your database and reference the connection mssql_select_db('DBName', $connect); // Create a new stored prodecure $stmt = mssql_init('sp_name'); // Bind the field names mssql_bind($stmt, '@fname',$fname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@lname',$lname,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@dept',$dept,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@phone',$phone,SQLVARCHAR,false,false,25); mssql_bind($stmt, '@super',$super,SQLVARCHAR,false,false,50); mssql_bind($stmt, '@groups',$groups,SQLVARCHAR,false,false,8000); // Execute mssql_execute($stmt); header(Location: done.php); exit; ? [/snip] No PHP error occurs that is why you do not get an error. Insert this http://us.php.net/manual/en/function.mssql-get-last-message.php after the execute and you should get a message back from SQL Server -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] what am I doing wrong? PHP5 on Fedora
**First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install Everything went fine, I then went to add the loadmodule line and did a locate on my box for libphp5.so and it can't find it...shoudln't it be there? It can find libphp4.so but that was left over from the Fedora install. For the heck of it I added the loadmodule line for libphp4.so and gave it the path to libphp4.so, I then added the AddType lines and restarted apache. Problem is, it doesn't parse the php file at all. What are some possible reasons when I don't have libphp5.so? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
On Thursday 30 December 2004 22:56, blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install Everything went fine, I then went to add the loadmodule line and did a locate on my box for libphp5.so and it can't find it...shoudln't it be there? [snip] What are some possible reasons when I don't have libphp5.so? By default the database that the 'locate' command uses is updated once a day. If you have only just installed something and have not updated that database then 'locate' will have no idea about the new files. Use: find / -name libphp5.so Better still, when inside the php5 source directory use: configure --help | less to see where exactly the installation will place your files. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The world has many unintentionally cruel mechanisms that are not designed for people who walk on their hands. -- John Irving, The World According to Garp */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? On Thu, 30 Dec 2004 10:20:01 -0500, John Nichel [EMAIL PROTECTED] wrote: blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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
Re: [PHP] what am I doing wrong? PHP5 on Fedora
I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? On Thu, 30 Dec 2004 10:20:01 -0500, John Nichel [EMAIL PROTECTED] wrote: blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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
Re: [PHP] what am I doing wrong? PHP5 on Fedora
blackwater dev wrote: I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? I don't know if the rpm install of Apache includes apxs. If it doesn't, you'll have to install Apache from source. Look here under Apache+PHP (DSO Module) http://www.blazonry.com/scripting/install_apache.php -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
John Nichel wrote: I don't know if the rpm install of Apache includes apxs. If it doesn't, you'll have to install Apache from source. Usually apxs is in the apache-dev package on the various distros. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
Sorry if you recieved this twice. Head's wreaked today, and I keep making mistakes, such as posting to a person instead of to the list. If you're using apache2 then you need to add something along the lines of --with-apxs to your ./configure line. With apache1.3 it was --with-apxs=/path/to/apxs. I'm not sure what whether it's still --with-apxs, or --with-apxs2, but either way you'll probably be looking for the path to apxs2. Just for your information apxs is the APache eXtension System. If you want to use locate, on recently created files, then you should schedule locate to run updatedb more often. your locate is only as recent as your last updatedb. On Thu, 30 Dec 2004 10:39:50 -0500, blackwater dev [EMAIL PROTECTED] wrote: I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? On Thu, 30 Dec 2004 10:20:01 -0500, John Nichel [EMAIL PROTECTED] wrote: blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
I just went ahead and installed apache from source with apxs then recompiled php5. I then created a info.php file which simply prints out phpinfo but get this error now. Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/usr/local/apache2/htdocs/info.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0 Thanks! On Thu, 30 Dec 2004 11:55:38 -0500, Rasmus Lerdorf [EMAIL PROTECTED] wrote: John Nichel wrote: I don't know if the rpm install of Apache includes apxs. If it doesn't, you'll have to install Apache from source. Usually apxs is in the apache-dev package on the various distros. -Rasmus -- 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
Re: [PHP] what am I doing wrong? PHP5 on Fedora
blackwater dev wrote: I just went ahead and installed apache from source with apxs then recompiled php5. I then created a info.php file which simply prints out phpinfo but get this error now. Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/usr/local/apache2/htdocs/info.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0 Thanks! *sigh* http://groups-beta.google.com/groups?hl=enq=%22Permission+denied+in+Unknown+on+line+0%22qt_s=Search+Groups http://www.linuxquestions.org/questions/history/211964 -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
if you want to know/have a rough guide on building/compiling php with mysql/mysqli support, the following link should help you out... although it's for linux.. http://marc.theaimsgroup.com/?l=php-generalm=109026859726530w=2 it kind of walks you through what you need to do.. hope it helps... peace.. -Original Message- From: Rory Browne [EMAIL PROTECTED] Sent: Dec 30, 2004 11:00 AM To: php-general@lists.php.net Subject: Re: [PHP] what am I doing wrong? PHP5 on Fedora Sorry if you recieved this twice. Head's wreaked today, and I keep making mistakes, such as posting to a person instead of to the list. If you're using apache2 then you need to add something along the lines of --with-apxs to your ./configure line. With apache1.3 it was --with-apxs=/path/to/apxs. I'm not sure what whether it's still --with-apxs, or --with-apxs2, but either way you'll probably be looking for the path to apxs2. Just for your information apxs is the APache eXtension System. If you want to use locate, on recently created files, then you should schedule locate to run updatedb more often. your locate is only as recent as your last updatedb. On Thu, 30 Dec 2004 10:39:50 -0500, blackwater dev [EMAIL PROTECTED] wrote: I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? On Thu, 30 Dec 2004 10:20:01 -0500, John Nichel [EMAIL PROTECTED] wrote: blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 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
Re: [PHP] what am I doing wrong? PHP5 on Fedora
I actually recompiled it all but was getting permission errors. I then rebooted and now linux seems to want to use the old apache instead of the new one I compiled with php support so I have to fix my environment variables to point to the new apache and figure out my permission errors. Thanks! On Thu, 30 Dec 2004 19:00:01 +, Rory Browne [EMAIL PROTECTED] wrote: Sorry if you recieved this twice. Head's wreaked today, and I keep making mistakes, such as posting to a person instead of to the list. If you're using apache2 then you need to add something along the lines of --with-apxs to your ./configure line. With apache1.3 it was --with-apxs=/path/to/apxs. I'm not sure what whether it's still --with-apxs, or --with-apxs2, but either way you'll probably be looking for the path to apxs2. Just for your information apxs is the APache eXtension System. If you want to use locate, on recently created files, then you should schedule locate to run updatedb more often. your locate is only as recent as your last updatedb. On Thu, 30 Dec 2004 10:39:50 -0500, blackwater dev [EMAIL PROTECTED] wrote: I don't seem to have an apxs directory. I don't even have an apache directory as apachectl resides in /usr/sbin/apachectl Of course apache was installed from the fedora install. How do I install this against apache? On Thu, 30 Dec 2004 10:20:01 -0500, John Nichel [EMAIL PROTECTED] wrote: blackwater dev wrote: **First let me say that I am a linux newbie** I have installed Fedora 3 on a development box. I then downloaded the php5 source and followed the php documentation: # ./configure --with-mysql # make # make install What did you build it against? You have no webserver type in your configure line. If I'm not mistaken, all you have above will do is build the cli, and not the loadable module. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- 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 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
Re: [PHP] what am I doing wrong? PHP5 on Fedora
John Nichel wrote / napísal (a): blackwater dev wrote: I just went ahead and installed apache from source with apxs then recompiled php5. I then created a info.php file which simply prints out phpinfo but get this error now. Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/usr/local/apache2/htdocs/info.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0 Thanks! *sigh* http://groups-beta.google.com/groups?hl=enq=%22Permission+denied+in+Unknown+on+line+0%22qt_s=Search+Groups http://www.linuxquestions.org/questions/history/211964 as root switch to htdocs and chmod 666 info.php troby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
tr wrote / napísal (a): John Nichel wrote / napísal (a): blackwater dev wrote: I just went ahead and installed apache from source with apxs then recompiled php5. I then created a info.php file which simply prints out phpinfo but get this error now. Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/usr/local/apache2/htdocs/info.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0 Thanks! *sigh* http://groups-beta.google.com/groups?hl=enq=%22Permission+denied+in+Unknown+on+line+0%22qt_s=Search+Groups http://www.linuxquestions.org/questions/history/211964 as root switch to htdocs and chmod 666 info.php troby It is also recomended to remove the apache binary rpm packages from you system as root: rpm -e apache* Then go to you /etc/init.d/ directory and create a shell script naming httpd_start: containing: #!/bin/bash /usr/local/apachectl start and another shell script naming as httpd_stop containing: /usr/local/apachectl stop go to /etc/rc.d/ and create symlink (ln -s /etc/init.d/httpd_start /etc/rc.d/rc3.d/S27httpd and rc5.d/S27httpd) in dirs rc3.d and rc5.d pointing to /etc/init.d/httpd_start naming S27httpd and then restart and it should work. you can set permissions recursively this way: chmod -R 666 /usr/local/apache/htdocs (to doc root) hello troby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am I doing wrong? PHP5 on Fedora
tr wrote: tr wrote / napísal (a): John Nichel wrote / napísal (a): blackwater dev wrote: I just went ahead and installed apache from source with apxs then recompiled php5. I then created a info.php file which simply prints out phpinfo but get this error now. Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0 Warning: Unknown: Failed opening '/usr/local/apache2/htdocs/info.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0 Thanks! *sigh* http://groups-beta.google.com/groups?hl=enq=%22Permission+denied+in+Unknown+on+line+0%22qt_s=Search+Groups http://www.linuxquestions.org/questions/history/211964 as root switch to htdocs and chmod 666 info.php troby snip you can set permissions recursively this way: chmod -R 666 /usr/local/apache/htdocs (to doc root) Do NOT do this. 1) You will make all your files world writeable...not good 2) By giving it the -R, you will have effectively taken away execute permission from not only /usr/local/apache/htdocs, but all the directories beneath it. Directories need to have execute permission to be 'seen'. Take a little time to read and understand your filesystem and it's permission levels. -- By-Tor.com ...it's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What am I doing wrong - PHP
Ok, hopefully I can explain this clearly, even though I think I might be an idiot since Ive been going on about this for a few days. I have a table that holds values and labels i.e. 1 = New York 2 = Boston 3 = Kansas City 4 = Amsterdam I want to put this table into a multiple selection list, that a user can choose from in a form My code is drawing a blank though: //This is my call to the table staindtypes ?php mysql_select_db($database_lokale, $lokale); $indque1 = SELECT * FROM staindtypes; $inds = mysql_query($indque1, $lokale) or die(mysql_error()); $row_inds = mysql_fetch_assoc($inds); $totalRows_inds = mysql_num_rows($inds); $row = mysql_fetch_row; ? //Here is the element and the php to loop it form name=form1 id=form1 method=post action= select name=Ind size=5 multiple=multiple id=Ind option value=Please Select/option ?php do { ? option value=?php echo $rows['CareerIDs']??php echo $row_$result['CareerCategories']?/option ?php } while ($rows = mysql_fetch_assoc($inds)); $rows = mysql_num_rows($inds); if($rows 0) { mysql_data_seek($inds, 0); $rows = mysql_fetch_assoc($inds); } ? When I load the page it is blank. Any help would be appreciated. Stuart -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am I doing wrong - PHP
Stuart Felenstein mailto:[EMAIL PROTECTED] on Friday, November 12, 2004 12:54 PM said: //This is my call to the table staindtypes ?php mysql_select_db($database_lokale, $lokale); $indque1 = SELECT * FROM staindtypes; $inds = mysql_query($indque1, $lokale) or die(mysql_error()); $row_inds = mysql_fetch_assoc($inds); $totalRows_inds = mysql_num_rows($inds); $row = mysql_fetch_row; $rows = mysql_num_rows($inds); if($rows 0) { mysql_data_seek($inds, 0); $rows = mysql_fetch_assoc($inds); } When I load the page it is blank. Any help would be appreciated. Well your code is a bit hard to follow (imo) but I notice that you have: $row_inds = mysql_fetch_assoc($inds); but then never refer to $row_inds again. I would do the following: ?php $row_inds = mysql_fetch_assoc($inds); $row_inds_cnt = count($row_inds); echo select ...\n; if($row_inds_cnt 0) { for($i = 0; $i $row_inds_cnt; $i++) { echo option value=\...\.../option\n; } } else { echo option value=\empty\empty/option\n; } echo /select\n; ? hth, Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am I doing wrong - PHP
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] Ok, hopefully I can explain this clearly, even though I think I might be an idiot since Ive been going on about this for a few days. I have a table that holds values and labels i.e. 1 = New York 2 = Boston 3 = Kansas City 4 = Amsterdam I want to put this table into a multiple selection list, that a user can choose from in a form My code is drawing a blank though: //This is my call to the table staindtypes ?php mysql_select_db($database_lokale, $lokale); $indque1 = SELECT * FROM staindtypes; $inds = mysql_query($indque1, $lokale) or die(mysql_error()); $row_inds = mysql_fetch_assoc($inds); $totalRows_inds = mysql_num_rows($inds); $row = mysql_fetch_row; ? //Here is the element and the php to loop it form name=form1 id=form1 method=post action= select name=Ind size=5 multiple=multiple id=Ind option value=Please Select/option ?php do { ? option value=?php echo $rows['CareerIDs']??php echo $row_$result['CareerCategories']?/option ---^ I think your error is right here. Don't you want $rows['CareerCategories']? Aside from that, I'm not certain the code is exactly what you want, but this should at least solve the blank page problem. I think PHP's barfing on that but errors aren't being written to the browser. Good luck! -- Mike Johnson Smarter Living, Inc. Web Developerwww.smarterliving.com [EMAIL PROTECTED] (617) 886-5539 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] what am i doing wrong..??
Hi there please have a look the code below...I dont know wht am doing wrong here... This code is suppose to show the number of jokes in a mysql database and allows user to add a joke when the user clicks addjoke link. And when the joke is added, it suppose to say that Joke inserted, Thank you and list all the jokes below this line. So far am able to view all the jokes and take the user to add joke page. But the problem is when the user clicks insert joke button, it does not display the message Joke inserted, Thank you and the jokes are not listed. Infact it does not give any error aswell, it just stays on the add joke form page. I checked the database and no joke is added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using registre_globals OFF and all these probs strted coming up. This code was working fine with globals ON. But my hosting has it off. So need to do so. I was able to fix all the other issues came coz of this global thing in this code. But stuck on the issue i just mentioned. Any help would be GREATLY appreciated. ?php if (isset($_GET['addjoke'])){ ? form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ? Type your joke :br textarea name=jokeText id=jokeText/textarea br input name=insert type=submit id=submit value=Insert Joke /form ?php } else { // start main else statement if(isset ($_POST['insert'])) { $db = mysql_connect(localhost,homesite,test) ; mysql_select_db(jokes,$db); $query = mysql_query(INSERT INTO jokes SET JokeText = '.$_POST['jokeText'].' , JokeDate = CURDATE() ); echo Joke inserted, Thank you BRBR; echo mysql_error(); } $color1 = #66CCFF; $color2 = #66CC99; $row_count = 1; // -- Following lines list the jokes in the database echo bH3 These are the jokes we have got so far/H3/B; $db = mysql_connect(localhost,homesite,test) or die(mysql_error()); mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from jokes; $query = mysql_query($sql); echo table border=1 tr tdbIDb/td tdbJoke Textb/td tdbJoke Dateb/td/tr; while ($myrow = mysql_fetch_array($query)) { $row_color = ($row_count % 2) ? $color1 : $color2; echotr bgcolor = $row_color. td. $myrow[id]./td. td. $myrow[JokeText]. /td. td. $myrow[JokeDate]./td/tr; $row_count++; } echo /table; $current_url = $_SERVER['PHP_SELF']; echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P); } // end main else statement ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] what am i doing wrong..??
Echo out your queries! $query = insert into joke values('',.$_POST['joke_text'].,'date'); --- echo $query; $result= mysql_query($query); This will tell you what is going on, perhaps some of the information is not set? You can even copy and paste the output to run against your mysql backend on the command line to see if additional information/errors are present. -B - Original Message - From: Aalee [EMAIL PROTECTED] Date: Thursday, November 4, 2004 7:54 am Subject: [PHP] what am i doing wrong..?? Hi there please have a look the code below...I dont know wht am doing wrong here... This code is suppose to show the number of jokes in a mysql database and allows user to add a joke when the user clicks addjoke link. And when the joke is added, it suppose to say that Joke inserted, Thank you and list all the jokes below this line. So far am able to view all the jokes and take the user to add joke page. But the problem is when the user clicks insertjoke button, it does not display the message Joke inserted, Thank you and the jokes are not listed. Infact it does not give any error aswell, it just stays on the add joke form page. I checked the database and no joke is added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using registre_globals OFF and all these probs strtedcoming up. This code was working fine with globals ON. But my hosting has it off. So need to do so. I was able to fix all the other issues came coz of this global thing in this code. But stuck on the issue i just mentioned. Any help would be GREATLY appreciated. ?php if (isset($_GET['addjoke'])){ ? form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ? Type your joke :br textarea name=jokeText id=jokeText/textarea br input name=insert type=submit id=submit value=Insert Joke /form ?php } else { // start main else statement if(isset ($_POST['insert'])) { $db = mysql_connect(localhost,homesite,test) ; mysql_select_db(jokes,$db); $query = mysql_query(INSERT INTO jokes SET JokeText = '.$_POST['jokeText'].' , JokeDate = CURDATE() ); echo Joke inserted, Thank you BRBR; echo mysql_error(); } $color1 = #66CCFF; $color2 = #66CC99; $row_count = 1; // -- Following lines list the jokes in the database echo bH3 These are the jokes we have got so far/H3/B; $db = mysql_connect(localhost,homesite,test) or die(mysql_error());mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from jokes; $query = mysql_query($sql); echo table border=1 tr tdbIDb/td tdbJoke Textb/td tdbJoke Dateb/td/tr; while ($myrow = mysql_fetch_array($query)) { $row_color = ($row_count % 2) ? $color1 : $color2; echotr bgcolor = $row_color. td. $myrow[id]./td. td. $myrow[JokeText]. /td. td. $myrow[JokeDate]./td/tr; $row_count++; } echo /table; $current_url = $_SERVER['PHP_SELF']; echo(P .Add a Joke!/P); } // end main else statement ? -- 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
RE: [PHP] what am i doing wrong..??
?php $_SERVER['PHP_SELF'] ? somehow keeps the $_GET variables. If you change this to the real script name it seems to work JACK -Original Message- From: Aalee [mailto:[EMAIL PROTECTED] Sent: Thursday, November 04, 2004 1:54 PM To: [EMAIL PROTECTED] Subject: [PHP] what am i doing wrong..?? Hi there please have a look the code below...I dont know wht am doing wrong here... This code is suppose to show the number of jokes in a mysql database and allows user to add a joke when the user clicks addjoke link. And when the joke is added, it suppose to say that Joke inserted, Thank you and list all the jokes below this line. So far am able to view all the jokes and take the user to add joke page. But the problem is when the user clicks insert joke button, it does not display the message Joke inserted, Thank you and the jokes are not listed. Infact it does not give any error aswell, it just stays on the add joke form page. I checked the database and no joke is added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using registre_globals OFF and all these probs strted coming up. This code was working fine with globals ON. But my hosting has it off. So need to do so. I was able to fix all the other issues came coz of this global thing in this code. But stuck on the issue i just mentioned. Any help would be GREATLY appreciated. ?php if (isset($_GET['addjoke'])){ ? form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ? Type your joke :br textarea name=jokeText id=jokeText/textarea br input name=insert type=submit id=submit value=Insert Joke /form ?php } else { // start main else statement if(isset ($_POST['insert'])) { $db = mysql_connect(localhost,homesite,test) ; mysql_select_db(jokes,$db); $query = mysql_query(INSERT INTO jokes SET JokeText = '.$_POST['jokeText'].' , JokeDate = CURDATE() ); echo Joke inserted, Thank you BRBR; echo mysql_error(); } $color1 = #66CCFF; $color2 = #66CC99; $row_count = 1; // -- Following lines list the jokes in the database echo bH3 These are the jokes we have got so far/H3/B; $db = mysql_connect(localhost,homesite,test) or die(mysql_error()); mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from jokes; $query = mysql_query($sql); echo table border=1 tr tdbIDb/td tdbJoke Textb/td tdbJoke Dateb/td/tr; while ($myrow = mysql_fetch_array($query)) { $row_color = ($row_count % 2) ? $color1 : $color2; echotr bgcolor = $row_color. td. $myrow[id]./td. td. $myrow[JokeText]. /td. td. $myrow[JokeDate]./td/tr; $row_count++; } echo /table; $current_url = $_SERVER['PHP_SELF']; echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P); } // end main else statement ? -- 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
Re: [PHP] what am i doing wrong..??
well ofcourse it keeps the get variables as you put it. PHP_SELF is the path and arguments that php was called with. use phpinfo(); to find out which variables hold the real path, make sure to add some random get variables when calling that script so you see the difference Jack Van Zanen wrote: ?php $_SERVER['PHP_SELF'] ? somehow keeps the $_GET variables. If you change this to the real script name it seems to work JACK -Original Message- From: Aalee [mailto:[EMAIL PROTECTED] Sent: Thursday, November 04, 2004 1:54 PM To: [EMAIL PROTECTED] Subject: [PHP] what am i doing wrong..?? Hi there please have a look the code below...I dont know wht am doing wrong here... This code is suppose to show the number of jokes in a mysql database and allows user to add a joke when the user clicks addjoke link. And when the joke is added, it suppose to say that Joke inserted, Thank you and list all the jokes below this line. So far am able to view all the jokes and take the user to add joke page. But the problem is when the user clicks insert joke button, it does not display the message Joke inserted, Thank you and the jokes are not listed. Infact it does not give any error aswell, it just stays on the add joke form page. I checked the database and no joke is added. Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. Recently i started using registre_globals OFF and all these probs strted coming up. This code was working fine with globals ON. But my hosting has it off. So need to do so. I was able to fix all the other issues came coz of this global thing in this code. But stuck on the issue i just mentioned. Any help would be GREATLY appreciated. ?php if (isset($_GET['addjoke'])){ ? form name=form1 method=post action=?php $_SERVER['PHP_SELF'] ? Type your joke :br textarea name=jokeText id=jokeText/textarea br input name=insert type=submit id=submit value=Insert Joke /form ?php } else { // start main else statement if(isset ($_POST['insert'])) { $db = mysql_connect(localhost,homesite,test) ; mysql_select_db(jokes,$db); $query = mysql_query(INSERT INTO jokes SET JokeText = '.$_POST['jokeText'].' , JokeDate = CURDATE() ); echo Joke inserted, Thank you BRBR; echo mysql_error(); } $color1 = #66CCFF; $color2 = #66CC99; $row_count = 1; // -- Following lines list the jokes in the database echo bH3 These are the jokes we have got so far/H3/B; $db = mysql_connect(localhost,homesite,test) or die(mysql_error()); mysql_select_db(jokes,$db); $sql = SELECT id, JokeText, JokeDate from jokes; $query = mysql_query($sql); echo table border=1 tr tdbIDb/td tdbJoke Textb/td tdbJoke Dateb/td/tr; while ($myrow = mysql_fetch_array($query)) { $row_color = ($row_count % 2) ? $color1 : $color2; echotr bgcolor = $row_color. td. $myrow[id]./td. td. $myrow[JokeText]. /td. td. $myrow[JokeDate]./td/tr; $row_count++; } echo /table; $current_url = $_SERVER['PHP_SELF']; echo(PA HREF=.$current_url.?addjoke=1 .Add a Joke!/A/P); } // end main else statement ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What am i doing wrong? SQL Query in PHP
I want to display the first 3 words of my record in the my table and following is the code i'm using. When i use the SQL Query in mySQL.. it works great.. but when i try to implement it in my php page.. i'm not getting anything.. no error, no display, no result.. just blank.. why? ?php $db = mysql_connect(localhost,user,pass); mysql_select_db(mydb,$db); $result = mysql_query(SELECT substring_index(title, ' ', 3) from news order by ID desc limit 4,$db); if ($myrow = mysql_fetch_array($result)) { do { echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } ? Rahul S. Johari __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
At 13:37 9-3-2003, you wrote: I want to display the first 3 words of my record in the my table and following is the code i'm using. When i use the SQL Query in mySQL.. it works great.. but when i try to implement it in my php page.. i'm not getting anything.. no error, no display, no result.. just blank.. why? i don't know what's wrog but you could do some quick debugging by echoing mysql_error() when the query fails. ($result=mysql_query(.) or die ('brQuery failed at'.__FILE__.' line '.__LINE__.' and mysql says:br'.mysql_error()); ?php $db = mysql_connect(localhost,user,pass); mysql_select_db(mydb,$db); $result = mysql_query(SELECT substring_index(title, ' ', 3) from news order by ID desc limit 4,$db); if ($myrow = mysql_fetch_array($result)) { do { check whether there are some results walked through by doing something silly like echo '*'; here. echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
Ok i tried this.. and i didn't get any error listed.. so it seems that the mySQL Query is not failing in syntax or logic.. but it's not picking up any rows. Which is really stupid because i used my phpmyadmin and i ran this SQL Query there and even then i got my results.. --- Chris Hayes [EMAIL PROTECTED] wrote: At 13:37 9-3-2003, you wrote: I want to display the first 3 words of my record in the my table and following is the code i'm using. When i use the SQL Query in mySQL.. it works great.. but when i try to implement it in my php page.. i'm not getting anything.. no error, no display, no result.. just blank.. why? i don't know what's wrog but you could do some quick debugging by echoing mysql_error() when the query fails. ($result=mysql_query(.) or die ('brQuery failed at'.__FILE__.' line '.__LINE__.' and mysql says:br'.mysql_error()); ?php $db = mysql_connect(localhost,user,pass); mysql_select_db(mydb,$db); $result = mysql_query(SELECT substring_index(title, ' ', 3) from news order by ID desc limit 4,$db); if ($myrow = mysql_fetch_array($result)) { do { check whether there are some results walked through by doing something silly like echo '*'; here. echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
Hello, Rahul.Brenda [EMAIL PROTECTED] wrote: Ok i tried this.. and i didn't get any error listed.. so it seems that the mySQL Query is not failing in syntax or logic.. but it's not picking up any rows. Which is really stupid because i used my phpmyadmin and i ran this SQL Query there and even then i got my results.. So, you still have a blank page? Check the resulting html source code and see how it looks like. Also, do you have display_errors = On in your php.ini? Btw, see if changing this: echo( $myrow[title] ); to this: echo $myrow[title]; makes any difference. Just my 2 cents... - E __ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
At 13:37 9-3-2003, you wrote: if ($myrow = mysql_fetch_array($result)) { do { echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } PS same result with while ($myrow = mysql_fetch_array($result)); { echo $myrow['title']; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
On Sun, 9 Mar 2003 04:37:47 -0800 (PST), Rahul.Brenda [EMAIL PROTECTED] wrote: I want to display the first 3 words of my record in the my table and following is the code i'm using. When i use the SQL Query in mySQL.. it works great.. but when i try to implement it in my php page.. i'm not getting anything.. no error, no display, no result.. just blank.. why? ?php $db = mysql_connect(localhost,user,pass); mysql_select_db(mydb,$db); $result = mysql_query(SELECT substring_index(title, ' ', 3) from news order by ID desc limit 4,$db); if ($myrow = mysql_fetch_array($result)) { do { echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } ? Rahul S. Johari Why not do it like this? // fetch row is faster than fetch_assoc, which is faster than fetch_array // fetch_result might even be a better choice here, though, with only one item... if (!mysql_num_rows($result)) { print 'no results'; } else { while (list($title) = mysql_fetch_row($result)) { print $title; // don't quote variables if you only want to print them by themselves } } -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP
Hi, So, you still have a blank page? Yes i do actually, and blank in HTML Source too. do you have display_errors = On in your php.ini? Ahan.. yes i do. to this: echo $myrow[title]; makes any difference. No actually it didnt. :0( Rahul S. Johari __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What am i doing wrong? SQL Query in PHP [WORKS!!]
Chris, Thanks a lot.. THIS WORKS! Works brilliantly. All other methods were just failing. Thanks man. // fetch row is faster than fetch_assoc, which is faster than fetch_array // fetch_result might even be a better choice here, though, with only one item... if (!mysql_num_rows($result)) { print 'no results'; } else { while (list($title) = mysql_fetch_row($result)) { print $title; // don't quote variables if you only want to print them by themselves } } Rahul S. Johari __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am i doing wrong? SQL Query in PHP
I want to display the first 3 words of my record in the my table and following is the code i'm using. When i use the SQL Query in mySQL.. it works great.. but when i try to implement it in my php page.. i'm not getting anything.. no error, no display, no result.. just blank.. why? ?php $db = mysql_connect(localhost,user,pass); mysql_select_db(mydb,$db); $result = mysql_query(SELECT substring_index(title, ' ', 3) from news order by ID desc limit 4,$db); if ($myrow = mysql_fetch_array($result)) { do { echo( $myrow[title] ); } while ($myrow = mysql_fetch_array($result)); } ? In case you're wondering, your method is fine. You can continue to use this or what chris suggested. Either way, the problem is that you need an alias for your column that you selected. With the above code, you didn't select a column called title so you can't use $row['title']. You created a column called substring_index(title, ' ', 3) so you'll have to use $row[substring_index(title, ' ', 3)]. As you can probably guess, there's an easier way to do it, though... If you use a query such as: SELECT SUBSTRING_INDEX(title, ' ', 3) AS f_title FROM news ORDER BY id LIMIT 4 You can then use $row['f_title'] to print the result. Using AS in your query will rename the column to f_title or whatever you put there. This is called assigning the column an alias. Of course, though all of this you could of just used $row[0] to get the value. I tend to stay away from using numerical indexes though, as it makes it harder for other people to follow your code. When you see $row['f_title'], it gives you a good idea of what you're displaying. When you see $row[0], you have no idea what it is and you have to go find the query that was run in order to determine what column zero was. Hope that helps. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What am i doing wrong? SQL Query in PHP
Hi, Thanks.. i went through your reply and certainly now i understand the mistake i was making. Quite logical actually, that i hadn't actually selected the title column. But i'm sure i wouldnt' have been able to figure this out myself. And surely, i too try to stay away from Numerical Indexes. Well thank you, this does enlighten quite a bit. Rahul S. Johari In case you're wondering, your method is fine. You can continue to use this or what chris suggested. Either way, the problem is that you need an alias for your column that you selected. With the above code, you didn't select a column called title so you can't use $row['title']. You created a column called substring_index(title, ' ', 3) so you'll have to use $row[substring_index(title, ' ', 3)]. As you can probably guess, there's an easier way to do it, though... If you use a query such as: SELECT SUBSTRING_INDEX(title, ' ', 3) AS f_title FROM news ORDER BY id LIMIT 4 You can then use $row['f_title'] to print the result. Using AS in your query will rename the column to f_title or whatever you put there. This is called assigning the column an alias. Of course, though all of this you could of just used $row[0] to get the value. I tend to stay away from using numerical indexes though, as it makes it harder for other people to follow your code. When you see $row['f_title'], it gives you a good idea of what you're displaying. When you see $row[0], you have no idea what it is and you have to go find the query that was run in order to determine what column zero was. Hope that helps. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ __ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php