PHP - Getting Errors/warnings On The Web Server But Not On Development Machine
In php.ini on my local development server, error_reporting is set to
Quote error_reporting = E_ALL | E_STRICT And I get no errors. However, on the remote web server I found a bunch of warnings in the error log. I fixed most of them, but this error/warning should have popped up on my development console: Quote [02-Dec-2011 17:47:22] PHP Warning: array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /home/bpslk/public_html/cart-checkout.php on line 177 [02-Dec-2011 17:47:22] PHP Warning: Invalid argument supplied for foreach() in /home/bpslk/public_html/cart-checkout.php on line 177 I can fix the code to eliminate the warning, no prob. But why am I NOT seeing this error on my development machine? --Thanks --HarryG Similar Tutorialshello and good day dear php-freaks which is the passwd for the mysql db run opensuse - therein i have installed a myql serfver and an apache now i want to port over a cms-system from a server to the localhost. question: the passwd of the configuriatin of the cms has got the following db connecgtion host : localhost db-name db-passwd question: does the db passwd need to match the passwd of the local mysql server!? is this true love to hear from you Hey guys just thought I'd introduce myself as it's a polite thing to do.
My name is Nick I am currently a front end developer and love learning new technologies so it looks like PHP is my next step.
I hope to learn and give whatever knowledge I can back
I have the following socket server. <?php class Controller public function doSomething($conn):void { $foo=new SomeClassWhichDoesntExist(); } } require 'vendor/autoload.php'; $server = new \React\Socket\TcpServer($settings['url'].':'.$settings['port'], \React\EventLoop\Factory::create()); $server->on('connection', function (\React\Socket\ConnectionInterface $rawSocket) { $conn = new LengthPrefixStream($rawSocket); $conn->on('data', function($data) use ($conn){ $controller->doSomething($conn); }); $rawSocket->on('error', function($error, $conn) {exit('error';}); $rawSocket->on('close', function() use ($conn) {exit('close';}); $conn->on('error', function($error, $conn) {exit('error';}); $conn->on('close', function() use ($conn) {exit('close';}); }); $server->on('error', function (Exception $e) {exit('server error';}); Turns out Controller::doSomething() is trying to create a new SomeClassWhichDoesntExist, but since it doesn't exist, composer doesn't require it and then PHP throws an error. But the error is caught by FulfilledPromise::then(), and then appears to eventually be ignored and an exception is never thrown, and the loop continues. In the past, I've always been able to catch these errors, but must have changed something. Any thoughts what might have changed to prevent errors from being caught? namespace React\Promise; class FulfilledPromise implements ExtendedPromiseInterface, CancellablePromiseInterface { public function then(callable $onFulfilled = null, callable $onRejected = null, callable $onProgress = null) { if (null === $onFulfilled) { return $this; } try { return resolve($onFulfilled($this->value)); } catch (\Throwable $exception) { return new RejectedPromise($exception); //<===== Caught here } catch (\Exception $exception) { return new RejectedPromise($exception); } } }
ok people sorry but its late, and I'm tired and I can't figure this out maybe I just need a break? I'm getting some warnings here, first here is my code: Code: [Select] <?php echo"<?xml version=\1.0\"encoding=\UFT-8\"\x3f>"; echo"\n"; ?> <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"lang="en"> <head> <title>Assignment 7: Making Space, Part 3</title> <meta name="author" content="Jim Cozzy"/> </head> <body> <h1> Assignment 7: Making Space, Part 3 </h1> <?php echo "<h2>Today is ".date('l, F d, Y')."</h2>"; ?> <?php //calculate the area of an equilateral triangle function calcTriangle($cVal) { $halfSide = $cVal/2; $otherSide = sqrt(($cVal*$cVal) - ($halfSide*$halfSide)); $areaValue = $otherSide * $halfSide; echo "<p>The area of an equilateral triangle whose sides are {$cVal} is {$areaValue}.</p>\n"; } $yeah = (isset($_POST['vfld']))?$_POST['vfld']:''; if (isset($_POST['submit'])) { if ($_POST['submit'] == "Clear") { $yeah = ""; } elseif ($_POST['submit'] == "Calculate") { if (!eregi(square|circle|triangle, $yeah)) { echo "<p>Sorry I forgot to mention the the shape needs to be a Square, Circle, or a Triangle.</p>". "<p>Please return and try again.</p>"; exit; } }} ?> <form method="post" action="makingspace3.php" id="form1" name=form1"> <p> Write down a shape and a number and I will compute the area for: <input type="text" id="vfld" name="vfld" value="<?php echo $yeah; ?>"/> </p> <p> After you have done this click calcualte to see results </p> <p> <input type="submit" name="submit" value="Calculate" /> <input type="submit" name="submit" value="Clear" /> </p> </form> <div id="footer"> <pre>This page written by: <cite>James Cozzy</cite> ©2011 and beyond</pre> </div> </body> </html> so when I enter something wrong into my form like ggggg I want it to print an error which it does, but it also says what am I missing???? Notice: Use of undefined constant square - assumed 'square' in /studfs1/homepage/CISS-225/makingspace3.php on line 49 Notice: Use of undefined constant circle - assumed 'circle' in /studfs1/homepage/CISS-225/makingspace3.php on line 49 Notice: Use of undefined constant triangle - assumed 'triangle' in /studfs1/homepage/CISS-225/makingspace3.php on line 49 Okay I have been trying to work out this problem for 3 months I am not the type of person to give up but I have tried everything. I was first not able to connect to my database live with my form but I did a change from ($cxn,$sql) to ($sql,$link) since then I was able to download to phpmyadmin in Google Chrome and no other site. But in Google Chrome I get a message about global registry Warning: Unknown on line 0. all other sites give me a Warning line 116 MySql Link is Here is my coding can someone help I have only been using PHP and I know someone is out there with much more knowledge than I have. This is the first page with the codes but it does not go to the second page which I will paste after this one. Any help would make my year better. Code: [Select] <php @session_start(); switch (@$_POST['Button']) { case "Login1": include "Connections/connect_to_mysql.php"; $sql = "SELECT id FROM Members WHERE id= '$_POST[fusername]'"; $result = mysql_query($sql) or die("Query died: fusername"); $num = mysql_num_rows($result); if($num > 0) //login name was found { $sql = "SELECT id FROM Members WHERE id='$_POST[fusername]' AND password=md5('$_POST[fpassword])'"; $result2 = mysql_query($sql) or die("Query died: fpassword"); $num2 = mysql_num_rows($result2); if($num2 > 0) //password matches { $_SESSION['email1']="yes"; $_SESSION['id'] = $_POST['fusername']; $sql = "INSERT INTO Members (id,loginTime) VALUES ('$_SESSION[id]',NOW())"; $result = mysql_query($sql) or die("Query died: insert"); header("Location: New_member.php"); } else //password does not match { $message_1="The username, '$_POST[fusername]' exists, but you have not entered the correct password! Please try again."; $fusername=strip_tags(trim($_POST['fusername'])); include("login_form.php"); } } else //username not found { $message_1 = "The username you entered does not exist! Please try again."; include("login_form.php"); } break; case "Register": /* Check for blanks */ foreach($_POST as $field => $value) { if($field != "fax") { if(empty($value)) { $blanks[] = $field; } else { $good_data[$field] = strip_tags(trim($value)); } } } if(isset($blanks)) { $message_2 = "The following fields are blank. Please enter the required information: "; foreach($blanks as $value) { $message_2 .="$value, "; } extract($good_data); include("login_form.php"); exit(); } /* validate data */ foreach($_POST as $field => $value) { if(preg_match("/name/i",$field) and !preg_match("/user/i",$field) and !preg_match("/log/i",$field)) { if (!preg_match("/^[A-Za-z' -]{1,50}$/",$value)) { $errors[] = "$value is not a valid name. "; } } if(preg_match("/email/i",$field)) { if(!preg_match("/^.+@.+\\..+$/",$value)) { $errors[]="$value is not a valid email addr."; } } } //end if not empty foreach($_POST as $field => $value) { $$field = strip_tags(trim($value)); } if(@is_array($errors)) { $message_2 = ""; foreach($errors as $value) { $message_2 .= $value." Please try again<br />"; } include("login_form.php"); exit(); } // end if errors are found /* check to see if username already exists */ include_once"Connections/connect_to_mysql.php"; $link = @mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); @mysql_select_db("$db_name") or die ("Query died:"); $sql = "SELECT id FROM Members WHERE id='$id'"; $result = mysql_query($sql) or die("Query died: id."); $num = mysql_num_rows($result); if($num > 0) { $message_2 = "$id already used. Select another User Name."; include("login_form.php"); exit(); } // end if username already exists else // Add new member to database { $sql = "INSERT INTO Members (id,sign_up_date,username password,firstName,lastName,email) VALUES ('$id',NOW(),,md5('$password'), '$username','$firstName','$lastName','$email')"; mysql_query($sql); $_SESSION['email1']="yes"; $_SESSION['id'] = $username; /* send email to new Customer */ $emess = "You have successfully registered. "; $emess .= "Your new username and password a "; $emess .= "\n\n\t$username\n\t"; $emess .= "$password\n\n"; $emess .= "We appreciate your interest. \n\n"; $emess .= "If you have any questions or problems,"; $emess .= " email ebermylove@gmail.com"; $subj = "Your new customer registration"; # $mailsend=mail ("$email","$subj","$emess"); } break; default: include("login_form.php"); } ?> <php session_start(); if (@$_SESSION['auth'] != "yes") { header("Location: login.php"); exit(); include("dogs.inc"); $link = mysqli_connect($host,$user,$password,$dbname) or die("Couldn't connect to server."); $sql = "SELECT firstName, lastName FROM `Members` WHERE id='{$_SESSION['id']}'"; $result = mysqli_query($sql,$link) or die("Couldn't execute query"); $row = mysqli_fetch_assoc($result); extract($row); } echo "<html> <head><title>New Member Welcome</title></head> <body> <h2 style='margin-top: .7in; text-align: center'> Welcome $firstName </h2>\n"; ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise for experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="member_page.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="profile.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> Is there any way to catch warnings without defining a warning handler? Example: try { $settings = parse_ini_file( 'main.ini' ); } catch( ErrorException $e ) { throw new ErrorException('No main configuration file found for webiste', '0003'); } Only ends up throwing a warning if the file doesn't exist. I want to catch it and throw an error. Howdy, this one is killing me! Hope some of the genius here will rub off on me. Very simple example of what is happening: Base.php Code: [Select] class Base_Model //class autoloaded { protected function scrub($value) { return trim(htmlspecialchars($value, ENT_QUOTES, "UTF-8")); } } Foo.php Code: [Select] class Foo_Model extends Base_Model { if($_POST) { $_POST = array_map('parent::scrub', $_POST); } } This works perfectly on the workstation (MAMP) server, but generates a warning ( Warning: array_map() [function.array-map]: The first argument, 'parent::scrub', should be either NULL or a valid callback in... ) when uploaded to the production server. Both are running the exact same version of php. Any ideas would be appreciated on getting rid of the error, besides turning off warnings ( haha ). William Hey all. I have a function called displayForm in a form validation script. This function accepts a few arguments but these arguments are empty upon initial calling of the function. One of the arguments is and errors array that only gets populated if there were form errors. So upon running my script initially I get missing argument Warnings. Can these warnings simply be ignored? Would they cause problems throughout my script if I ignore these warnings? And how can I suppress these warnings if I would like to? Thanks all for your help. Cheers. I use PHP's PDO extensively for data grabbing and inserting. When I am selecting data, the return is a PHP PDO object which in itself contains select statements. So I use foreach to parse through the object and build a table. For cells which I have data it's fine but for cells which do not get any data meaning that have no entry in the db, php throws out a error PHP Warning: Invalid argument supplied for foreach(). I tried using if(is_array) and also @ to suppress them but no luck . Can anyone point me to the right direction for suppressing these errors/warnings!! Hi everyone, I'm trying to get the name of the machine in use. If I use this feature locally, it works.
function visitor_machine_name(){
return $machine_name;
But as soon as I try it on an online server I get the DNS name back, like this:
What can I do? Hello, I was trying out some code to check out how some of the php settings work and when i tried allow_call_time_pass_reference to see if it works, it doesn't spew out any warning or error like the comments in the .ini file mention (or in the manual sites). Maybe i'm not using some other setting in order to see this? Here is my EXACT code. <?php ini_set('display_errors',1); error_reporting(-1); $variable = 'String'; function display($variable) { return $variable; } echo display(&$variable); ?> Outputs : String. No errors, no warnings. I'm running PHP Version 5.3.2-1ubuntu4.5 Does any one know where I can find a PHP slots machine script? Is there a way to get my visitors PC or Device Name? I am not looking for server name or ip. I need to get my current visitors computer name. Example: MAIN, HOME, OFFICE, TOM32154}}{|\] like when first naming a PC with a new windows install. Could Someone Help Me Make A Gumball Machine My Site Is Toxicpets.co.cc And the page is gumballs.php but i need it to give gumballs I am trying to make a gumball machine on my site which gives you a gumball every time you click the button. This is the code I am using to generate a gumball: Code: [Select] <?php $balltype = rand(1,50); if ($balltype = 1) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 2) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 3) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 4) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30978','1','1')"); $gummy = "You won a <b>Blue Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_blue.gif" width="80" height="80" border="0">'; } elseif ($balltype = 5) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 6) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 7) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 8) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30983','1','1')"); $gummy = "You won a <b>Green Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_green.gif" width="80" height="80" border="0">'; } elseif ($balltype = 9) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 10) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 11) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 12) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30985','1','1')"); $gummy = "You won an <b>Orange Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_orange.gif" width="80" height="80" border="0">'; } elseif ($balltype = 13) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 14) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 15) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 16) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30986','1','1')"); $gummy = "You won a <b>Purple Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_purple.gif" width="80" height="80" border="0">'; } elseif ($balltype = 17) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 18) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 19) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 20) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30990','1','1')"); $gummy = "You won a <b>Yellow Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_yellow.gif" width="80" height="80" border="0">'; } elseif ($balltype = 21) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 22) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 23) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30981','1','1')"); $gummy = "You won a <b>Cola Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_cola.gif" width="80" height="80" border="0">'; } elseif ($balltype = 24) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 25) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 26) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30979','1','1')"); $gummy = "You won a <b>Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_bronze.gif" width="80" height="80" border="0">'; } elseif ($balltype = 27) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 28) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 29) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30984','1','1')"); $gummy = "You won an <b>Ice Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_ice.gif" width="80" height="80" border="0">'; } elseif ($balltype = 30) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 31) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 32) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30987','1','1')"); $gummy = "You won a <b>Rock Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_rock.gif" width="80" height="80" border="0">'; } elseif ($balltype = 33) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 34) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 35) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30988','1','1')"); $gummy = "You won a <b>Strawberry Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_strawberry.gif" width="80" height="80" border="0">'; } elseif ($balltype = 36) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30980','1','1')"); $gummy = "You won a <b>Dark Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_chocolate2.gif" width="80" height="80" border="0">'; } elseif ($balltype = 37) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30980','1','1')"); $gummy = "You won a <b>Dark Chocolate Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_chocolate2.gif" width="80" height="80" border="0">'; } elseif ($balltype = 38) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30977','1','1')"); $gummy = "You won a <b>Black Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_black.gif" width="80" height="80" border="0">'; } elseif ($balltype = 39) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30977','1','1')"); $gummy = "You won a <b>Black Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_black.gif" width="80" height="80" border="0">'; } elseif ($balltype = 40) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30982','1','1')"); $gummy = "You won a <b>Digital Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_digital.gif" width="80" height="80" border="0">'; } elseif ($balltype = 41) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30982','1','1')"); $gummy = "You won a <b>Digital Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_digital.gif" width="80" height="80" border="0">'; } elseif ($balltype = 42) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30989','1','1')"); $gummy = "You won a <b>Silver Gumball</b>."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gum_silver.gif" width="80" height="80" border="0">'; } elseif ($balltype = 43) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 44) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 45) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 46) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 47) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 48) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 49) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } elseif ($balltype = 50) { mysql_query("INSERT INTO usersitems2 (owner,item_id,parts_left,game) VALUES ('$userid','30991','1','1')"); $gummy = "You won a <b>Burnt Gumball</b>. Ur... Well done..."; $picture = '<img src="http://www.bubblemagic.co.cc/images/gumballs/gumball_burnt.gif" width="80" height="80" border="0">'; } else { $gummy = "Nooooooooo!!!!! The gumball machine is broken!!! It still took your money though..."; } ?> Every time I try it, it gives me a burnt gumball EDIT: All that CODE hurts.... use some CODE formatting for godsakes. Sooo i got this idea but i dont know the line of code i should write +im an amateur coder. Anyone know how to make the 123d catch into a web application. Just gv me a start and ill modify the code slowly. And 1 more thing.. Does anybody know how 123d catch was able to combine the pictures into 3d. Like if you know can u also gv me the code.. appr3ciated alot. and also do u know how to make like if someone press the pic and moves to the left the 3d picture will move to the left also Hi all, Php and web development wannabe, started HTML in about 2006 for my ebay listings, CSS came shortly after but it wasn't until maybe 2009 when I used my first 'someone-else's-php-script' to implement a dynamic breadcrumb. Although I have trouble reading volumes of text, a lot of discussions on code draw me in. I end up taking in a lot but in a totally non-structured way. After lots of googling, reading and some more practice of putting 'other-people's-php' into action I found I understood that breadcrumb... Sort of. I merrily tore out over half the code and refactored using ternary operators - I can't see why people remove those to increase readability?? OFC I lost every hint of error management! Now I've heard of error management I try to envisage what might go wrong and print messages to screen if "something unexpected happened". So I've been bumbling along solving problems for specific tasks and asking a lot of questions - But I've never joined a php forum! Formulating a question that's not embarrassing to ask, usually ends with me answering my own question and when I do want to put something out there, I'd rather fill up Yahoo Answers (A few very good and very generous users on there!) with my gibberish than contaminate someone's proper, serious, scripting forum. So anyway, I had a question to ask earlier, YA seems to be running out of steam and I only half answered it myself so here I am... Hi! Hi, I'm not sure if this is the right place to post this but it seems to be acceptable. Please let me know if it's out of line, though. I recently started learning PHP and am going through PHP and MYSQL Web Development. It seems like a pretty good book so far. Currently I'm working through the code in chapter 1 and am running into an issue. From what I can tell, the code I should have at this point is as follows: <html> <head> <title>Bob's Auto Parts - Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php // create short variable names $tireqty = $_POST('tireqty'); $oilqty = $_POST('oilqty'); $sparkqty = $_POST('sparkqty'); echo "<p>Order processed at "; echo date('H:i, jS F Y'); echo "</p>"; echo "<p>Your order is as follows: </p>"; echo $tireqty.' tires<br />'; echo $oilqty.' bottles of oil<br />'; echo $sparkqty.' spark plugs<br /'>'; ?> </body> </html> Within the PHP script, two particular blocks of code seem to be giving me problems: $tireqty = $_POST('tireqty'); $oilqty = $_POST('oilqty'); $sparkqty = $_POST('sparkqty'); and echo "<p>Your order is as follows: </p>"; echo $tireqty.' tires<br />'; echo $oilqty.' bottles of oil<br />'; echo $sparkqty.' spark plugs<br /'>'; Without these two blocks, the rest of the PHP executes but when I add one or both of these the PHP doesn't show up at all; instead it only executes the HTML and the output from the PHP doesn't show up. IF I remove these and only keep the "Order processed at" part of the script, that part executes fine. I've gone through the code in the book and it seems like what I have is correct. As soon as I try to define or call any of the variables, it seems to break the code. Any ideas? Sorry to bother you with such a basic question but I can't seem to locate a problem with this code based on what I've been taught so far. Thanks! If any of you have developed mobile apps before I could really use some advice, please. I have never made one, and would like to for my website. I just need to query my database and display the information. From what I have been able to put together so far, I know that I can use css and jquery fine. My main question is: can I use php to query the mysql database? Pretty much I am a novice, so if using these languages together will not work, please feel free to suggest combinations that would be better. Although, I am trying to avoid as much object oriented stuff as I can, because I just don't get it entirely, but I'll still take the suggestion. Thanks. |