PHP - Upgrade Or Implimentation Problem
I am UPGRADING some old files to MySQLi and while doing so have decided to complete some leftover projects. In this project, I was counting vegetables sold to customers that displayed a report displaying information like this:
There were 3 orders for carrots for 1 lbs. each The code I used to generate the messages was: while($row = mysqli_fetch_array($result)){ echo "There were ". $row['COUNT(carrots)'] ." orders for carrots for ". $row['carrots'] ." lbs. each <br />"; } At the time, I was going to call a separate script for carrots, potatoes, and celery. Now, with my worldly advancement (or maybe not.. LOL) I realize I should be able to use the same single script and assign a variable to accommodate each vegetable item. After declaring the $item = 'carrots' I inserted it to test my theory. I tested the output in stages and all seemed okay until I did this: while($row = mysqli_fetch_array($result)){ echo "There were ". $row['COUNT($item)'] ." orders for carrots for ". $row['$item'] ." lbs. each <br />"; } Is there an issue with using a variable inside a $row? Is there a syntax error (no error messages)? Perhaps a MySQLi addition that is required? Similar TutorialsHi guys, a few days i upgrade php from 5.1 to 5.2.16 all seem fine and last 2 days i start to find some bugs. I use this code to get url var and pass from a form: <?php echo $_GET['id']; ?> <input name="ids" type="hidden" id="ids" value="<?php $_GET['id'];?>" /> In the email i receive all data from the form, but not this that i get from the URL. in code to send to email i just use: $_POST[id] This work fine in 5.1 but not in this version. anyone have an idea why? Wipe I have 2 pages in my flash site that call some PHP files. The pages are a feedback page and a locator page. When my server went from PHP4 to PHP5 both pages stopped displaying the content. When I load the flash pages with Fiddler open, fiddler shows a 500 error on the PHP files that the flash is calling. I'm certain my database connections are good, file paths have not changed since the server maintenance, and I have .htaccess files except they are blank. Can anyone advise what I can do to find where the problem is? I have the PHP code below that showed the 500 errors. Any help would be really appreciated. This is the locator page: Code: [Select] <?php include_once('db_connect.inc.php'); $query = "SELECT state FROM stores group BY state ORDER BY state"; $result = mysql_query($query); if(mysql_num_rows($result)==NULL){ $r_string = '&error=1&msg=No Records Found.'; }else{ $r_string = '&error=0&n='.mysql_num_rows($result) . '&r_states='; $i = 0; $r=''; while ($row = mysql_fetch_assoc($result)) { if($r!='') $r .= '||'; $r .= $row['state']; $i++; } $r_string .= $r; // add extra & to prevent returning extra chars at the end $r_string .='&'; } echo $r_string; ?> This is the feedback page: Code: [Select] <?php include_once('inc/feedbackconn.inc.php'); echo '&rsult='; $query = "SELECT * FROM messages where active!=0"; $result = mysql_query($query); $num = @mysql_num_rows($result); $cfeed=$_POST['sFeed']; $cfeed--; $query = "SELECT * FROM messages where active='1' ORDER BY id LIMIT " . $cfeed . ',1'; $result = mysql_query($query); //$row = mysql_fetch_array($result); if($num==NULL){ echo "No Records."; exit(); } while($row = @mysql_fetch_array($result)){ $b_name = stripslashes($row[strName]); $b_loc = stripslashes($row[strLocation]); $b_mes = stripslashes($row[strMessage]); $b_id = $row[id]; $b_active = $row[active]; $feedArray[] = array("name"=>$b_name,"location"=>$b_loc,"feedback"=>$b_mes,"id"=>$b_id,"active"=>$b_active); } /* /////////////// DISPLAY THE RECORDS ///////////////// */ $numOfMessages = sizeOf($feedArray); for($i=0;$i<$numOfMessages;$i++){ //------------------------------------------------------------------ //echo $feedArray[$i]['id']."<br>\n"; echo '<b><i>' . $feedArray[$i]['feedback']."</i><br><br>"; echo $feedArray[$i]['name']."<br>"; echo $feedArray[$i]['location']."</b>"; //--------------------------------------------------------------------- } echo '&tFeeds=' . $num; echo '&cFeed=' . $_POST['sFeed']; ?> I've been out of coding for about 4 years. My client called and said that they upgraded his server and now nothing works. I've don't done some reading and see that there are changes to queries. I originally wrote the program using mysql_query which is now deprecated replaced with MySQLi and PDO_MySQL which I thought would be that simple. Apparently not. My code is below. The error I get is Fatal error: Call to undefined function MySQLi() in /home1/zipclick/public_html/marketingteamates.com/_ZABP_merchants/main-w.php on line 304 which leads me to believe that the upgrade is now solely object oriented.
$result = MySQLi( "SELECT * FROM $users WHERE username = '$username'" ) or die("SELECT Error: ". mysqli_errno()); $num_rows = mysqli_num_rows($result); while ($row = mysqli_fetch_array($result)) { extract($row); }
See below my website is showing like this
I think debian upgraded from php 7.3 or 4 to 8.0 I am wondering if I am missing some php packages if run php -v at terminal I get php -v PHP 8.0.7 (cli) (built: Jun 4 2021 23:17:30) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.7, Copyright (c) Zend Technologies with Zend OPcache v8.0.7, Copyright (c), by Zend Technologies and if I run php -m at terminal i get php -m [PHP Modules] calendar Core ctype date dom exif FFI fileinfo filter ftp gd gettext hash iconv json libxml mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql Phar posix readline Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlwriter xsl Zend OPcache zlib [Zend Modules] Zend OPcache
The Wordpress Atahualpa theme does not appear to be compatible with php 7.2. I know very little about php. I get the following error message in my error log: This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=355561.0 Hi everyone, would be grateful if anyone can help me. I recently changed my hosting package and didnt realize that the new package uses PHP 5. There is no option to use an earlier version but my thumbnail script that worked on PHP 4 just shows a red cross where the thumbnail should be. Can anyone tell me why the script below would not work with PHP 5. I have a basic understanding of how scripts work but I am not an expert so if you could make any replies easy to understand I have checked and the new server does have GD library version 2.0.34 installed - not sure if there is anything else I need to check ? script called: uktn.php Code: [Select] <? $maxwidth = 200; $maxheight = 200; $image_path = $_GET['im']; $ext = explode('.', $image_path); $i = count($ext)-1; if ($ext[$i] == 'jpg' || $ext[$i] == 'jpeg' || $ext[$i] == 'JPG' || $ext[$i] == 'JPEG' ) { $img = @imagecreatefromjpeg($image_path); } else if ($ext[$i] == 'png' || $ext[$i] == 'PNG') { $img = @imagecreatefrompng($image_path); } else if ($ext[$i] == 'gif' || $ext[$i] == 'GIF') { $img = @imagecreatefromgif($image_path); } if ($img) { $width = imagesx($img); $height = imagesy($img); $scale = min($maxwidth/$width, $maxheight/$height); if ($scale < 1) { $new_width = floor($scale*$width); $new_height = floor($scale*$height); $tmp_img = imagecreatetruecolor($new_width, $new_height); imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagedestroy($img); $img = $tmp_img; } } if (!$img) { exit ("You must specify an image!"); } header("Content-type: image/png"); imagepng($img,'',100); ?> Many thanks, Dave I have had a problem with some scripts I wrote (Screenscrapers) that worked great in PHP4, but stopped working the minute I upgraded to PHP5. I can change all of my filenames to have the .PHP4 extension and this solves the problem, but since this encompasses a number of sites, internal links and hundreds of files, this is not my first choice solution. Here is the scraper, what it does, is it takes items from the zazzle Results Page by category, strips out the formatting, adds my affiliate ID and then I can present these items on my page. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Test of scrape</title> <link rel="stylesheet" type="text/css" href="/css/scraper.css" /> <script type='text/javascript' src='http://www.zazzle.com/js/logging/omniture/s_code.zjs/r-52.78223/site-zazzle.js'></script> </head> <body> <div class="gridCell " id="page_productsGrid_assetCell1"> <?php $page = file_get_contents("http://www.zazzle.com/cool+smiley+gifts"); //comment out the <span> tags completely $page = preg_replace('/<span/', "<!-- <span", $page); $page = preg_replace('/<\/span>/', "<\/span> -->", $page); $page = preg_replace('/<a /', "<a rel=\"nofollow\" ", $page); $rf_id="238219236805025733"; // Regular expression to parse "&rf=" and the $rf_id into the existing link $page=preg_replace("/(.*?)(href\s*=+\s*[\"\'])(.*?)([\"\'])(.*?)/is","$1$2$3?rf=$rf_id$4$5",$page); $test = explode('<div style="position:relative" class="clearfix">',$page); for($t=1;$t<=count($test)-2;$t++){ print "<div class=\"gridCellInfo\" id=\"page_products\">"; print $test[$t]; } ?> </body> </html> This works find in PHP4; not at all in PHP5. My ideal solution would be an .htaccess file that I could put in any directory under PHP5 to make it default to php4. I have tried this, to no avail (.htaccess): Code: [Select] <IfModule mod_rewrite.c> RewriteEngine On AddType text/html .php4 AddHandler php4-script .php .html php5 </IfModule> I have also tried a few alternatives... this appears to be a common problem and I have scoured the web and found no solution. Here are the two pages in PHP4 and PHP5: php4: http://www.killersmiley.com/test/cool-smiley.php4 php5: http://www.killersmiley.com/test/cool-smiley.php Hello, I work for a non-profit agency and I have been up all night trying to fix a registration form that has suddenly stopped working after a php upgrade from v 5.0 to v 5.2. The server admin says it is my coding. When you hit submit the form actually does what it is supposed to however the missing link here is that I am not being emailed after each registration with the registraiton informationl. You can see the form in action at www.nctt.net/coreTest.php I have also cut and pasted the contents of that file below and have attached it to this email. There is also the last version of the form I used still up on the website that I never took down after our summer program. There are a few modifications to this page to meet the program requirements but in July www.nctt.net/SIReg.php was working fine. Any assitance, hints, suggestions, anything at all is welcome and I thnk you in advance for taking a loot. Jennifer <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>NCTT Registration Form</title> <style type="text/css"> body { margin: 10px padding: 0; font-size: 100%; } * { } h1.register { text-align: center; padding: 18px; background: #cc0033; color: #ffffff; font: 160% Arial, Helvetica, sans-serif; font-weight: bold; text-transform: uppercase; } h1.costs { margin: 10px 0 0 0; padding: 0; border-bottom: 5px solid #cccccc; font: 320% Arial, Helvetica, sans-serif; color: #0071b7; font-weight: bold; text-transform: uppercase; line-height: 1.5em; text-align: left; } h1.title { margin: 10px 0 0 0; padding: 0; border-bottom: 5px solid #cccccc; font: 180% Arial, Arial, Helvetica, sans-serif; color:#0071b7; font-weight: bold; text-transform: uppercase; line-height: 1.5em; text-align: left; } h1.regbox { color: #cc0033; font: 200% Trebuchet Ms, Arial; letter-spacing: -1px; margin: 0; padding: 0; text-align: center; } h1.side { letter-spacing: -1px; text-align: center; font: 140% Arial, Helvetica, sans-serif; font-weight: bold; color: #ffffff; padding: 0; margin: 0; } h2 { text-align: left; margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 170%; font-family: trebuchet ms; } h2.regbox { color: #0071b7; font: 140% Trebuchet Ms, Arial; letter-spacing: -1px; font-weight: bold; margin: 5px 0 0 0; padding: 0; text-align: center; } h2.enroll { color: #0071b7; font: 120% Trebuchet Ms, Arial; font-weight: bold; text-align: left; border-bottom: 3px solid #cccccc; margin: 15px 0 0 0;} h3 { margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 110%; font-family: trebuchet ms; } h4 { margin: 0; padding: 0; line-height: 1.8em; color: #cc0033; font-size: 90%; font-family: trebuchet ms; } p.normal { text-align: left; font: 75% Arial, Helvetica, sans-serif; line-height: 1.4em; margin: 5px; padding: 0; color: #000000; } .prices { border-bottom: 1px solid #ccc; color: #cc0033; line-height: 2em; font: 80% Arial, Helvetica, sans-serif; margin: 0; padding: 5px; } p.special { text-align: left; padding: 10px; margin: 5px 0 5px 0; background-color: #efefef; border: 1px solid #0071b7; font: 80% Arial, Helvetica, sans-serif; line-height: 1.5em; } p.normal1 { text-align: center; font: 75% Arial, Helvetica, sans-serif; line-height: 1.4em; margin: 5px; padding: 0; color: #000000; } span.price { border-bottom: 1px solid #ccc; color: #0071b7; line-height: 2em; font: 80% Arial, Helvetica, sans-serif; margin: 0; padding: 5px; } td.reg { background: #0071b7; border-bottom: 5px solid #0071b7; color: #ffffff; font-family: Arial, Helvetica, sans-serif; font-size: 150%; font-weight: bold; text-transform: uppercase; letter-spacing: -1px; } td.reg-line { border-bottom: 5px solid #0071b7; } td.title { font: 100% Arial, Helvetica, sans-serif; color: #000000; font-weight: bold; } label { font: 100% trebuchet ms, arial; color: #0071b7; font-weight: bold; } input { margin: 0; padding: 5px; } input.sub { padding: 10px; font-family: arial; color: #000033; font-size: 12pt; font-weight: bold; background: #ccc; text-transform: uppercase; } .success { color: #ffffff; background: #0071b7; font-weight: bold; font: 100% arial; border: 1px solid #000; padding: 10px; } .error { color: #fff; background: #FF0000; padding: 10px; border: 1px solid #990000; font: 90% arial; } a:link { text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #cc3333; text-decoration: underline; } a:active {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #ff9933; text-decoration: none; } a:visited {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #009933; text-decoration: underline; } a:hover {text-align: left; font: 125% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bold; padding: 0; color: #0099ff; text-decoration: none;} p.check {text-align: left; font: 110% Arial, Helvetica, sans-serif; line-height: 1.4em; font-weight: bolder; padding: 0; color: #cc0033; } </style> </head> <body> <center> <? if($_POST['submit']) { $first = $_POST['first_name']; $last = $_POST['last_name']; $middle = $_POST['middle_name']; $dob = $_POST['dob']; $module_1 = $_POST['module_1']; /*$module_2 = $_POST['module_2'];*/ $province = $_POST['province']; $address_1 = $_POST['address_1']; $address_2 = $_POST['address_2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $school = $_POST['school']; $country = $_POST['country']; $taught = $_POST['taught']; $grade = $_POST['grade']; $home = $_POST['home']; $work = $_POST['work']; $email = $_POST['email']; if(!empty($first) && !empty($last) && !empty($address_1) && !empty($city) && !empty($state) && !empty($zip) && !empty($home) && !empty($email)) { if($module_1) { $cost = $cost+195; $add_email .= "<li>December 5, 2014: YES ($195)</li>"; } /* if($module_2) { $cost = $cost+1075; $add_email .= "<li>Week II: YES ($1075)</li>"; } if(date("n") <= 15) { $before = $cost*.05; $before = round($before,2); $cost = $cost-$before; } */ $msg .= "<body style=\"font-family: arial; font-size: 10pt; line-height: 1.5em;\">"; $msg .= "<p>These are the registration details submitted from the website.</p>"; $msg .= "<ul>"; $msg .= $add_email; $msg .= "<li><strong>Name:</strong> " . $first . " " . $middle . " " . $last . "</li>"; $msg .= "<li><strong>Address One:</strong> " . $address_1 . "</li>"; $msg .= "<li><strong>Address Two:</strong> " . $address_2 . "</li>"; $msg .= "<li><strong>City:</strong> " . $city . "</li>"; $msg .= "<li><strong>State:</strong> " . $state . "</li>"; $msg .= "<li><strong>Zipcode:</strong> " . $zip . "</li>"; $msg .= "<li><strong>Province:</strong> " . $province . "</li>"; $msg .= "<li><strong>Country:</strong> " . $country . "</li>"; $msg .= "<li><strong>School:</strong> " . $school . "</li>"; $msg .= "<li><strong>Grade Taught:</strong> " . $grade . "</li>"; $msg .= "<li><strong>Field/Subject Taught:</strong> " . $taught . "</li>"; $msg .= "<li><strong>Home Phone:</strong> " . $home . "</li>"; $msg .= "<li><strong>Work Phone:</strong> " . $work . "</li>"; $msg .= "<li><strong>Email:</strong> " . $email . "</li>"; $msg .= "</ul>"; $msg .= "<p>Total Cost: $" . $cost . "</p>"; /* if($before) { $msg .= "<p>This was sent before April 15, 2013, so 5% has been taken off the total.</p>"; }*/ $msg .= "</body>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'From: donotreply@nctt.net'; $to = "info@nctt.net"; $subject = "Registration Form | " . $first . " " . $middle . " " . $last; mail($to,$subject,$msg,$headers); ?> <div class="success"> We have successfully sent your registration details to NCTT. Please click on "Add to Cart" below, and checkout with Paypal to complete your resgistration. <strong>Space will not be held for registration without payment unless you have contacted the office at 417-773-1654 and spoken to Jennifer to make special arrangements.</strong> <br /> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="info@nctt.net"> <input name="item_name" type="hidden" class="title" value="Registration: Critical Thinking, Reading, Writing and the Common Core "> <input type="hidden" name="amount" value="<? echo $cost; ?>"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="no_shipping" value="1" /> <input type="hidden" name="on0" value="name"> <input type="hidden" name="os0" maxlength="60" value="<? echo $first . " " . $middle . " " . $last; ?>"> <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="add" value="1"> </form><!--<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="business" value="info@nctt.net"> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> <input type="hidden" name="display" value="1"> </form>--> </div> <? } else { echo "<div class=\"error\">Sorry, please fill out all of the required fields.</div>"; } } else { ?> <form action="core.php" method="post"> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td colspan=3><h1 class="costs"><div align="center">REGISTER ONLINE</div></h1></td> </tr> <tr> <td width=10%></td> <td width="90%" valign="top"> <table border=0 cellpadding=3 cellspacing=0 width="100%"> <tr> <td class="prices" align="left"><a href="core.htm">Critical Thinking, Reading, Writing and the Common Core</a> <br /><p>December 5, 2014</p></td> <td width="30%" align="right" class="prices"><p style="font-weight:bold; color:#cc3300; font-size:14px;">$195.00</p></td> </tr> </table> </td> <td width=20%></td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td width="50%" align="center" class="reg">Registration</td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="80%"> <tr> <td width=17%></td> <td width="66%" valign="top"> <div align="center"><h1 class="title">Critical Thinking, Reading, Writing and the Common Core</h1></div> <p class="check">You <i>must check</i> the box below for your registration to be valid. Thank you.</p> <input type="checkbox" name="module_1" value="1" /> <label for="module_1">Critical Thinking, Reading, Writing and the Common Core</label> <!--<table border="0" cellpadding="3" cellspacing="1" width="100%"> <tr> <td width="25%" valign="top"> <p style="font-weight:bold; font-size:14px; color:#cc3300;">December 6, 2013 $150.00</p> </td> <td width="25%"></td> </tr> <tr> <td width="25%"><input type="checkbox" name="module_1" value="1" /> <label for="module_1">Critical Thinking, Reading, Writing and the Common Core</label></td> <td></td> </tr> <tr> <td width="25%" valign="top"> <h4>Week II ($1075.00)</h4> </td> <td width="25%"></td> </tr> <tr> <td width="25%"><input type="checkbox" name="module_2" value="1" /> <label for="module_2">Summer Institute Week II</label></td> <td></td> </tr> </table>--> <hr size=1 width=100% noshade /> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td width="33%" align="center"><input type="text" name="first_name" size="30" /></td> <td width="33%" align="center"><input type="text" name="middle_name" size="30" /></td> <td width="33%" align="center"><input type="text" name="last_name" size="30" /></td> </tr> <tr> <td width="33%" align="center"><p class="normal1">First Name</p></td> <td width="33%" align="center"><p class="normal1">Middle Initial</p></td> <td width="33%" align="center"><p class="normal1">Last Name</p></td> </tr> </table> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr> <td><p class="normal">Address 1</p></td> <td colspan="3" align="left"><input type="text" name="address_1" size="94" /></td> </tr> <tr> <td><p class="normal">Address 2</p></td> <td colspan="3" align="left"><input type="text" name="address_2" size="94" /></td> </tr> <tr> <td><p class="normal">City</p></td> <td align="left"><input type="text" name="city" size="20" /></td> <td><p class="normal">State</p></td> <td align="left"><input type="text" name="state" size="20" /></td> </tr> <tr> <td><p class="normal">Zip</p></td> <td align="left"><input type="text" name="zip" size="20" /></td> <td><p class="normal">Province</p></td> <td><input type="text" name="province" size="20" /></td> </tr> <tr> <td><p class="normal">School/College</p></td> <td align="left"><input type="text" name="school" size="56" /></td> <td><p class="normal">Country</p></td> <td><input type="text" name="country" size="20" /></td> </tr> <tr> <td><p class="normal">Field/Subject Taught</p></td> <td align="left"><input type="text" name="taught" size="56" /></td> <td><p class="normal">Grade</p></td> <td><input type="text" name="grade" size="20" /></td> </tr> <tr> <td><p class="normal">Telephone (H)</p></td> <td align="left"><input type="text" name="home" size="20" /></td> <td><p class="normal">(W)</p></td> <td><input type="text" name="work" size="20" /></td> </tr> <tr> <td><p class="normal">Email Address</p></td> <td colspan="3"><input type="text" name="email" size="94" /></td> </tr> <tr> <td colspan=4 align=center><input type="submit" name="submit" value="Submit Form" class="sub" /></td> </tr> </table> <td width=17%></td> </td> </tr> </table> </form> <? } ?> </center> </body> </html>Attached Files coreTest.php 15.99KB 2 downloads SIReg.php 15.08KB 2 downloads Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> Hi there, I have a map of America made in flash, where you click on a state and the page should display the SQL database information for that state in the HTML table - but instead all it shows is the first entry of the database regardless of which state you click and it doesn't display the 2 radio buttons. My code is as follows Flash Actionscript 3 (just showing one state) Code: [Select] function waClick(event:MouseEvent):void { var waURL:URLRequest = new URLRequest("restaurants.php?state=Washington"); navigateToURL(waURL, "_self"); } wa_btn.addEventListener(MouseEvent.CLICK, waClick); PHP code Code: [Select] <?php include("mvfconnect.php"); $theChoice = $_GET['state']; $query = "SELECT * FROM restaurants WHERE" .$theChoice; $result = @ mysql_query($query); if (!$result) { $message="Unfortunately we are having problems with this page, we promise to have it fixed as soon as possible"; die($message); } $num = mysql_num_fields($result); $i=0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $show1=substr($row['state'],0,50)."..."; $show2=substr($row['city'],0,50)."..."; $show3=substr($row['rname'],0,50)."..."; $show4=substr($row['address'],0,50)."..."; $show5=substr($row['pnum'],0,50)."..."; $show6=substr($row['web'],0,50)."..."; $show7=substr($row['dishes'],0,50)."..."; $show8=substr($row['dish_details'],0,50)."..."; $show9=substr($row['challenges'],0,50)."..."; $show10=substr($row['challenge_details'],0,50)."..."; $show11=substr($row['youtube'],0,50)."..."; $show12=substr($row['images'],0,50)."..."; echo "<tr>". "<td>".$row['city']."</td>". "<td>".$row['rname']."</td>". "<td>".$row['address']."</td>". "<td>".$row['pnum']."</td>". "<td>".$row['web']."</td>". "<td>".$row['dishes']."</td>". "<td>".$row['challenges']."</td>". "<td id='state".$i."' style='display:none'>".$row['state']."</td>". "<td id='city".$i."' style='display:none'>".$row['city']."</td>". "<td id='rname".$i."' style='display:none'>".$row['rname']."</td>". "<td id='address".$i."' style='display:none'>".$row['address']."</td>". "<td id='pnum".$i."' style='display:none'>".$row['pnum']."</td>". "<td id='web".$i."' style='display:none'>".$row['web']."</td>". "<td id='dishes".$i."' style='display:none'>".$row['dishes']."</td>". "<td id='dish_details".$i."' style='display:none'>".$row['dish_details']."</td>". "<td id='challenges".$i."' style='display:none'>".$row['challenges']."</td>". "<td id='challenge_details".$i."' style='display:none'>".$row['challenge_details']."</td>". "<td id='youtube".$i."' style='display:none'>".$row['youtube']."</td>". "<td id='images".$i."' style='display:none'>".$row['images']."</td>". "<td><input type='radio' name='vid' id='vid".$i."' onclick='openVideo(".$i.")' /></td>". "<td><input type='radio' name='pic' id='pic".$i."' onclick='openImage(".$i.")' /></td>". "<td class='last'style='display:none'>".$show1." ".$show2." ".$show3." ".$show4." ".$show5." ".$show6." ".$show7." ".$show8." ".$show9." ".$show10."</td>". "</tr>"; $i++; } ?> I have used this code before and it has worked fine, can someone please help me out! Okay, so i'm using the basic php mysql insert into function but I have a strange (or maybe not so strange, I just don't get it..) problem.. I have two columns (do you call them columns? I don't really know for sure, whatever things that are in a table whatsoever). Name and Trailer. EDIT: they are TEXT's if that matters Name is really nothing important, just the name. But I want to embed trailers.. If I embed the Megavideo code below: Code: [Select] <object width="400" height="300"><param name="movie" value="http://www.megavideo.com/v/8UZFURZQ2b55ada04d73ae65c726a5383b9ee9d9"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.megavideo.com/v/8UZFURZQ2b55ada04d73ae65c726a5383b9ee9d9" type="application/x-shockwave-flash" allowfullscreen="true" width="400" height="300"></embed></object> Everything works fine, no problems and no bullshit. But.. if I for an example try to embed this one (NovaMov): Code: [Select] <iframe style='overflow: hidden; border: 0; width: 400px; height: 300px' src='http://embed.novamov.com/embed.php?width=400&height=300&v=xngq7u8yejwbt' scrolling='no'></iframe> It doesn't work. It just doesn't insert. Is inserting an "iframe" a problem or something? I just don't get why the hell it would do this? Does anyone know anything about this? If so i'd be eager and very thankful to hear why and how to fix it. thanks in advance im making a website it works fine on firefox but on ie doesnt work correctly. page looks weird i see the error is <? include("index/index_files/front/php/include.php"); ?> anyone can help me its in a <html> tab. Hi, i use mysql_real_escape_string() function when insert in db, but when echo i use htmlentities($var, ENT_QUOTES, "UTF-8") Now problem is '\ in that text. In db it write text with single quote with \, example That\'s wrong, and when echo it show just the same like in db.. How can i fix this ? Elo, I'm creating a very simple image list that is function generated which pulls the source from a table in my database, this is my code Code: [Select] $output = "<ul>"; $img_src = get_all_image_src($sel_event['id']); while($src = mysql_fetch_array($img_src)) { for($i=0;$i <= 9; $i++) { $output .= "<li>"; $output .= "<a"; $output .= " class ='album'"; $output .= " rel='group'"; $output .= " href='/images/gallery/'" . $src['img_src'] . $i; $output .= ".jpg"; $output .= " title='sample 1'"; $output .= ">"; //Image Thumb $output .= "<img"; $output .= " src='/images/gallery/'"; $output .= $src['img_thumb_src']. $i . ".jpg"; $output .= "alt='image01' "; $output .= "title='sample title' />"; $output .= "tae"; $output .= "</a>"; $output .= "</li>"; } } $output .= "</ul>"; return $output; and the img src doesnt seems to add up... my folder structure is Sandbox>image>gallery>2011>Mall>Event>Thumbs where Sandbox is the main directory. i tried echoing the $src['img_src'] and it displays correctly the data to be added (which is 2011/Mall/Event/ plus $i and a .jpg) .. sorry noob here... any thoughts? am i missing a simple detail? Hi. I am from poland. I am 17 old age and like webmastering. I write my social network. I have new server 10 GB VPS and my script no runing In my server. in my server do can not login. No runing function Code: [Select] mb_strtolower();as delete function mb_strtolower() ; this login runing. In my server haven`t installing liberary GD and no runing upload avatars. my code upload is: elseif ($_GET['act'] == "upload") { echo <<< KONIEC <hr> <center> <p> <h2>Dodaj zdjęcie</h2> <ul class="gallery clearfix"> <li class="extra"> KONIEC; error_reporting(E_ALL); // we first include the upload class, as we will need it here to deal with the uploaded file include('include/class.upload.php'); // retrieve eventual CLI parameters $cli = (isset($argc) && $argc > 1); if ($cli) { if (isset($argv[1])) $_GET['file'] = $argv[1]; if (isset($argv[2])) $_GET['dir'] = $argv[2]; if (isset($argv[3])) $_GET['pics'] = $argv[3]; } // set variables $dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test'); $dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest); if (!$cli) { } // we have three forms on the test page, so we redirect accordingly if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'simple') { // ---------- SIMPLE UPLOAD ---------- // we create an instance of the class, giving as argument the PHP object // corresponding to the file field from the form // All the uploads are accessible from the PHP object $_FILES $handle = new Upload($_FILES['my_field']); // then we check if the file has been uploaded properly // in its *temporary* location in the server (often, it is /tmp) if ($handle->uploaded) { // yes, the file is on the server // now, we start the upload 'process'. That is, to copy the uploaded file // from its temporary location to the wanted location // It could be something like $handle->Process('/home/www/my_uploads/'); $handle->Process($dir_dest); function TestProcess(&$handle, $title = 'test', $details='') { global $dir_pics, $dir_dest; $unlink = 'test/'. $handle->file_dst_name; $myid = $_SESSION['id']; $opis = htmlspecialchars(stripslashes(strip_tags(trim($_POST["opis"]))), ENT_QUOTES); $handle->Process($dir_dest); if ($handle->processed) { unlink("$unlink"); $link = ''.$dir_pics.'/' . $handle->file_dst_name .''; $addphoto = mysql_query("INSERT INTO photo VALUES('', '$myid', '$link', '$opis')"); echo <<< KONIEC <br> <center> <img src="$link" > <br> <br /> </center> KONIEC; } else { echo '<fieldset class="classuploadphp">'; echo ' <legend>' . $title . '</legend>'; echo ' Error: ' . $handle->error . ''; if ($details) echo ' <pre class="code php">' . htmlentities($details) . '</pre>'; echo '</fieldset>'; } } if (!file_exists($dir_dest)) mkdir($dir_dest); // ----------- $handle->image_convert = 'jpg'; $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 500; $handle->image_precrop = 15; $handle->image_watermark = "watermark_large.png"; $handle->image_watermark_x = 20; $handle->image_watermark_y = -20; TestProcess($handle, '15px pre-cropping (before resizing 800 wide), large watermark automatically reduced, position 20 -20', "\$foo->image_convert = 'jpg';\n\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 800;\n\$foo->image_precrop = 15;\n\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;"); } else { // one error occured echo '<fieldset>'; echo ' <legend>file not uploaded to the wanted location</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } // we copy the file a second time // we delete the temporary files $handle-> Clean(); } else { // if we are here, the local file failed for some reasons echo '<fieldset>'; echo ' <legend>local file error</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } echo <<< KONIEC <li> </ul> </p> </center> KONIEC; is it the only problem that isn`t installing GD as i have something off in php.ini ? Plise Help me Hi, im creating a script for a website that will list products, i have the basic construct which lists the products from the database but it lists then vertically, i have set the width of each 'product' to 200px so i could have around 3 colums and many rows. can anybody advise how i would make them run vertically aswell as horizontally? my code below: <?php include_once("include/globals.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link href="styles/stylesheet.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <?php //Get database Results $result = mysql_query("SELECT * FROM Products WHERE is_active = 1") or die(mysql_error()); //keeps getting the next row until no more records while($row = mysql_fetch_array($result)) { //echo results ($result) echo '<div id="holder">'; echo '<div class="title">' . $row['Name'] . '</div>'; //insert image here echo '<div class="image">'; echo '<img src="' . $row['image'] . '" width="100" alt="">'; echo '</div>'; echo '<div class="tag_line">'; echo $row['Tag_Line']; echo '</div>'; echo '<div class="price">Now Only: £'; echo $row['Website_Price']; echo '</div>'; echo '<div class="prod-footer"></div>'; echo '</div>'; } ?> </div> </body> </html> table structu Field Type Null Default Comments MIME ID int(11) No product_code varchar(255) No Name varchar(255) Yes NULL Tag_Line varchar(255) Yes NULL Description varchar(255) Yes NULL Specification varchar(255) Yes NULL Technical_Info varchar(255) Yes NULL Cost_Price_USD decimal(10,2) Yes NULL Cost_Price_GBP decimal(10,2) Yes NULL Built_in_delivery decimal(10,2) Yes NULL Trade_Price decimal(10,2) Yes NULL Trade_Plus_Price decimal(10,2) Yes NULL Website_Price decimal(10,2) Yes NULL Is_active int(1) No image varchar(255) Yes NULL i'm getting this erro "Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /***/***/*****.php on line 278 not an active session, starts new" this is the code: if ($phase = mysql_result(mysql_query("SELECT `phase` FROM `as_support` WHERE `mission` = '$var2'"),0,0)) { if ($phase=='5') { // mysql_query("DELETE FROM `as_support` WHERE `mission` = '$var2'"); // header("Location: https://www.**********/*******/*******.php"); } else { echo date('h:i:s') . ": PHASE is $phase<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; } } else { echo "not an active session, starts new<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; mysql_query("INSERT INTO `as_support` (`mission`, `phase`) VALUES ('$var2', '0')") OR DIE(mysql_error()); the first line is line no. 278 can someone please tell me what to do? tnx shirley I do not receive email for my published php file which is: <?php ///// easend.php ///// $youremail = "acdelco40108@yahoo.com"; /*put the email address here, between quotes, the email address you want the message sent to*/ $to = $youremail; $email = $_POST['EMail']; $name2 = $_POST['Name']; $street2 = $_POST['Street']; $city2 = $_POST['City']; $state2 = $_POST['State']; $zip2 = $_POST['Zip']; $Phone = $_POST['Home_Phone']; $Cell = $_POST['Cell_Phone']; $education = $_POST['email1']; $comments = $_POST['email2'] ; $headers = "From:" . $email; $fields = array(); $fields{"Name"} = "Name"; $fields{"Street"} = "Street"; $fields{"City"} = "City"; $fields{"State"} = "State"; $fields{"Zip"} = "Zip"; $fields{"Home_Phone"} = "Home Phone"; $fields{"Cell_Phone"} = "Cell Phone"; $fields{"EMail"} = "Email"; $fields{"email1"} = "Education"; $fields{"email2"} = "Comments"; $subject = "We have received the following information from your employment application"; $body = "We have received the following information from your employment application:\n\n"; foreach($fields as $a => $b) { $body .= sprintf("%20s: %s\n",$b,$_POST[$a]); } mail ($to, $subject, $body, $headers); //send mail to owner #end create email vars $headers = "From:" . $to; mail ($email, $subject, $body, $headers); //send mail to user #end create email vars echo "<head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=ThankYou.html\"></head>"; ?> I have a simple text file called bio.txt: Code: [Select] wohlersr; Richie Wohlers; Intermediate; Four Aces meyersg; Greg Meyers; Novice; Four Aces I wrote a little script, to return the info for Greg Meyers if the user id is correct, or say "Member not found" if incorrect. For some reason, my output is giving me both. I assume it's a context error, but can't figure it out. Here's my script: Code: [Select] <?php $file=file("bio.txt"); $count=count($file); $i=0; while($i<=$count) { $row = explode(";", $file[$i]); $id = $row[0]; $name = $row[1]; $class = $row[2]; $club = $row[3]; if($id=="meyersg"){ echo $name."</br>"; echo $class."</br>"; echo $club."</br>"; }else{ echo "Member not found."; } $i++; } ?> And here's the output I'm getting: Code: [Select] Member not found. Greg Meyers Novice Four Aces Member not found. |