PHP - How Do I Find Out Where Is The Error/problem In My Code?
When clicking on the link "groups", there is no problem printing out the first level subgroups. But when clicking on any of the subgroup, the second level subgroups are not being displayed.
I have or die(mysql_error()); after some queries but I can not see what is the error. It always gives the same message: Quote No Products Found. Sorry, but there are no products in this section at the moment. The products are constantly being updated, however. Please try again later or contact us. How would I find out which part of the code fails? The code: <?php include 'scrptz/functions.php'; // Page vars $thisPage=$getVars["page"]; if($thisPage<1)$thisPage=1; $firstGroup=($thisPage*16)-16; // Get group details and stick them into an array $qMain="SELECT * FROM PGroups WHERE PG = '".$getVars["prodg"]."'"; $result=mysql_query($qMain) or die(mysql_error()); $groupDetails=mysql_fetch_array($result); // Get all sub groups in current product group $qMain="SELECT * FROM SubG WHERE ProdG = '".$getVars["prodg"]."'"; $result=mysql_query($qMain) or die(mysql_error()); // Stick sub groups in a 2D associative array $j=0; while ($row=mysql_fetch_array($result)) { foreach($row as $i=>$data)$array[$j][$i]=$data; $j++; } // Calculate vars for navigation $totalGroups=$j; $totalPages=ceil($totalGroups/16); // Set page title (for bookmark) $pageTitle=$groupDetails["GPname"]; // Set top title if($totalGroups>0){$topTitle="VIEW PRODUCTS";}else{$topTitle="ERROR";} ?> <html> <head> <title>Lock-Tech® Hi-Specification Architectural Hardware</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="scrptz/styles.css" rel="stylesheet" type="text/css"> <script language="JavaScript" type="text/javascript">var theID="<?php echo $getVars['uid']; ?>";</script> <script language="JavaScript" src="scrptz/content.js" type="text/javascript"></script> <script language="JavaScript" src="scrptz/menu.js" type="text/javascript"></script> <script language="JavaScript" src="scrptz/scripts.js" type="text/javascript"></script> </head> <body background="imgz/bg.gif" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"<?php echo $notify ?>> <?php include("top.php"); ?> <table width="952" height="509" border="0" cellpadding="0" cellspacing="0" class="maintext"> <?php if($sessions['accCode']){?><form action="http://www.lock-tech.co.uk/index.php" method="post" name="logout" target="_parent"><input name="account" type="hidden" value="<?php echo $sessions['accCode']; ?>"><input name="killSession" type="hidden" value="<?php echo $getVars['uid']; ?>"></form><?php }?> <tr> <td width="1" rowspan="5" bgcolor="#000000"></td> <td height="21" background="imgz/topbar.gif" bgcolor="#14359E"> </td> <td height="21" colspan="5" valign="middle" background="imgz/topbar.gif" bgcolor="#14359E" class="mainyellow"><?php include("scrptz/dd_menu.php"); ?></td> <td height="21" background="imgz/topbar.gif" bgcolor="#14359E"> </td> <td width="1" rowspan="5" bgcolor="#000000"></td> </tr> <tr> <td width="5" rowspan="3"> </td> <td width="306" height="30" valign="bottom" class="title2"><?php echo $groupDetails["GPname"] ?></td> <td width="11" rowspan="3"><img src="imgz/maindiv.gif" width="11" height="466"></td> <td width="306" height="30" align="center" valign="bottom" class="title2"><?php if($totalGroups>0){?><a href="g_view.php?pgroup=<?php echo $groupDetails["PG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link4" onmouseover="window.status='View List of all Products in <?php echo $groupDetails["GPname"] ?>'; return true">VIEW ALL</a> | <a href="g_browse.php?pgroup=<?php echo $groupDetails["PG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link4" onmouseover="window.status='Browse all Products in <?php echo $groupDetails["GPname"] ?>'; return true">BROWSE ALL</a><?php }?></td> <td width="11" rowspan="3"><img src="imgz/maindiv.gif" width="11" height="466"></td> <td width="306" height="30" align="center" valign="bottom"> </td> <td width="5" rowspan="3"> </td> </tr> <tr> <td height="20" valign="top" class="mainbold"></td> <td width="306" rowspan="2" valign="top" class="maintext"> <?php for($i=$firstGroup; $i<($firstGroup+8) && $i<$totalGroups; $i++){?> <a href="sub.php?PSubG=<?php echo $array[$i]["SPG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link1" onmouseover="window.status='View Products in <?php echo $array[$i]["SPGname"] ?>'; return true"><?php echo $array[$i]["SPGname"] ?></a><br> <?php // Get all subsubs in current sub group $qMain="SELECT * FROM SubSubG WHERE SPG = '".$array[$i]["SPG"]."'"; $result=mysql_query($qMain) or die(mysql_error()); // Print subsubs while ($row=mysql_fetch_array($result)) { ?> [<a href="subsub.php?PSubSubG=<?php echo $row["SSPG"]?>&uid=<?php echo $getVars['uid']; ?>" class="link3" onmouseover="window.status='View Products in <?php echo $row["SSPGName"]?>'; return true"><?php echo $row["SSPGName"]?></a>] <?php } ?> <br><br> <?php }?></td> <td width="306" rowspan="2" valign="top" class="maintext"> <?php for($i=$firstGroup+8; $i<($firstGroup+16) && $i<$totalGroups; $i++){ ?> <a href="sub.php?PSubG=<?php echo $array[$i]["SPG"] ?>&uid=<?php echo $getVars['uid']; ?>" class="link1" onmouseover="window.status='View Products in <?php echo $array[$i]["SPGname"] ?>'; return true"><?php echo $array[$i]["SPGname"] ?></a><br> <?php // Get all subsubs in current sub group $qMain="SELECT * FROM SubSubG WHERE SPG = '".$array[$i]["SPG"]."'"; $result=mysql_query($qMain) or die("<font color=\"#FF0000\">ERROR {9.4}! Please navigate to a <a href=\"main.php?uid=".$getVars['uid']."\">different page</a> and then try this page again.</font>"); // Print subsubs while ($row=mysql_fetch_array($result)) { ?> [<a href="subsub.php?PSubSubG=<?php echo $row["SSPG"]?>&uid=<?php echo $getVars['uid']; ?>" class="link3" onmouseover="window.status='View Products in <?php echo $row["SSPGName"]?>'; return true"><?php echo $row["SSPGName"]?></a>] <?php } ?> <br><br> <?php }?></td> </tr> <tr> <td height="416" valign="top" class="mainbold"> <?php if($totalGroups>0) { ?> <img src="grp_pics/<?php echo $groupDetails["PG"] ?>.jpg" alt="Group Picture" galleryimg="no"><br><img src="imgz/pixel.gif" width="306" height="5"><br> <?php echo $groupDetails["GPText"] ?><?php } else { ?> or die(mysql_error()); <p class="noresult">No Products Found.</p><p class="mainbold">Sorry, but there are no products in this section at the moment. The products are constantly being updated, however. Please try again later or <a href="mailto:sales@lock-tech.co.uk" class="link1" onmouseover="window.status='Send us an Email.'; return true">contact us</a>.</p><?php }?></td> </tr> <tr> <td width="5" height="22" background="imgz/btmbar.gif" bgcolor="#14359E"> </td> <td width="306" height="22" align="center" valign="top" background="imgz/btmbar.gif" bgcolor="#14359E"><a href="javascript:history.back()" onmouseover="prev_btn.src='imgz/prev2.gif';window.status='Previous Page'; return true" onmouseout="prev_btn.src='imgz/prev.gif'"><img name="prev_btn" src="imgz/prev.gif" width="124" height="16" border="0"></a></td> <td width="11" height="22" bgcolor="#14359E"><img src="imgz/btmdiv.gif" width="11" height="22"></td> <td width="306" height="22" align="center" background="imgz/btmbar.gif" bgcolor="#14359E" class="nav"><? include 'scrptz/nav.php' ?></td> <td width="11" height="22" bgcolor="#14359E"><img src="imgz/btmdiv.gif" width="11" height="22"></td> <td width="306" height="22" align="center" valign="top" background="imgz/btmbar.gif" bgcolor="#14359E"><a href="javascript:directLink('<?php echo $prodLink; ?>','<? echo $pageTitle ?>')" onmouseover="link_btn.src='imgz/link2.gif'; window.status='Direct Link to This Page'; return true" onmouseout="link_btn.src='imgz/link.gif'"><img name="link_btn" src="imgz/link.gif" alt="" width="182" height="16" border="0"></a></td> <td width="5" height="22" background="imgz/btmbar.gif" bgcolor="#14359E"> </td> </tr> </table> </body> </html> Similar TutorialsHey all, Basically I have this code which technically should work, but I have put an error in the logic somewhere and am really struggling to find it, I've been going over it for about an hour now :/ The error is that in the second part (// Enter them into the activities database if they're not already there), it won't enter them, and it won't show the word 'Randomevent1' either, so clearly somehow I have put in something to prevent it performing that step. Can anybody help me out? I'd be amazingly grateful, I have no clue how I've screwed it up. if(isset($_POST['submit'])){ $ownerid = $_SESSION['id']; // If completed = Y give an error $completeyn = "SELECT completed FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $completecheck=mysql_query($completeyn) or die(mysql_error()); while($row = mysql_fetch_array( $completecheck )) { if($row['completed'] == 'Y'){ echo 'Oops, you\'ve already done this twice today!';} else { // Enter them into the activities database if they're not already there $stepno2 = "SELECT playerno, timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $stepnoanswer2=mysql_query($stepno2) or die(mysql_error()); $num_rows2 = mysql_num_rows($stepnoanswer2); echo $num_rows2; if($num_rows2 == '0'){ $putintodb2 = mysql_query("INSERT INTO activities (playerno, activityno, timesdone) VALUES ('$ownerid', '1', '1')") or die("Error: ".mysql_error()); echo 'Randomevent1'; }else{ // If they are already there update their stepcount $updatestepcount2=("UPDATE activities SET timesdone=timesdone+'1' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount2=mysql_query($updatestepcount2); echo 'Randomevent2';} // If this new stepcount is equal to 2, set completed to Y $checkstep = "SELECT timesdone FROM activities WHERE playerno='$ownerid' AND activityno = '1'"; $checkstepresult=mysql_query($checkstep) or die(mysql_error()); while($row = mysql_fetch_array( $checkstepresult )) { if($row['timesdone'] == '2'){ echo $row['timesdone']; $updatestepcount22=("UPDATE activities SET completed = 'Y' WHERE playerno='$ownerid' AND activityno = '1'"); $newstepcount22=mysql_query($updatestepcount22); } }}}} I have a php script wihich updates data in mysql db named 'trial' and table named 'tab' I am using jquery and ajax to update the db. but the script is not working. edit-profile.php <code> <?php session_start(); $img=$_SESSION['img']; ?> <html> <head> <title>Tgmc</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <link href="default.css" rel="stylesheet" type="text/css" media="screen" /> <script type="text/javascript" src="jquery-1.5.min.js"> </script> <script type="text/javascript"> $(function(){ $('#submit').click(function(){ $('#load').append('<img src="ajax-loader.gif" id="loading" alt="image" />'); var about= $('#about').val(); var contact= $('#contact').val(); var present= $('#present').val(); var inter= $('#inter').val(); var high= $('#high').val(); var books= $('#books').val(); var sports= $('#sports').val(); var pastime= $('#pastime').val(); var interest= $('#interest').val(); console.log (about); $.ajax({ url:'update-profile.php', type:'POST', data: 'contact=' + contact + '&about=' + about + '&present=' + present + '&inter=' + inter + '&high=' + high + '&books=' + books + '&sports=' + sports + '&pastime=' + pastime + '&interest=' +interest, success: function(result){ $('#response').remove(); $('#load').append('<p id="response">' + result + '</p>'); $('#loading').fadeOut(500,function(){ $(this).remove(); }); } }); return false; }); }); </script> </head> <body> <!-- start header --> <div id="wrapper"> <div id="header"> <div id="logo"> <h1><a href="#">ABC</a></h1> <p><a href="#">cinemas</a></p> </div> <?php { if(isset($_SESSION['name'])){ echo "<p id=\"welcome\">"; echo "Welcome ".$_SESSION['name']; echo " "; echo "<a href=\"logout.php\">"; echo "Logout"; echo "</a>"; echo "</p>"; } }?> </div> </div> <!-- end header --> <!-- star menu --> <div id="menu"> <ul> <li class="current_page_item"> <?php { if(isset($_SESSION['name'])){ echo "<a href=\"index1.php\">Home</a></li>"; } else{ echo "<a href=\"index.html\">Home</a></li>";}} ?> <li><a href="shows.php">Shows</a></li> <li><a href="umovies.php">Upcoming Movies</a></li> <li><a href="#">Reviews</a></li> <li><a href="#">Book Tickets</a></li> <li><a href="contact.html">Contact</a></li> </ul> </div> <!-- end menu --> <!-- start page --> <div id="page"> <!-- start ads --> <!-- end ads --> <!-- start content --> <div id="content"> <div class="post"> <div class="title"> <h2>My Profile <a href="edit-profile.php">Edit Profile</h2></a> </div> <div class="entry"> <form action="update-profile.php" method="post"> <p style="color:white"><a href="upload.php">Change photo</a><br/> <img src=<?php echo $_SESSION['img'] ?> width='120px' height='140px' class='left' alt='image' /> <strong>Contact:-</strong><input type="text" name="contact" id="contact" value="<?php echo $_SESSION['contact']; ?>" /><br/> About:-<textarea name="about" id="about" rows="5" cols="38" ><?php echo $_SESSION['about']; ?> </textarea><br/> </p> </div> <p style="color:white">Education:<br/> <strong>Present:-</strong> <input type="text" id="present" name="present" size="25" value="<?php echo $_SESSION['present']; ?>" /> <br/> <strong>Inter:- </strong><input type="text" id="inter" name="inter" size="25"value="<?php echo $_SESSION['inter']; ?>" /><br/> <strong>High School:-</strong><input type="text" id="high" name="high" size="25" value="<?php echo $_SESSION['high']; ?>" /><br/> <br><br> <strong>Favourite Books:-</strong><input type="text" id="books" name="books" size="30" value="<?php echo $_SESSION['books']; ?>" /><br/> <strong>Favourite Sport:-</strong><input type="text" id="sports" name="sports" size="30" value="<?php echo $_SESSION['sports']; ?>" /><br/> <br/><br/> <strong>Pastimes:-</strong><input type="text" name="pastime" id="pastime" size="25" value="<?php echo $_SESSION['pastime']; ?>" /><br/> <strong>Interests:-</strong><input type="text" name="interest" id="interest" size="25" value="<?php echo $_SESSION['interests']; ?>" /><br/><br/> <input type="submit" id="submit" value="Update" /> <div id="load></div> </form> </div> <!-- end page --> <!-- start footer --> <div id="footer"> <p class="legal"> ©2010ABC Cinemas. All Rights Reserved. • Design by <a href="#/">Pulkit</a> </p> <p class="links"> <a href="http://validator.w3.org/check/referer" class="xhtml" title="This page validates as XHTML">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a> • <a href="http://jigsaw.w3.org/css-validator/check/referer" class="css" title="This page validates as CSS">Valid <abbr title="Cascading Style Sheets">CSS</abbr></a> </p> </div> </div> <!-- end footer --> </body> </html> </code> update-profile.php <code> <?php session_start(); $connection=mysql_connect("localhost","root",""); mysql_select_db("TRIAL",$connection); if(mysql_query("UPDATE tab SET about='$_POST[about]',contact='$_POST[contact]',present='$_POST[present]',inter='$_POST[inter]',high='$_POST[high]',books='$_POST[books]',sports='$_POST[sports]',pastime='$_POST[pastime]',interests='$_POST[interest]' WHERE name='$_SESSION[name]'")){ echo "Successfully uploaded the data.<a href='index.php'>Click here</a> to return back."; } else echo "Unable to upload"; ?> </code> hey, I get this error on line 69 which is the end of my code, but I just can't find the missing or wrong curly bracket :s <!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>Untitled Document</title> </head> <body> <p> <?php if(isset($_POST['_submit_check'])){ if($form_errors = validate_form()){ show_form($form_errors);} else{ process_form();}} else{ show_form();} function process_form(){ print "Hello, ".$_POST['user'];} if(array_key_exists('user', $_POST)){ process_form();} else{ show_form(); } function validate_form(){ $errors = array(); if(strlen($_POST['user']) < 1){ $errors[] = 'Your name must be at least 1 letter long.'; } return $errors;} if(array_key_exists('_submit_check', $_POST)){ if(validate_form()){ proces_form(); } else{ show_form();} } else{ show_form(); } function show_form($errors = ''){ if($errors){ print 'please correct these errors: <ul><li>'; print implode('</li><li>', $errors); print '</li></ul>'; } print<<<_HTML_ <form method = "POST" action="$_SERVER[PHP_SELF]"> Your name: <input type="text" name="user"> </br> <input type="submit" value="Verzenden"/> </br> <input type="hidden" name="_submit_check_" value="1"> </form> _HTML_; } ?> </p> </body> </html> this code works fine it I take out the checkboxes(repair & replace) in the html & PHP ? Code: [Select] <form name="form" action="<?php $_SERVER[PHP_SELF] ?>" method="post"> <input type="text" size="2" name="apt" id="apt" onkeyup="getResults();if(this.value.length==this.size)document.form.datereceived.focus();" />Apt<br /> <input type="text" size="25" name="name" id="name" />Name<br /> <INPUT TYPE="text" size=10 name="datereceived" onKeyUp="if(this.value.length==this.size)document.form.time.focus();">Date Received<br /> <INPUT TYPE="text" size=7 name="time">Time Received<br /> <br>Kitchen <select name="item"> <option value="kitchen blinds" selected>kitchen blinds</option> <option value="kitchen bifolds">kitchen bifolds</option> <option value="kitchen lights">kitchen light fixtures</option> <option value="kitchen bulbs">kitchen light bulbs</option> <option value="kitchen tile">kitchen tile/linoleum</option> <option value="kitchen countop">kitchen counter top</option> <option value="kitchen cabinets">kitchen cabinets</option> <option value="kitchen drawers">kitchen drawers</option> <option value="fridge">refidgerator</option> <option value="stove">stove</option> <option value="range hood">stove hood</option> <option value="kitchen sink">kitchen sink</option> <option value="under kitchensink">under kitchen sink</option> <option value="kitchen faucet">kitchen faucet</option> <option value="kitchen drain">kitchen drain</option> <option value="kitchen screens">kitchen windows & screens</option> <option value="fire extinguisher">fire extinguisher</option> <option value="kitchen wall plates">kitchen switch plates</option> <option value="kitchen outlets">kitchen electrical outlets</option> <option value="kitchen ceilings">kitchen ceiling paint</option> <option value="kitchen wallpaint">kitchen wall paint</option> </select> <br> repaired <input type=checkbox name="repair" value="Y"> replaced <input type=checkbox name="replace" value="Y"><br> </p> action<INPUT TYPE="text" size=100 name="action"><br /> <INPUT TYPE="text" size=2 name="compday" MAXLENGTH=2 onKeyUp="if(this.value.length==this.size)document.form.compmoyr.focus();"> <INPUT TYPE="text" size=7 name="compmoyr" MAXLENGTH=7 Date Completed - <font color=red>day then mm/yyyy</font <br /><br /> cost<INPUT TYPE="text" size=4 name="cost"> charge<INPUT TYPE="text" size=4 name="charge"> Order#<INPUT TYPE="text" size=4 name="ordno"> - If Insp <p> <INPUT type="submit" value="submit data" /> </p> </form><?php if (isset( $_POST['apt']) ) { $apt=$_POST['apt']; $name=$_POST['name']; $datereceived=$_POST['datereceived']; $time=$_POST['time']; $item=$_POST['item']; $repair=$_POST['repair']; $replace=$_POST['replace']; $action=$_POST['action']; $compday=$_POST['compday']; $compmoyr=$_POST['compmoyr']; $cost=$_POST['cost']; $charge=$_POST['charge']; $ordno=$_POST['ordno']; $stat = mysql_connect("localhost","root","") or die('Unable to connect to database: ' . mysql_error()); $stat = mysql_select_db("maintdb") or die('Unable to select database: ' . mysql_error()); $query = " INSERT INTO maintdata (apt,name,datereceived,time,item,repair,replace,action,compday,compmoyr,cost,charge,ordno) VALUES('$apt','$name','$datereceived','$time','$item','$repair','$replace','$action','$compday','$compmoyr','$cost','$charge','$ordno')"; echo "apt $apt data inserted</font><br /><br />"; $stat = mysql_query($query) or die('Query failed: ' . mysql_error()); mysql_close(); } ?> Hello I am new thought I would ask help here as I was not getting much help on another forum. I have this code Code: [Select] <?php header("content-type: text/xml"); $rssfeed = '<?xml version="1.0" encoding="UTF-8"?>'; $rssfeed .= '<rss version="2.0">'; $rssfeed .= '<channel>'; $rssfeed .= '<title>My Price Savings Coupons.com Feed</title>'; $rssfeed .= '<link>http://www.mypricesavings.com</link>'; $rssfeed .= '<description>This is coupons.com feed</description>'; $rssfeed .= '<language>en-us</language>'; $rssfeed .= '<copyright>Copyright (C) 2011 mypricesavings.com</copyright>'; function compareFeeds($a, $b){ //this function will compare the "val" array element of each $itemRSS if ($a["val"] == $b["val"]) { return 0; } return ($a["val"] < $b["val"]) ? -1 : 1; } $doc = new DOMDocument(); $doc->load('http://rss.coupons.com/xmlserve.asp?go=14520kk5210'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { $itemRSS = array ( 'val' => $node->getElementsByTagName('value')->item(0)->nodeValue, 'image' => $node->getElementsByTagName('image')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'exp' => $node->getElementsByTagName('activedate')->item(0)->nodeValue ); array_push($arrFeeds, $itemRSS); } usort($arrFeeds, 'compareFeeds'); foreach($arrFeeds as $itemRSS){ $descrip = '<![CDATA[ <p><a href="'.$itemRSS["link"].'"><img src="'. $itemRSS["image"].'" align="left" border="0" height="80" width="80" alt="'.$itemRSS["desc"].'"/></a></p>]]>'; $descrip .= '' .$itemRSS["desc"]; $rssfeed .= '<item>'; $rssfeed .= '<title>' . $itemRSS["desc"] . '</title>'; $rssfeed .= '<link>' . $itemRSS["link"] . '</link>'; $rssfeed .= '<pubDate>' . $itemRSS["exp"] . '</pubDate>'; $rssfeed .= '<description>'. $descrip . '</description>'; $rssfeed .= '</item>'; } $rssfeed .= '</channel>'; $rssfeed .= '</rss>'; echo $rssfeed; ?> The purpose of this code is to take http://rss.coupons.com/xmlserve.asp?go=14520kk5210 and turn it into a true RSS Feed. I currently have the php above at mypricesavings.com/coupons/couponsfeed.php I receive the error in google chrome on mac, however, in safari it does work, If I were to use RSS Graffiti on facebook it also errors Thank you for any help, Also, If there is a better more efficient way to accomplish what I am trying to do, please share with me so I may learn better Derrick I just need another pair of eyes as I am not seeing the syntax error. I'm sure I'll figure it out right after I post this as that has happened many times before. query: <?php $sql = " INSERT INTO views (user_id,show,show_id,episode,episode_id) VALUES ( '" . $_SESSION['user']['id'] . "', '" . $showTitle . "', '" . $showID . "', '" . $episodeTitle . "', '" . $episodeID . "')"; ?> output: <?php $output = " INSERT INTO views (user_id,show,show_id,episode,episode_id) VALUES ('1','Criminal Minds','9','Episode Title','1')"; ?> error: Code: [Select] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'show,show_id,episode,episode_id) VALUES ( '1', 'Criminal Minds', '9',' at line 2 Hi I am trying to learn php and am working on a cms website. I keep on getting this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[id]' at line 1 I looked at the MySql manual and cannot find what is wrong any suggestion would be greatly appreciated. Thank you. The is the line of code to link to the Edit.php page and holds the id of the post. echo "<a href=\"edit.php?id=$posts[ID]\">Edit</a>"; This is in the Edit page and it gives me the error above. <?php include('Connection.php'); $query = 'SELECT * FROM site_content WHERE ID = $_GET[id]'; $result = mysql_query($query) or die(mysql_error()); $post = mysql_fetch_array($result); ?> I get the following error: Quote Parse error: syntax error, unexpected ';' in /hermes/web06/b1946/moo.rghollenbeck/index.php on line 35 But here is the only php code on the whole page: . . .more html code above <?php // PHP version: 5.2.12 // MySQL Version: 5.0.77 $link = mysql_connect('path', 'username', 'pword'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db(guestlist); $Users_IP_address = $_SERVER["REMOTE_ADDR"] ; echo "<input type='hidden' name='ip' value="; echo $Users_IP_address; echo ">"; $first_name=mysql_query("SELECT 'fname' FROM tblMain; WHERE 'ip'=" . $Users_IP_address); // pseudocode section: // If $first_name !null{ // echo "Hello " . $first_name; // } // end pseudocode section: // something like that ?> more html code below. . . Thank you. line 11 the while loop <?php //include connect $connect = mysql_connect("localhost","root","") or die ("Could Not Connect To Server"); mysql_select_db('npcs') or die ("Could Not Select Database"); $query = mysql_query("SELECT * FROM npc WHERE LEVEL=1") or die ("Could Not query Database"); echo "<table width='220' border='1' align='center'><tr><th>NPC NAME</th><th>JOB DESCRIPTION</th></tr><tr><th>LEVEL</th></tr><tr><th>EXPERIENCE</th></tr><tr><th>CASH</th></tr><tr><th>REPUTATION</th></tr>" while ($row = mysql_fetch_array($query)) { //set varibles from query $npcname = $row['npcname']; $level = $row['level']; $jobdes = $row['jobdes']; $exper = $row['exper']; $cash = $row['cash']; $rep = $row['rep']; //end getting varibles echo "<tr align='center'><td>{$row['npcname']}</td><td>{$row['jobdes']}</td><td>{$row['level']}</td><td>{$row['exper']}</td><td>{$row['cash']}</td><td>{$row['rep']}</td></tr>"; } ?> I cannot see the error. I'm getting syntax errors on line 61 and line 67 indicated in comments on form. What am I missing? <?php $submit = $_POST['submit']; // Form Data $email = strip_tags($_POST['email']); $salonname = strip_tags($_POST['salonname']); if ($_POST[submit]) { echo "TRUE - CONTINUE_1"; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_SESSION[key]==$_POST[user_code]) { echo "TRUE - CONTINUE_2"; $_SESSION[key]=''; } if ($salonname); { echo "TRUE - CONTINUE_3"; $email = trim($_POST['email']); if(!checkEmail($email)) { echo 'Invalid email address!'; echo "FALSE - STOP_4"; } else { echo "TRUE - CONTINUE_4"; // RUN Database Query } }//End IF salonname = TRUE else //LINE 61 {// STOP CODE echo "FALSE - STOP_3"; }// End salonanme check else //LINE 67 {// STOP CODE echo "FALSE - STOP_2"; }// End user code }// End if Sumbit else {// STOP CODE echo "FALSE - STOP_1"; } ?> Say I have... Code: [Select] <? echo("do something"); include("include_file.php"); echo("do something else"); ?> include_file.php Code: [Select] <? $a_$string = "a string"; echo($a_string); ?> I have put an error in the include_file.php an extra $ in the variable name. The first script would kick up an error that there is a problem with file include_file.php as line 3 or what ever the line may be. How can I have it so I can choose what the error message is, say a cryptic code and the line number without having the file names show as this is showing up my hidden includes folder and the file name which means that someone may try to visit this page alone and this can cause security issues. Adding in extra lines to every file to see if it is being use correctly a bit like sessions is not an option although I have looked at it as I have houndreds of files to alter in this case. I have just tried this instead of the top script but I does not show the secret code on error Code: [Select] <? echo("top"); @include("dummy.php") or die("secreterrorcode123"); echo("bottom"); ?> hello I've some code and I want find and cut url from it using php. this url link between 1 - 5 link. this mean some times 1 URL in the code sometimes 2 url in the code and ... can anyone help me? Code: [Select] MB</div><br/> <br/> <br/> <b><br/> DOWNLOAD<br/> <br/> <a href="http://uploading.com/files/c2182562/LIBERO%252B24%252BLUGLIO%252B2010.pdf/" target="_blank" rel="nofollow">http://uploading.com/files/c2182562/LIBERO%2B24%2BLUGLIO%2B2010.pdf/</a><br/> <br/> <br/> <br/> <br/> <a href="http://rapidshare.com/files/408736098/LIBERO_24_LUGLIO_2010.pdf.html" target="_blank" rel="nofollow">http://rapidshare.com/files/408736098/LIBERO_24_LUGLIO_2010.pdf.html</a></b> </div> <table class='file-express' width='100%'> <tr> <td style='text-align: left; color: #B2AC94; font-size: 3'><br>titletm= LIBERO 24 LUGLIO 2010 LIBERO 24 LUGLIO 2010 :found<br><font color="blue">2</font>http://www.avaxhome.ws/magazines/everyday_practical_electronics_vol_33_no_5_2004.html<br>File exists.dllink'MB</div><br/> <br/> <br/> This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306039.0 Im working on a "Friend-request"-script, but something is wrong in my "answer"-script... See the script below: Code: [Select] if (isset($_POST['submit_ansReq_answer'])) { $answer = $_POST['ansReq_what']; $uid= $_SESSION['userid']; $fid= $_POST['fid']; $db=friend_db; $dbname=bannaky_basic; include('config.php'); ///////////// IF ACCEPTED if ($answer == "acceptReq") { $reqStat = "YES"; $reqEcho = "Answered YES"; } ///////////// ELSE IF DENIED else if ($answer == "denyReq") { $reqStat = "NO"; $reqEcho = "Answered NO"; } $query = "UPDATE $db SET req_accept='$reqStat' WHERE friend_id='$uid' AND user_id='$fid'"; mysql_query($query); echo "$reqEcho"; If the user hits the Accept-button, everything works fine and is registered in the SQL database. But when hitting the Deny-button nothing happens... I get to the page and $regEcho works, but $reqStat=NO; wont save in the SQL database... Probably a simple solution to this that im not seeing.... Please help me out before i loose my mind. Hi
I have a MySql database and wondered if there is a code to search a table field with a given string and display the number of unique occurrences.
The table is asterisk_cdr and would like to know how many calls received daily on a perticular channel.
Thanks
shmideo
Here's a neat little script that you simply use by calling yourscript.php?microsoft (where microsoft is any keyword you want) and it returns 100 related keywords. It's pretty raw in it's form. I didn't write it. Purely for learning, I'm trying to figure out how to 1) issue a line break between each item in the elements of the arry? 2) return only the keywords and not the associated array info. Currently, it returns results like: Array ( => microsoft [1] => microsoft security essentials [2] => microsoft office [3] => microsoft templates [4] => microsoft updates [5] => microsoft silverlight [6] => microsoft word [7] => microsoft money [8] => microsoft office 2010 [9] => microsoft clip art [10] => microsoft [11] => microsoft security essentials [12] => microsoft office [13] => microsoft templates [14] => microsoft updates [15] => microsoft silverlight [16] => microsoft word [17] => microsoft money [18] => microsoft office 2010 [19] => microsoft clip art [20] => microsoft security essentials [21] => microsoft security essentials review [22] => microsoft security essentials alert [23] => microsoft security essentials update [24] => microsoft security essentials 2.0 I'm wanting to know how to make it return results like... microsoft microsoft security essential microsoft office microsoft templates etc.... Code: [Select] <?php function text_between($start,$end,$string) { if ($start != '') {$temp = explode($start,$string,2);} else {$temp = array('',$string);} $temp = explode($end,$temp[1],2); return $temp[0]; } function gsscrape($keyword) { $keyword=str_replace(" ","+",$keyword); global $kw; $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&q='.$keyword); $data=explode('[',$data,3); $data=explode('],[',$data[2]); foreach($data as $temp) { $kw[]= text_between('"','"',$temp); } } #simple to use, just use yourscriptname.php?keywords if ($_SERVER['QUERY_STRING']!='') { gsscrape($_SERVER['QUERY_STRING']); foreach ($kw as $keyword) { gsscrape($keyword); } #all results are in array $kw... print_r($kw); } ?> Dear Members, I am a PHP developer and desisgning a WAP page for mobiles.I need some php code to find out the model of a mobile phone from where request is coming so that based on that information I can upload the proper CSS for my page.If you can give me some hints as well that would also help me to proceed further.Currently I am able to fetch user-agent of mobile but not able to find out the specific model of mobile. Hello happy phpkkies, I search this forum for a sample php code on how to write a links scrapper that will recursively go through each page within a site and pull all the links. Then, I will save them to a database for analysis. I couldn't find something like that. Also, I was wondering if someone has or is selling a comments library in php. This is, a code or a set of functions that are related to commenting systems. For example; the library should have a function for blocking bad words or a function that will let people vote up or down comments made. Any ideas or links will be appreciated, thank you, V. Hi, This piece of code below stops site loading, can't find the problem Please help. If i remove the whole of this the site loads but does not function correct. Code: [Select] if ( $_GET[sssess] ) { session_id( $_GET[sssess] ); } session_start( ); header( "cache-control: private" ); if ( isset( $_GET[redeempoints] ) && $_GET[redeempoints] == "Y" ) { $_SESSION[redeemer] = "Y"; } if ( $_POST[purchaseorder] ) { $_SESSION[po] = "{$_POST['purchaseorder']}"; } if ( !$_SESSION[loginemail] ) { $_SESSION[loginemail] = "noemail@site"; } if ( !$_SESSION[adminemail] ) { $_SESSION[adminemail] = "noadmin@site"; } if ( $_POST[discode] ) { $_SESSION[discode] = trim( "{$_POST['discode']}" ); } $auth_ok_check = md5( "{$_SESSION['loginemail']}.{$hash}" ); $admin_ok_check = md5( "{$_SESSION['adminemail']}.{$hash}" ); if ( isset( $_GET['oidref'] ) ) { $GLOBALS['_GET']['oidref'] = mysql_real_escape_string( $_GET['oidref'] ); $sql = "SELECT o_id FROM order_list WHERE ref='".$_GET['oidref']."' AND unh='{$_GET['oidref']}'"; if ( !( $result = @mysql_query( $sql, $connection ) ) ) { exit( "**COULD NOT GET COPYRIGHT KEYS**" ); } if ( $row = mysql_fetch_array( $result ) ) { $_SESSION['unh'] = $_GET['oidref']; header( "location: ".$sshopurl."orderdetails_os.php?o_id={$row['o_id']}" ); exit( ); } if ( $_SESSION['auth_ok'] == $auth_ok_check ) { header( "location: ".$sshopurl."secure/orders.php" ); exit( ); } header( "location: ".$sshopurl."secure/login.php?next=orders.php" ); exit( ); } if ( preg_match( "/secure/", "{$_SERVER['PHP_SELF']}" ) && !preg_match( "/doqreg.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/qreg.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/voicepaycallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/secpaysecpagecallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/vps_handle_protx_response.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/protx/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/protxformcallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/protxcallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/worldpaycallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/securetradingcallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/barclayscpicallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/paypalcallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/moneybookerscallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/nochexcallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/offlinecallback.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/doregister.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/register.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/doprereg.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/login.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/dologin.php/", "{$_SERVER['PHP_SELF']}" ) ) { if ( $auth_ok_check != $_SESSION[auth_ok] ) { header( "Location: ".$sshopurl."secure/login.php?next={$_GET['next']}&shk&p={$_SERVER['PHP_SELF']}" ); exit( ); } if ( preg_match( "/secure/", "{$_SERVER['PHP_SELF']}" ) ) { $isaccount = "1"; } } if ( preg_match( "/".$adminDir."/", "{$_SERVER['PHP_SELF']}" ) && !preg_match( "/adlogin.php/", "{$_SERVER['PHP_SELF']}" ) || !preg_match( "/forgetful.php/", "{$_SERVER['PHP_SELF']}" ) ) { if ( $admin_ok_check != $_SESSION[admin_ok] ) { header( "Location: ".$adminurl."adlogin.php" ); exit( ); } if ( preg_match( "/".$adminDir."/", "{$_SERVER['PHP_SELF']}" ) ) { $isadmin = "1"; } } $noadirs = count( $admin_dirs ); $i = 0; for ( ; $i <= $noadirs; ++$i ) { if ( !preg_match( "/admin\\/".$admin_dirs[$i]."/", "{$_SERVER['PHP_SELF']}" ) && preg_match( "/".$admin_dirs[$i]."/", "{$_SESSION['admin_type']}" ) ) { continue; } header( "Location: ".$adminurl."perms.php?noperm={$admin_dirs[$i]}" ); exit( ); } if ( !$_SESSION[shopper_type] ) { $_SESSION[shopper_type] = "1"; } if ( $_GET[setcurrency] == 1 ) { if ( $_GET[new_currency_id] ) { $GLOBALS['_POST'][new_currency_id] = $_GET[new_currency_id]; } $_SESSION['currency_id'] = $_POST[new_currency_id]; } if ( $_GET[clearptid] == Y ) { session_unregister( "ptid" ); } if ( $_GET[selectpostage] == 1 ) { if ( $_POST[selptid] == Free || $_POST[selptid] == free ) { session_unregister( "ptid" ); } else if ( isset( $_POST[selptid] ) ) { $_SESSION['ptid'] = $_POST[selptid]; } else { session_unregister( "ptid" ); } $GLOBALS['_POST'][selptid] = mysql_real_escape_string( $_POST[selptid] ); $sql1 = "UPDATE basket SET ptid='".$_POST['selptid']."' WHERE session_id='".session_id( )."'"; if ( !( $result1 = @mysql_query( $sql1, $connection ) ) ) { exit( "Couldn't execute request 1" ); } } I can not find the problem with this script I wrote. I am trying to show a web page provided that the $_GET['reg'] is registered by the user. I am trying to check that the $_GET['reg'] is registered by the user before the page with specific details is shown. For some reason even if the email address equals the email address in the DB the output still shows: <?php echo "I am sorry but this '$_GET[reg]' does not seem to be registered by you!"; ?> Can anyone see where I am going wrong - there is more than one 'reg' for each email address in the DB. Thanks <?php $email = $_POST['email']; $sql = "SELECT reg FROM sales WHERE email='$email'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); $data = array(); //This way we can hold multiple results $i = 0; //The index of the array to add the result to while($row = mysqli_fetch_assoc($result)) { if ($row['reg'] == $_GET['reg'] ) { //Why use two if statements? $data[$i] = $row['reg']; $i++; //increase the array index for the next while loop } else { echo "I am sorry but this '$_GET[reg]' does not seem to be registered by you!"; exit(); } } // THIS IS WHERE THE PAGE CONTENT IS ...................... ?> |