[PHP] Stuck on undefined function mysql_connect()
I have been stuck on this, and have no idea what is causing it. I have compiled PHP with mysqli support: ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php --with-mcrypt=/usr/local/bin/mcrypt --with-mysqli --with-gettext=./ext/gettext --with-pear --with-libxml-dir=/usr/include/libxml2 --with-zlib --with-gd --enable-pcntl mysqli MysqlI Supportenabled Client API library version 5.1.49 Active Persistent Links 0 Inactive Persistent Links 0 Active Links 0 Client API header version 5.1.49 MYSQLI_SOCKET /var/run/mysqld/mysqld.sock DirectiveLocal ValueMaster Value mysqli.allow_local_infileOnOn mysqli.allow_persistentOnOn mysqli.default_host*no value**no value* mysqli.default_port33063306 mysqli.default_pw*no value**no value* mysqli.default_socket*no value**no value* mysqli.default_user*no value**no value* mysqli.max_linksUnlimitedUnlimited mysqli.max_persistentUnlimited Unlimited mysqli.reconnectOffOff However, there is no mysqli.so or mysql.so found anywhere? Please help, I have fallen behind because of this. Nick.
Re: [PHP] Stuck on undefined function mysql_connect()
On Thu, Oct 13, 2011 at 14:19, Nick Khamis sym...@gmail.com wrote: I have been stuck on this, and have no idea what is causing it. I have compiled PHP with mysqli support: Right which will use mysqli_connect(), et al. If you didn't compile it with straight MySQL support, then the mysql_*() functions won't be there. However, there is no mysqli.so or mysql.so found anywhere? Please help, I have fallen behind because of this. It's compiled into the core, not as an extension. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stuck on undefined function mysql_connect()
On Thu, Oct 13, 2011 at 14:33, Nick Khamis sym...@gmail.com wrote: I was just going to try recompilign with mysql instead of mysqli... I hope this fixes it. In terms of mysql being compiled into the core, does this mean I do not have to add extension=mysqli.so extension_dir=/usr/local/php/include/php/ext/ (Please don't top-post, and be sure to click reply-all so that the discussion remains on the list for the benefit of others as well.) Correct. Extensions, such as those found in the PECL repository, are added in that manner. Things compiled into the core, such as what you're doing with MySQLi, are automatically loaded regardless, because they're statically-built into the PHP binary itself. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stuck on undefined function mysql_connect()
I was just going to try recompilign with mysql instead of mysqli... I hope this fixes it. In terms of mysql being compiled into the core, does this mean I do not have to add extension=mysqli.so extension_dir=/usr/local/php/ include/php/ext/ Thanks in Advance,
Re: [PHP] Stuck on undefined function mysql_connect()
Correct. Extensions, such as those found in the PECL repository, are added in that manner. Things compiled into the core, such as what you're doing with MySQLi, are automatically loaded regardless, because they're statically-built into the PHP binary itself.
[PHP] Stuck in implementing PHP with HTML
Hi All, Hi i am a newbie in PHP environment. First of all my sincere regards to all behind developing this fabulous language of-course to every one who are sharing their knowledge views making others comfortable with the same. Coming to the point i am trying to create a contact form applying server side validation for my site using PHP. Here the problem had arises. I have designed a from applied validation referring the tutorials available on web but unfortunately it is not working. I am applying the validation trying to show the error in the same field if there Here i am sending you the code snippet what i am trying to do. Your help is highly appreciable. kindly help me out. *form.php:-* body ?php $required = array(name=Name,number=Number,email=Email,detail=Comment); foreach($required as $field = $label){ if(!$_POST[$field]){ $warnings[$field] = Required; } if($_POST[email] !eregi (^[_a-z0-9-]+(\.[_a-z0-9-]+)*...@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$,$_POST[email])) $warnings[email] = Invalid Email Format; if($_POST[number] !eregi (^[0-9]{10}$,$_POST[number])) $warnings[number] = Invalid number Format; if(count($warnings)0){ ? !-- start form-- div class=post h2 class=title-creditContact Form:-/h2 div class=entry style=padding-left:30px; form name=feedback method=post action=submit.php pdiv style=padding:3px;Name span style=margin-left:20pxinput name=name type=text id=name size=40 ?php if($$warnings[name]) echo 'style=\shaded\';? value=?php echo $_POST[name];??php echo $warnings[name];?/span/div div style=padding:3px;Number span style=margin-left:10pxinput name=number type=text id=number size=40 ?php if($$warnings[number]) echo 'style=\shaded\';? value=?php echo $_POST[number];??php echo $warnings[number];?/span/div div style=padding:3px;Email span style=margin-left:22pxinput name=email type=text id=email size=40 ?php if($$warnings[email]) echo 'style=\shaded\';? value=?php echo $_POST[email];??php echo $warnings[email];?/span/div div style=padding:3px;Comment span style=margin-left:0pxtextarea name=detail cols=50 rows=4 id=detail ?php if($$warnings[detail]) echo 'style=\shaded\';? value=?php echo $_POST[detail];?/textarea?php echo $warnings[detail];?/span/div div style=padding:3px; padding-left:150px;input type=submit name=Submit value=Submit input type=reset name=Reset value=Reset/div/p /form ?php } else{ echo Thanks for valuable comments; } ? /body *submit.php* ? $con=mysql_connect(localhost,test,test1234) or die (mysql_errno().:b .mysql_error()./b); mysql_select_db(dbname,$con) or die (mysql_errno().:b .mysql_error()./b); $insert_query = 'insert into GUESTBOOK (NAME,NUMBER,EMAIL,DETAIL) values( ' . $_POST['name'] . ', ' . $_POST['number'] . ', ' . $_POST['email'] . ', ' . $_POST['detail'] . ' )'; mysql_query($insert_query) or die ('Error updating database'); mysql_close($con); ? header('Location: http://www.sweetsamaira.com/guest.php'); Kindly help me out. Thanks in advance. -- Kind Regards, Vivek Jadiya
RE: [PHP] Stuck in implementing PHP with HTML
-Original Message- From: vivek [mailto:er.jadiyavi...@gmail.com] Sent: Thursday, October 14, 2010 2:26 AM To: php-general@lists.php.net Subject: [PHP] Stuck in implementing PHP with HTML Hi All, Hi i am a newbie in PHP environment. First of all my sincere regards to all behind developing this fabulous language of-course to every one who are sharing their knowledge views making others comfortable with the same. Coming to the point i am trying to create a contact form applying server side validation for my site using PHP. Here the problem had arises. I have designed a from applied validation referring the tutorials available on web but unfortunately it is not working. I am applying the validation trying to show the error in the same field if there Here i am sending you the code snippet what i am trying to do. Your help is highly appreciable. kindly help me out. *form.php:-* body ?php $required = array(name=Name,number=Number,email=Email,detail= Comment); foreach($required as $field = $label){ if(!$_POST[$field]){ $warnings[$field] = Required; } if($_POST[email] !eregi (^[_a-z0-9-]+(\.[_a-z0-9-]+)*...@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a- z]{2,3})$,$_POST[email])) $warnings[email] = Invalid Email Format; if($_POST[number] !eregi (^[0-9]{10}$,$_POST[number])) $warnings[number] = Invalid number Format; if(count($warnings)0){ ? !-- start form-- div class=post h2 class=title-creditContact Form:-/h2 div class=entry style=padding-left:30px; form name=feedback method=post action=submit.php Here is your problem... The form is submitting to submit.php while your validation is done in form.php. What you should do is have the form submit TO form.php. If validation passes, redirect via header() [1]. You might have to use session [2] to have the value accessible in submit.php for security reasons. pdiv style=padding:3px;Name span style=margin- left:20pxinput name=name type=text id=name size=40 ?php if($$warnings[name]) echo 'style=\shaded\';? value=?php echo $_POST[name];??php echo $warnings[name];?/span/div div style=padding:3px;Number span style=margin- left:10pxinput name=number type=text id=number size=40 ?php if($$warnings[number]) echo 'style=\shaded\';? value=?php echo $_POST[number];??php echo $warnings[number];?/span/div div style=padding:3px;Email span style=margin- left:22pxinput name=email type=text id=email size=40 ?php if($$warnings[email]) echo 'style=\shaded\';? value=?php echo $_POST[email];??php echo $warnings[email];?/span/div div style=padding:3px;Comment span style=margin- left:0pxtextarea name=detail cols=50 rows=4 id=detail ?php if($$warnings[detail]) echo 'style=\shaded\';? value=?php echo $_POST[detail];?/textarea?php echo $warnings[detail];?/span/div div style=padding:3px; padding-left:150px;input type=submit name=Submit value=Submit input type=reset name=Reset value=Reset/div/p /form ?php } else{ echo Thanks for valuable comments; } ? /body *submit.php* ? $con=mysql_connect(localhost,test,test1234) or die (mysql_errno().:b .mysql_error()./b); mysql_select_db(dbname,$con) or die (mysql_errno().:b .mysql_error()./b); $insert_query = 'insert into GUESTBOOK (NAME,NUMBER,EMAIL,DETAIL) values( ' . $_POST['name'] . ', ' . $_POST['number'] . ', ' . $_POST['email'] . ', ' . $_POST['detail'] . ' )'; In submit.php, the values should be retrieved from $_SESSION. Also, this is very bad to SQL injection. Look into escaping the input [3]. I suggest you to use mysqli extension, if you can, over mysql extension. There many benefits to it. mysql_query($insert_query) or die ('Error updating database'); mysql_close($con); ? header('Location: http://www.sweetsamaira.com/guest.php'); Kindly help me out. Thanks in advance. -- Kind Regards, Vivek Jadiya Regards, Tommy [1] http://php.net/manual/en/function.header.php [2] http://www.php.net/manual/en/book.session.php [3] http://us2.php.net/manual/en/function.mysql-real-escape-string.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] stuck with simple query..... Plz have a look
[snip] We have two tables [/snip] Please do not cross-post, send only to the list where needed. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stuck with simple query..... Plz have a look
We have two tables Table1: - ID |Name 1 |name1 2 |name2 3 |name3 4 |name4 Table2: --- PL | PC |PA| Description --- 1| 2 | 4| Some description for Project 1 2| 3 | 1| Some description for Project 2 1| 2 | 4| Some description for Project 3 4| 1 | 3| Some description for Project 4 3| 1 | 4| Some description for Project 5 2| 3 | 1| Some description for Project 6 I need the output like.. - PL-Name| PC-Name| PA-Name - name1 | name2 |name4 name2 | name3 |name1 name1 | name2 |name4 name4 | name1 |name3 name3 | name1 |name4 name2 | name3 |name1 Please guide me how can i achieve this kind of result set. Regards, Tariq
[PHP] Stuck!
Having spent hours on my members registration and login pages I am getting so close to cracking it, but have now hit a brick wall. I am getting a warning message which I think could stem from somewhere else in my code but I have no idea where. There is a little too much code to put here so is there a kind sole out there who would take a look at my code if I email it to you to see where I am going wrong? There are two pages a login page and a new member page. Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Stuck!
Andrew wrote: Having spent hours on my members registration and login pages I am getting so close to cracking it, but have now hit a brick wall. I am getting a warning message which I think could stem from somewhere else in my code but I have no idea where. There is a little too much code to put here so is there a kind sole out there who would take a look at my code if I email it to you to see where I am going wrong? There are two pages a login page and a new member page. With respect, I feel we might help you more if you post the exact error message, and the last couple of lines prior to the line number reported in the error message. HTH Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stuck at PHP4 installation( with Apache2 )
hi, I've Apache 2 running fine in my Windows 2000 machine. I installed PHP 4.2.3( from the zip-file method ). I copied php4apache.dll and php4apache2.dll to /WINNT/system32 and /WINNT as well( to be safe ). In my httpd.conf, either of the following startments are causing the Apache to not start... LoadModule php4_module F:/Progra~1/php-4.2.3-Win32/sapi/php4apache2.dll LoadModule php4_module D:/WINNT/system32/php4apache2.dll I tried to give F:/Program Files/php-4.2.3-Win32/sapi/php4apache2.dll and all possible combinations of quotes, spaces, names, but it doesn't start if I include any of those combinations. Otherwise it works ! Besides the above mentioned problematic line, these are the other entries( in diff. lines ofcourse ) I've in my httpd.conf... - DirectoryIndex index.html index.html.var index.htm index.shtml index.php index.php3 index.php4 - ScriptAlias /php/ F:/Program Files/php-4.2.3-Win32/ - AddType application/x-httpd-php .php .php3 .php4 .phtml - AddType application/x-httpd-php-source .phps - Action application/x-httpd-php F:/Program Files/php-4.2.3-Win32/php.exe I'm new PHP Apache2. Can someone help me to make this work. Thanks a lot. kramer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] stuck n00b
I have a simple form: form action=addUser.php method=post Enter Username: input type=text name=userNamebrbr input type=submit value=Submit /form Submits to addUser.php: ?php echo $HTTP_SERVER_VARS['userName']; ? Returns this error in my browser: Notice: Undefined index: userName in E:\Inetpub\wwwroot\Test\addUser.php on line 11 Is there a setting in my php.ini file I need to change? register_globals is off, as that seems to be the preferred method now. But that's my issue, trying to access this external variable. $_REQUEST doesn't work. $_POST doesn't either. I have other scripts that it's working in, but I may not know what I'm saying here. PHP 4.2.3 on IIS (personal web server or whatever it's called) on WinXP Pro. Thanks for any help you can give. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] stuck n00b
[snip] Submits to addUser.php: ?php echo $HTTP_SERVER_VARS['userName']; ? Returns this error in my browser: Notice: Undefined index: userName in E:\Inetpub\wwwroot\Test\addUser.php on line 11 Is there a setting in my php.ini file I need to change? register_globals is off, as that seems to be the preferred method now. But that's my issue, trying to access this external variable. $_REQUEST doesn't work. $_POST doesn't either. I have other scripts that it's working in, but I may not know what I'm saying here. PHP 4.2.3 on IIS (personal web server or whatever it's called) on WinXP Pro. [/snip] You mentioned everything but $_GET{'userName'] :^] Since the form method=GET this is what you would have to do to 'get' the result you're looking for. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] stuck n00b
[snip] You mentioned everything but $_GET{'userName'] :^] [/snip] Ooops, typo! $_GET['userName'] HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stuck n00b
My form is actually using method=post. And I did use $_POST. Can't remember if I tried $_GET, but if I'm using post would that even work? I'll give it a try later and let you know. Jay Blanchard [EMAIL PROTECTED] wrote in message 000101c2697c$4ad74bc0$8102a8c0@000347D72515">news:000101c2697c$4ad74bc0$8102a8c0@000347D72515... [snip] Submits to addUser.php: ?php echo $HTTP_SERVER_VARS['userName']; ? Returns this error in my browser: Notice: Undefined index: userName in E:\Inetpub\wwwroot\Test\addUser.php on line 11 Is there a setting in my php.ini file I need to change? register_globals is off, as that seems to be the preferred method now. But that's my issue, trying to access this external variable. $_REQUEST doesn't work. $_POST doesn't either. I have other scripts that it's working in, but I may not know what I'm saying here. PHP 4.2.3 on IIS (personal web server or whatever it's called) on WinXP Pro. [/snip] You mentioned everything but $_GET{'userName'] :^] Since the form method=GET this is what you would have to do to 'get' the result you're looking for. HTH! Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] stuck n00b
[snip] My form is actually using method=post. And I did use $_POST. Can't remember if I tried $_GET, but if I'm using post would that even work? I'll give it a try later and let you know. [/snip] My bad! I looked at two e-mails from different folks and saw a GET in one, and a POST in another. Since you are using POST it should be $_POST['userName'] or $_POST[userName] Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stuck n00b
I was sure I'd tried it, but $_POST works now. Thanks guys. Jay Blanchard [EMAIL PROTECTED] wrote in message 000501c2697d$ded95a10$8102a8c0@000347D72515">news:000501c2697d$ded95a10$8102a8c0@000347D72515... [snip] My form is actually using method=post. And I did use $_POST. Can't remember if I tried $_GET, but if I'm using post would that even work? I'll give it a try later and let you know. [/snip] My bad! I looked at two e-mails from different folks and saw a GET in one, and a POST in another. Since you are using POST it should be $_POST['userName'] or $_POST[userName] Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Stuck using mail() in script with variable
Hi all! I'm pretty green on this and i'm trying to create a form that sends a authorization mail using a few variable using the ()mail script. I have all settings correct, added the smtp right, even tested it with the following scripts wich worked fine ?php print mail ('[EMAIL PROTECTED]', 'No need for reply -- PHP test!', /* subject */ hi Cheyenne\nLine 2\n);/* body*/ ? and this one ?php $mailTo = [EMAIL PROTECTED]; $mailSubject = Testing EMail; $mailBody = This is a test of the EMail system from a PHP script\n; $mailBody .= PHP Version . phpversion(); $mailHeader = From: [EMAIL PROTECTED]\n; $mailHeader .= Reply-To: [EMAIL PROTECTED]\n; $mailHeader .= X-Mailer: PHP/ . phpversion() . \n\n; mail( $mailTo, $mailSubject, $mailBody, $mailHeader ); ? When using the concerning script wich i copied below, it just doesnt send the mail and gives me the following error : Warning: Server Error in x:\apache group\apache\htdocs\php-pages\register.php on line 103 It does in fact store the submitted data in the database so it is only the mail that's given me a headache!!! What is it i'm doing wrong? The error is in line: mail($recipient, $subject, $message, $headers); The source: html head titleInschrijven/title /head body p align=left ? require ../db.php; require ../functions.inc.php; $result=mysql_query(SELECT * FROM CATEGORIE); $result2=mysql_query(SELECT * FROM CATEGORIE); $result3=mysql_query(SELECT * FROM CATEGORIE); ? ?php if ($submit) { $geboortedatum=$jaar.-.$maand.-.$dag; $van=$jaar2.-.$maand2.-.$dag2; $tot=$jaar3.-.$maand3.-.$dag3; $postcode=$postcode1.$postcode2; for ($ix=0;$ixcount($rijbewijs);$ix++) { $rijbewijzen.=$rijbewijs[$ix]. ; } if (emailcheck($email)!=oke) { $fout.=Vul een geldig e-mailadres in.br; } if (strlen($ervaring)==0) { $fout.=Vul een geldige waarde in voor bervaring/b.br; } if (strlen($nationaliteit)==0) { $fout.=Vul een geldige waarde in voor bnationaliteit/b.br; } if (strlen($naam)==0) { $fout.=Vul een geldige naam in.br; } if (strlen($voornaam)==0) { $fout.=Vul een geldige voornaam in.br; } if (strlen($adres)7) { $fout.=Vul een geldig adres in.br; } if (strlen($postcode)!=6) { $fout.=Vul een geldige postcode in.br; } if (strlen($plaats)5) { $fout.=Vul een geldige woonplaats in.br; } if (strlen($tel)10 || strlen($mobiel)10) { $fout.=Een telefoonnummer bestaat uit minimaal 10 cijfers.br; } if ($fout) { $fout.=brKlik a href=javascript:history.go(-1)hier/a om de invoer te verbeteren.; echo h1FOUTE INVOER/h1; echo $fout; } else { srand((double)microtime()*100); $mailcode= rand(1000,); if ($register=mysql_query(INSERT INTO TEST VALUES('','$naam','$voornaam','$geslacht','$geboortedatum','$adres','$postco de','$plaats','$tel','$mobiel','$email','$nationaliteit','$opleiding','$rijb ewijzen','$cat1','$cat2','$cat3','$van','$tot','$ervaring','$info','$mailcod e','0'))) { //variabalen declareren voor te versturen verificatie mail /* recipients */ $recipient.= $voornaam $naam $email ; /* subject */ $subject= E-mail verificatie TEST; /* message */ $message.= Beste . $voornaam.,\n\n ; $message.= Je hebt je ingeschreven op de website van TEST.\n\n; $message.= Om je inschrijving definitief te maken klik je op onderstaande link.\n\n; $message.= http://notnamed.com/validate/validate.php?code=.$mailcode.\n\n;; $message.= Staat je emailprogramma niet toe om email-links te volgen kun je ook de volgende URL intypen:\n\n; $message.= http://notnamed.com/validate/validate.php\n\n;; $message.= Daar vul je dan de volgende code in:\n.$mailcode.\n\n; $message.= Noteer deze persoonlijke code!\n.$mailcode.\n\n; $message.= Deze code, samen met je emailadres geeft je de mogelijkheid\n\n; $message.= om te reageren op vacatures en je gegevens aan te passen.\n\n; $message.= Met vriendelijke groet,\n\TEST; $headers= From: [EMAIL PROTECTED]\n; $headers.= X-Mailer: PHP\n; // mailer $headers.= Return-Path: [EMAIL PROTECTED]; // Return path for errors mail($recipient, $subject, $message, $headers); echo Uw gegevens zijn opgeslagen in het systeem.br; echo U heeft een e-mailbericht ontvangen met daarin verdere instructies om de inschrijving definitief te maken.br; echo Pas als u die instructies heeft opgevolgd is uw inschrijving definitief.br; } else { echo Er ging iets mis bij het invoeren in de database.brbr.mysql_error(); } } } else{ ? /p form method=post action=?echo $PHP_SELF;? table border=0 width=461 tr td width=127Naam/td td colspan=3 input type=text size=20 name=naam /td /tr tr td width=127Voornaam/td td colspan=3 input type=text size=20 name=voornaam /td /tr tr td width=127Geslacht/td td colspan=3 input type=radio name=geslacht value=M checked Man input type=radio name=geslacht value=V Vrouw /td /tr tr td
RE: [PHP] Stuck on array, need a little help.
I still can't get this to do what I want: $bikes = array( Road = array( Trek = array( Trek 5200 = road.php?brand=t5200 ), LeMond = array( Zurich = road.php?brand=zurich, Chambery = road.php?brand=chambery, Alpe d'Huez = road.php?brand=alpe, BuenosAries = road.php?brand=bueno, Tourmalet = road.php?brand=tourmalet ), Moots = array( VaMoots = road.php?brand=vamoots ) ), ); if ($cat == 'bikes') { while (list($key, $val)=each($bikes[$sub_cat])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/TD\n; echo TDA HREF=\$val\ CLASS=\menu\$key/A/TD\n; while (list($sub_key, $sub_val) = each($val)) { echo TDA HREF=\$sub_val\ CLASS=\menu\$sub_key/a/td\n; } } } Will produce: Trek Trek 5200 LeMond Zurich Chambery Alpe d'Huez BuenosAries Tourmalet Moots VaMoots as it should... But, I need it to produce: Trek LeMond Moots Trek 5200 Zurich Chambery Alpe d'Huez BuenosAries Tourmalet VaMoots And I need to get the value of $sub_val in the nested while loop to where $val is in the outer loop. I'm really stuck, any suggestions?? -Brian ** -Original Message- From: Jim Musil [mailto:[EMAIL PROTECTED]] Sent: Friday, November 30, 2001 5:26 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Stuck on array, need a little help. The script is still working right, you just need to nest another while loop into your current while loop. Like so ... if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo trtd$val/td; while (list($sub_val, $sub_key) = each($key)) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/td\n; echo TDA HREF=\$sub_key\ CLASS=\menu\$sub_val/a/td\n; } } } alternatively, if you know specifically what you want you could do this ... if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat][Trek])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/td\n; echo TDA HREF=\$key\ CLASS=\menu\$val/a/td\n; } } No, all that will do is reverse the placement of the values. So now it prints out Array and puts the item in the URL. Still the same problem. -Original Message- From: Jim Musil [mailto:[EMAIL PROTECTED]] Sent: Friday, November 30, 2001 4:54 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Stuck on array, need a little help. Your script is working like you are asking it to ... Change ... while (list($val, $key)=each($bikes[$sub_cat])) { To ... while (list($key, $val)=each($bikes[$sub_cat])) { and it should work like you WANT it to ... I'm stuck. $key returns Array how can I get at each level of this array? if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/TD\n; echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n; $bikes = array( Road = array( Trek = array( Trek 5200 = road.php?brand=t5200 ), LeMond = array( Zurich = road.php?brand=zurich, Chambery = road.php?brand=chambery, Alpe d'Huez = road.php?brand=alpe, BuenosAries = road.php?brand=bueno, Tourmalet = road.php?brand=tourmalet ), Moots = array( VaMoots = road.php?brand=vamoots ) ), Mountain = array( Trek = array( Fuel 100 = mountain.php?brand=tfuel90, Fuel 90 = mountain.php?brand=schhg ), Klein = array( bike 1 = URL, bike 2 = URL ), Gary Fisher = array( bike 1 = URL, bike 2 = URL ), Moots = array( bike 1 = URL, bike 2 = URL ) ), -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212
[PHP] Stuck on array, need a little help.
I'm stuck. $key returns Array how can I get at each level of this array? if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/TD\n; echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n; $bikes = array( Road = array( Trek = array( Trek 5200 = road.php?brand=t5200 ), LeMond = array( Zurich = road.php?brand=zurich, Chambery = road.php?brand=chambery, Alpe d'Huez = road.php?brand=alpe, BuenosAries = road.php?brand=bueno, Tourmalet = road.php?brand=tourmalet ), Moots = array( VaMoots = road.php?brand=vamoots ) ), Mountain = array( Trek = array( Fuel 100 = mountain.php?brand=tfuel90, Fuel 90 = mountain.php?brand=schhg ), Klein = array( bike 1 = URL, bike 2 = URL ), Gary Fisher = array( bike 1 = URL, bike 2 = URL ), Moots = array( bike 1 = URL, bike 2 = URL ) ), -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Stuck on array, need a little help.
Your script is working like you are asking it to ... Change ... while (list($val, $key)=each($bikes[$sub_cat])) { To ... while (list($key, $val)=each($bikes[$sub_cat])) { and it should work like you WANT it to ... I'm stuck. $key returns Array how can I get at each level of this array? if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/TD\n; echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n; $bikes = array( Road = array( Trek = array( Trek 5200 = road.php?brand=t5200 ), LeMond = array( Zurich = road.php?brand=zurich, Chambery = road.php?brand=chambery, Alpe d'Huez = road.php?brand=alpe, BuenosAries = road.php?brand=bueno, Tourmalet = road.php?brand=tourmalet ), Moots = array( VaMoots = road.php?brand=vamoots ) ), Mountain = array( Trek = array( Fuel 100 = mountain.php?brand=tfuel90, Fuel 90 = mountain.php?brand=schhg ), Klein = array( bike 1 = URL, bike 2 = URL ), Gary Fisher = array( bike 1 = URL, bike 2 = URL ), Moots = array( bike 1 = URL, bike 2 = URL ) ), -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212-629-0004 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Stuck on array, need a little help.
The script is still working right, you just need to nest another while loop into your current while loop. Like so ... if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo trtd$val/td; while (list($sub_val, $sub_key) = each($key)) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/td\n; echo TDA HREF=\$sub_key\ CLASS=\menu\$sub_val/a/td\n; } } } alternatively, if you know specifically what you want you could do this ... if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat][Trek])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/td\n; echo TDA HREF=\$key\ CLASS=\menu\$val/a/td\n; } } No, all that will do is reverse the placement of the values. So now it prints out Array and puts the item in the URL. Still the same problem. -Original Message- From: Jim Musil [mailto:[EMAIL PROTECTED]] Sent: Friday, November 30, 2001 4:54 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Stuck on array, need a little help. Your script is working like you are asking it to ... Change ... while (list($val, $key)=each($bikes[$sub_cat])) { To ... while (list($key, $val)=each($bikes[$sub_cat])) { and it should work like you WANT it to ... I'm stuck. $key returns Array how can I get at each level of this array? if ($cat == 'bikes' $sub_cat != 'Road') { while (list($val, $key)=each($bikes[$sub_cat])) { echo TDIMG SRC=\images/spacer.gif\ WIDTH=\25\ HEIGHT=\1\ ALT=\\ BORDER=\0\/TD\n; echo TDA HREF=\$key\ CLASS=\menu\$val/A/TD\n; $bikes = array( Road = array( Trek = array( Trek 5200 = road.php?brand=t5200 ), LeMond = array( Zurich = road.php?brand=zurich, Chambery = road.php?brand=chambery, Alpe d'Huez = road.php?brand=alpe, BuenosAries = road.php?brand=bueno, Tourmalet = road.php?brand=tourmalet ), Moots = array( VaMoots = road.php?brand=vamoots ) ), Mountain = array( Trek = array( Fuel 100 = mountain.php?brand=tfuel90, Fuel 90 = mountain.php?brand=schhg ), Klein = array( bike 1 = URL, bike 2 = URL ), Gary Fisher = array( bike 1 = URL, bike 2 = URL ), Moots = array( bike 1 = URL, bike 2 = URL ) ), -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212-629-0004 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Jim Musil - Multimedia Programmer Nettmedia - 212-629-0004 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] stuck
Hi, Can someone please tell me what is wrong with this page. The problem is that my option block is always stuck on the last record in the table. No matter what option I choose, the information, address, city, state...etc, that is passed is always the one of the last record in the table...Help! ? session_start(); session_register(address); session_register(city); session_register(state); session_register(zip_code); session_register(country); session_register(company); session_register(occupation); session_register(telephone); session_register(fax); $db_name = contact; $table_name = company; $connection = @mysql_connect(l, c, c) or die(Couldn't connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); $sql = SELECT * FROM $table_name ; $result = @mysql_query($sql,$connection) or die(Couldn't execute query.); while ($row = mysql_fetch_array($result)) { $uid = $row['uid']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip_code = $row['zip_code']; $country = $row['country']; $company = $row['company']; $occupation = $row['occupation']; $telephone = $row['telephone']; $fax = $row['fax']; $option_block .= option value=\$uid\$company/option; } $display_block = FORM METHOD=post ACTION=show_adduserbycompany.php PstrongCompany:/strong select name=\uid\ $option_block /select INPUT TYPE=\SUBMIT\ NAME=\submit\ VALUE=\Select this Company\/P /form ; ? HTML HEAD TITLEUser Information: Add a User/TITLE /HEAD BODY h1 User Information/h1 h2emAdd a User/em/h2 PSelect a company from the list below, to continue to the user addition./p ? echo $display_block; ? pa href=contact_menu.phpReturn to Main Menu/a/p /BODY /HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] stuck
You need to put the info in an array for all record to be available, like this: while ($row = mysql_fetch_array($result)) { $uid[] = $row['uid']; $address[] = $row['address']; $city[] = $row['city']; $state[] = $row['state']; $zip_code[] = $row['zip_code']; $country[] = $row['country']; $company[] = $row['company']; $occupation[] = $row['occupation']; $telephone[] = $row['telephone']; $fax[] = $row['fax']; and to get it out again, you need to use a for loop for ($i = 0; $i count($uid); $i++) { echo $uid[$i]; ... } Hope this helps, Jan De Luyck -Original Message- From: Jeremy Morano [mailto:[EMAIL PROTECTED]] Sent: Friday, August 17, 2001 6:05 PM To: [EMAIL PROTECTED] Subject: [PHP] stuck Hi, Can someone please tell me what is wrong with this page. The problem is that my option block is always stuck on the last record in the table. No matter what option I choose, the information, address, city, state...etc, that is passed is always the one of the last record in the table...Help! ? session_start(); session_register(address); session_register(city); session_register(state); session_register(zip_code); session_register(country); session_register(company); session_register(occupation); session_register(telephone); session_register(fax); $db_name = contact; $table_name = company; $connection = @mysql_connect(l, c, c) or die(Couldn't connect.); $db = @mysql_select_db($db_name, $connection) or die(Couldn't select database.); $sql = SELECT * FROM $table_name ; $result = @mysql_query($sql,$connection) or die(Couldn't execute query.); while ($row = mysql_fetch_array($result)) { $uid = $row['uid']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip_code = $row['zip_code']; $country = $row['country']; $company = $row['company']; $occupation = $row['occupation']; $telephone = $row['telephone']; $fax = $row['fax']; $option_block .= option value=\$uid\$company/option; } $display_block = FORM METHOD=post ACTION=show_adduserbycompany.php PstrongCompany:/strong select name=\uid\ $option_block /select INPUT TYPE=\SUBMIT\ NAME=\submit\ VALUE=\Select this Company\/P /form ; ? HTML HEAD TITLEUser Information: Add a User/TITLE /HEAD BODY h1 User Information/h1 h2emAdd a User/em/h2 PSelect a company from the list below, to continue to the user addition./p ? echo $display_block; ? pa href=contact_menu.phpReturn to Main Menu/a/p /BODY /HTML -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] stuck
I'm not 100% sure what you want to accomplish here, or why it is stuck on the last row, but I've made some observations. On Friday 17 August 2001 09:05 am, you wrote: ? session_start(); session_register(address); session_register(city); session_register(state); session_register(zip_code); session_register(country); session_register(company); session_register(occupation); session_register(telephone); session_register(fax); -Session register variables that were supposed to have been passed by a form. For a piece of test code you may want to execute this to see what variables and values were passed. I think only UID and company have been passed via the uid select. echo 'preFrom variables were:BR', print_r($HTTP_POST_VARS), '/pre'; while ($row = mysql_fetch_array($result)) { $uid = $row['uid']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip_code = $row['zip_code']; $country = $row['country']; $company = $row['company']; $occupation = $row['occupation']; $telephone = $row['telephone']; $fax = $row['fax']; $option_block .= option value=\$uid\$company/option; } -Here you've requested a bunch of info back from your query, but you only use uid and company in the option form, so you never actually pass the other info back to be registered by the session in your first lines. You could simplify with: $option_block = NULL; while ($row = mysql_fetch_array($result)) { $option_block .= 'option value='.$row['uid'].''.$row['company']. '/option'; } you may also want to do an echo in this block, or examine your html source to make sure you are getting back the values you request, and make sure that uid is unique to each row. ...if you need the other info you may want to do a query for it after the UID and company have been passed via the form on the second iteration, and then sess register them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]