PHP - Mysqli_fetch_array - Issue?
Hi Guys
Using mysqli_fetch_array(), which i had anticipated would simply return a numeric array with all the results from the simple query. However, it keeps coming out as a multidimensional array, which isn;t what i want. Is this just how it works or have i done something wrong? Code Code: [Select] $mysqli = new mysqli("localhost", "root", "", "ik"); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } $qry = "SELECT amount FROM teams"; $result = $mysqli->query($qry); while($row = mysqli_fetch_array($result, MYSQLI_NUM)) { $rows[] = $row; //echo $row . "<br/>"; } print_r($rows); Result Code: [Select] Array ( [0] => Array ( [0] => 3 ) [1] => Array ( [0] => 25 ) [2] => Array ( [0] => 26 ) [3] => Array ( [0] => 31 ) [4] => Array ( [0] => 34 ) [5] => Array ( [0] => 44 ) [6] => Array ( [0] => 50 ) [7] => Array ( [0] => 56 ) [8] => Array ( [0] => 65 ) [9] => Array ( [0] => 221 ) [10] => Array ( [0] => 222 ) [11] => Array ( [0] => 225 ) [12] => Array ( [0] => 2210 ) [13] => Array ( [0] => 2600 ) ) Similar TutorialsI HOPE THIS IS IN THE CORRECT FORUM! I am developing a program that filters a MySQL database to choose a type of verse. I am using an HTML form with check boxes to select the type. The variable that is passed using $POST is a text string. I am using this string to query the database in the table Events to get all of the verses with that Event_Type. Using mysqli_fetch_array, I am then extacting the ID to use in another MySQL query, this time querying the Verses table to list the verses of this type. What is actually happening is that all the types up to 9 are displaying the correct result, but the ones with ID 10 to 19 are displaying verses with ID = 1 and the last 3 are displaying versed with ID = 2. So it is obvious that it is only looking at the first digit of the ID. How do you get it to recognise complete ID number? PHP Version 5.3.6 Here is the PHP code: Code: [Select] <?php include("Loc_cverse_connect.php"); doDB(); //check for required info from the query string //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE Event_Type = '".$_POST["Event_Type"]."'"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); echo $_POST["Event_Type"]; if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); } //gather the Events $get_Event_sql = "SELECT ID, Verse FROM Verses WHERE Event = '".$Event_ID["ID"]."' ORDER BY ID ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = " <p> The Event Type is <b>" .$_POST["Event_Type"]."</b> </p> <table width=\"50%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Event_id = $Verse_info['ID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Event_id."<br/></td> <td width=\"35%\" valign=\"top\">".$Verse_text."<br/><br/> </tr>"; } //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; } ?> <html> <head> <title> List of Verses</title> </head> <body BGCOLOR="#87CEEB"> <h1>Verses</h1> <?php echo $display_block; ?> </body> </html> mysqlnd 5.0.8-dev - 20102224 - $Revision: 308673 $ MySQL Table Structu Event:- ID Event_Type Verses:- ID Event Sub_Type Verse Hello, So I have only been using php for a few months now and am a noob. This question is probably an easy fix. My problem is that I have an array of info which is user stories they post on my site. I have a delete button for each story for the user to delete the associated story if they wish. The problem is that the delete button code deletes the last $row or story that was fetched! It seems that the variable updates through every loop and the code just deletes that id. Here is my code. Code: [Select] //page with delete button echo "<center><b>Stories Shared</b></center>"; $result = mysqli_query($cxn, "SELECT * FROM Stories WHERE User = '$name' ORDER BY ID DESC"); while($row = mysqli_fetch_array($result)) { if (empty($row)) { echo "<center>N/A</center>"; } $artpixname = $row['Artpixname']; echo "<hr />"; echo "<div id = 'info'>";; echo "ID: " . $row['ID']; echo "<b>Category: </b>" .$row['Type']. " "; $id = $row['ID']; echo "<FORM ACTION='delete.php' METHOD='POST'> <input type='hidden' name='ID' value='$id'> <INPUT TYPE = 'Submit' name='Delete' id='Delete' VALUE = 'Delete'>"; echo "<center><b><h3>" . $row['Name'] . "</h3></b></center> "; echo "</div>"; if (!empty($artpixname)) { echo "<center><img class = 'artimg' src = 'articles/images/".$row['Artpixname']."'></center>"; } echo "<br />"; echo "<br />"; echo $row['Article']; echo "<br />"; echo "<br />"; //now the delete button opens up the delete program here... <?php session_start(); include 'header.php'; include 'connection.php'; $id = $_POST['ID']; $name = $_SESSION['logname']; $result = mysqli_query($cxn, "SELECT ID FROM Stories WHERE ID = '$id'"); while($row = mysqli_fetch_array($result)) { $sql = mysqli_query($cxn, "DELETE FROM Stories WHERE ID = '$id'"); } echo "Your story was deleted successfully!"; echo "<br />"; echo "Click <a href = 'userpage.php?'.$name'><b>Here</b></a> to return to your profile page."; ?> What am I doing wrong? I tried everything including different variables and even putting the delete query in the while loop. Any help would be appreciated thanks! Lance MOD EDIT: [code] . . . [/code] tags added. I think I put this in the wrong forum, as it seems to be more of a php problem (I think) I'm trying to populate a profile page with information from the database. Really bizarrely, every $row variable that isn't null returns as 'website', which is the database username. I have absolutely no idea why this is. It might be worth noting I have just changed hosts...the only thing I can think might make a difference. Any help would be great, thankyou $query = "SELECT * FROM member WHERE username='$member'"; $result = mysqli_query ($dbc, $query) or trigger_error ("query: $query\n<br />MySQL Error: " . mysqli_error($dbc)); if ($result) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $member_id = $row['member_id']; $username = $row['username_id']; $photo = $row['photo']; $about = $row['about']; $slink = $row['soundcloud_link']; $mlink = $row['mixcloud_link']; $flink = $row['facebook_link']; $dlink = $row['divshare_link']; $mylink = $row['myspace_link']; $plink = $row['postbocks_links']; $website = $row['personal_website']; $type = $row['member_type']; $status = $row['status']; } } } I've echo'd the $query and put the result into sql directly and it comes out fine. Hi guys, I received an error, could anyone explain this current error? Thanks Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in D:\inetpub\vhosts\championtutor.com\httpdocs\questionnaire.php on line 32 Hello im geting this error what im ding wrong? Code: [Select] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/admincom/public_html/tsue/library/plugins/movie_plugin.php on line 7 line 7 is: while ($row = mysqli_fetch_array($sql)) { code he Code: [Select] $query = mysqli_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DB); $sql = mysqli_query($query, "SELECT `membername`, `filename`, `tid`, `info_hash`, `name`, `description`, `cid`, `size`, `added`, `leechers`, `seeders`, `times_completed`, `owner`, `options`, `nfo`, `sticky`, `flags`, `mtime`, `ctime`, `download_multiplier`, `upload_multiplier` FROM `tsue_members`, `tsue_torrents`, `tsue_attachments` WHERE `memberid`='owner' AND `content_type`='torrent_images' AND `content_id` = `tid` LIMIT 0, 10"); while ($row = mysqli_fetch_array($sql)) { $movie_plugin_row = ''; $uploader = $row['membername']; $description= $row['description']; $dydis= $row['size']; $name= $row['name']; $leechers= $row['leechers']; $owner= $row['owner']; $filename= $row['filename']; $nunx= $row['tid']; $seeders= $row['seeders']; eval("\$movie_plugin_row = \"".$TSUE['TSUE_Template']->LoadTemplate('movie_plugin_row')."\";"); $movie_plugin .= $movie_plugin_row; } Hi
I am a student who is fairly new to PHP and MySQL. I have been working on creating a registration page for a website and I'm getting the following warnings when I've tested the page:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/ed12e2w/public_html/COMM2735/dynamic_website/registration.php on line 74 Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /home/ed12e2w/public_html/COMM2735/dynamic_website/registration.php on line 80 I think that my query has failed but I'm not completely sure on what to change in order to solve this. Here is the section of code I'm having problems with: Attached Files register.php 733bytes 4 downloads Hey everyone I've been working on converting my old mysql code to to the mysqli version and am running into some trouble. I am pulling posts form phpbb and displaying them in a script. My first script below works just fine. Code: [Select] <?php require("connect.php"); $query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14') AND topic_status = '0'"; $query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16') AND topic_status = '0'"; $result=mysql_query($query); $result2=mysql_query($query2); echo "<table border=0 cellpadding=2>"; echo "<tr><td>Lost</td><td>Found</td></tr>"; while($row=(mysql_fetch_array($result)) || $row2=(mysql_fetch_array($result2))) { $forum_id=mysql_result($result,$k,"forum_id"); $topic_id=mysql_result($result,$k,"topic_id"); $topic_title=mysql_result($result,$k,"topic_title"); $forum_id2=mysql_result($result2,$k,"forum_id"); $topic_id2=mysql_result($result2,$k,"topic_id"); $topic_title2=mysql_result($result2,$k,"topic_title"); echo "<tr><td width='15%'><a href=/sahbb/viewtopic.php?f=$forum_id&t=$topic_id>$topic_title</a></td> <td width='15%'><a href=/sahbb/viewtopic.php?f=$forum_id2&t=$topic_id2>$topic_title2</a></td> </tr>"; $k++; } echo "</table>"; mysql_close($connect); ?> however its not very clean or memory efficient so i have converted it to the following. Code: [Select] <?php require("includes_database/mysqli_connect.php"); $query="SELECT * FROM phpbb_topics WHERE (forum_id='13' OR forum_id='14')"; $query2="SELECT * FROM phpbb_topics WHERE (forum_id='15' OR forum_id='16')"; $result=mysqli_query($dbc, $query); $result2=mysqli_query($dbc, $query2); echo "<table border=1 cellpadding=2>"; echo "<tr><td>Lost</td><td>Found</td></tr>"; while(($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) || ($row2 = mysqli_fetch_array($result2, MYSQLI_ASSOC))) { echo "<tr><td width='15%'><a href=/sahbb/viewtopic.php?f=".$row['forum_id']."&t=".$row['topic_id'].">".$row['topic_title']."</a></td> <td width='15%'><a href=/sahbb/viewtopic.php?f=".$row2['forum_id']."&t=".$row2['topic_id'].">".$row2['topic_title']."</a></td> </tr>"; } echo "</table>"; mysqli_free_result($result); mysqli_free_result($result2); mysqli_close($dbc); ?> I know the error is in my while loop but i cant seem to figure out exactly where. The new code displays all of the first query in the table and then below that it displays the next query insted of displaying them side by side below would be an example of what is happening [table Lost Found Lost, Australian Sheppard Lost German Shepherded / Collie Mix Lost Golden Retriever/Cocker Mix Lost Female Grey Tiger Lost Pitbull Mix Lost 2 Chihuahua Lost Black Lab Lost - German Shepard Mix and Lab Mix Lost - Female German Sheperd Aprox 8 Week Old Kitten Found! 2 Pugs FOUND Found 1 Corgi female/ 1 Shih Tzu male Found Tan and Black Australian Shepard Found Australian Shepard Found Intact Male Pitbull/Lab Mix Any help that any of you could provide would be greatly appreciated! Someone help me in this problem please?? Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in line 8 $rec= mysqli_query ($db, "SELECT FROM joborder WHERE id=$id"); $record = mysqli_fetch_array ($rec); // line 8 $fnames= $record ['fnames'] ; Edited March 8 by keiWarning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/myritebook/public_html/footer.php on line 13 I am trying to fix the above error. Please Help. code is given below:
<?php
if ($conn) {
try{
catch(Exception $e){ Folks, I remember once having a php or html5 issue where the first option had to be blank in the drop down. Otherwise, it wasn't working. What wasn't working ? How wasn't working ? I can't remember. either php had difficulty reading user input or the drop down was not showing any options. And so, I had to add a blank value. So, something like this wasn't working ...
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value="yes">Yes</option> <option value="no">No</option> </select>
And, I think I added a blank value, at somebody's advice, to get it to work. I think it was something like this, if I remember correctly:
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value=" ">Select here</option> <option value="yes">Yes</option> <option value="no">No</option> </select>
Or, maybe it was something like this:
<label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value=" "></option> <option value="yes">Yes</option> <option value="no">No</option> </select>
I can't remember. All I remember slightly that there was a blank value. I been going through my php files to find that particular file to jog my memory but I failed to find it. Can you folks explain to me if a blank value is required or not ? What is the benefit/disaster of adding it and how should the blank value be added ? Show me an example.
Was this a php or html 5 issue ? Can anybody fugure ?
Thank You Hi, I have this code below which groups all the SubHeading together and then queries the same table to find RiskConsequence which are grouped that match SubHeading then to query this table one more last time with all the Risk Mitigation that matches the grouped RiskConsequence. Problem I get is it does the SubHeading, the RiskConsequences it only does one of them not all of them before it moves onto the RiskMitigation. I know I have a php coding issue just cant see the wood from the tree's as the queries work. Code: [Select] <?php include ("include.php"); $query = "SELECT * FROM tblriskassessmentdatabank GROUP BY SubHeading"; $results = mysql_query($query) or die("Error: " . mysql_error()); while($row1 = mysql_fetch_array($results)){ echo'<a href="#" onClick="return(changeDisplay(';echo"'";echo($row1[SubHeading]);echo"'))";echo'">';echo($row1[SubHeading]);echo'</a><br /><br />'; echo'<div id="';echo($row1[SubHeading]); echo'" class="HideText">'; $risksub = $row1[SubHeading]; $query1 = "SELECT * FROM tblriskassessmentdatabank GROUP By RiskConsequence"; $results1 = mysql_query($query1) or die("Error: " . mysql_error()); while($row2 = mysql_fetch_array($results1)){ echo'<a href="#" onClick="return(changeDisplay(';echo"'";echo($row2[RiskConsequence]);echo"'))";echo'">';echo($row2[RiskConsequence]);echo'</a><br />'; echo'<div id="';echo($row2[RiskConsequence]); echo'" class="HideText">'; $risksub1 = $row2[RiskConsequence]; $query1 = "SELECT * FROM tblriskassessmentdatabank WHERE RiskConsequence = '$risksub1'"; $results1 = mysql_query($query1) or die("Error: " . mysql_error()); while($row3 = mysql_fetch_array($results1)){ echo'<input name="checkbox[]" type="checkbox" id="checkbox[]" value="';echo($row3[IssueNumber]);echo'" /> <label for="checkbox[]"></label>';echo($row3[RiskMitigation]);echo'<br /><br />'; } echo'</div>'; } echo'</div>'; } ?> Greetings =), seems i'm stumped again. lol What I want to do is check to see if a row exists if it does assign the variable to the $deposit variable to $row['price_each'] If it does not exist, i want it to assign the variable $deposit = 0 Here is my code, I think I am doing something wrong, becuase it keeps giving me the undefined variable for $deposit, when the statment i wrote should make it work. I think my syntax is off, or my ==0 is in the wrong place. I'm not too expierenced with php and i'm still learning. Any help would be greatly appreciated! Code: [Select] $deposit_query2 = mysql_query("SELECT * FROM invoice_entries, sku_codes WHERE invoice_entries.invoice_number = $invoice_number AND invoice_entries.sku_number = sku_codes.sku AND sku_codes.sku = 01-00") or die(mysql_error()); if ($row = mysql_fetch_array($deposit_query2)==0 ) { $deposit = $row['price_each']; } else { $deposit = 0; } I run this query in TOAD ( database management application ) and it returns to me the date that a specified table was last updated. Code: [Select] $qry = "SELECT to_char(LAST_DDL_TIME, 'MM/DD/YYYY') AS LASTUPDATED FROM all_objects WHERE owner = 'USER' AND object_name = 'TABLENAME'"; $go = oci_parse($conn, $qry); oci_execute($go); $result = oci_fetch_assoc($go) echo = $result['LASTUPDATED']; However when i run that identical query through PHP i get absolutely NOTHING. Any idea if perhaps PHP isnt capable of retreiving such data or if maybe i'm doing something wrong. Thanks! A friend told me vaguely that there is a possible insecurity with a RFI, in my dynamic image, that reads a players stats off of a seprate web page, parses it, and prints it on the image: <?php Header ('Content-type: image/jpeg'); Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT'); Header('Pragma: no-cache'); // get CMID variable from the url $cmid = htmlentities($_GET['cmid']); if ($cmid < 100000 or $cmid > 999999); $cmid = 563853; elseif ($cmid > 100000 and $cmid < 999999); $cmid = $cmid; else $cmid = 563853; // create the image using your own background $image = imagecreatefromjpeg("background.jpg"); // dimensions of the image used $img_width = 600; $img_height = 9; // set the colours $cool = imagecolorallocate($image, 81, 86, 96); $black = imagecolorallocate($image, 0, 0, 0); $white = imagecolorallocate($image, 255, 255, 255); $red = imagecolorallocate($image, 255, 0, 0); $grey = imagecolorallocate($image, 204, 204, 204); $green = imagecolorallocate($image, 206, 129, 18); $blue = imagecolorallocate($image, 0, 0, 255); $yellow = imagecolorallocate($image, 225, 225, 0); $statcolor = $yellow; // set the font and print text $font = 'Verdana.ttf'; /* // counter - CHMOD your counter file to 777 $viewss = file("views.txt"); $views = $viewss[0]; $views++; $fp = fopen("views.txt", "w"); fwrite($fp, $views); fclose($fp); $counter = "$views"; // View Output imagettftext($image, 7, 0, 16, 117, $yellow, $font, "Views:$counter"); */ // Attempt to make web content grabber. function get_url_contents($url){ $crl = curl_init(); $timeout = 5; curl_setopt ($crl, CURLOPT_URL,$url); curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); $ret = curl_exec($crl); curl_close($crl); return $ret; } // Web content grabber execution. $returned_content = get_url_contents("http://uberstrike.cmune.com/Profile?cmid=$cmid"); // Parsing the returned content for Global Rank. $clanstart = strpos($returned_content, 'Clan:'); $clanend = strpos($returned_content, '</h2>', $clanstart); $clanunref = substr($returned_content, $clanstart, $clanend); $clanrefstart = strpos($clanunref, '['); $clanrefend = strpos($clanunref, ']', $clanrefstart); $clan = substr($clanunref, $clanrefstart, $clanrefend); $clan = html_entity_decode(strip_tags($clan)); // Stripping the parsed Global Rank of HTML. $clan = html_entity_decode(strip_tags($clan)); // Filtering Clan to only show the value number, not text or formatting in between. $clan = str_replace ("C", "", $clan); $clan = str_replace ("l", "", $clan); $clan = str_replace ("a", "", $clan); $clan = str_replace ("n", "", $clan); $clan = str_replace (":", "", $clan); $clan = str_replace (" ", "", $clan); // Parsing the returned content for Name. $namestart = strpos($returned_content, '<span style="color: #FEC42C; font-size: 20px; font-weight: bold;">'); $nameend = strpos($returned_content, '</span>', $namestart); $name = substr($returned_content, $namestart, $nameend-$namestart); // Stripping the parsed Name of HTML elements. $name = html_entity_decode(strip_tags($name)); // Clan and name output. imagettftext($image, 7, 0, 50, 7, $yellow, $font, "$clan" . "$name"); // Parsing the returned content for Global Rank. $rankstart = strpos($returned_content, '<h2 style="font-size:14px; font-weight:bold; text-indent:0px; margin-left:25px;">'); $rankend = strpos($returned_content, '<br />', $rankstart); $rank = substr($returned_content, $rankstart, $rankend-$rankstart); // Stripping the parsed Global Rank of HTML. $rank = html_entity_decode(strip_tags($rank)); // Filtering Rank to only show the value number, not text or formatting in between. $rank = str_replace ("G", "", $rank); $rank = str_replace ("l", "", $rank); $rank = str_replace ("o", "", $rank); $rank = str_replace ("b", "", $rank); $rank = str_replace ("a", "", $rank); $rank = str_replace ("R", "", $rank); $rank = str_replace ("n", "", $rank); $rank = str_replace ("k", "", $rank); $rank = str_replace (":", "", $rank); $rank = str_replace (" ", "", $rank); // Rank Output. imagettftext($image, 7, 0, 230, 7, $yellow, $font, "$rank"); $killstart = strpos($returned_content, '<h3 style="color: #FEC42C;">All time record</h3>'); $killend = strpos($returned_content, '</tr>', $killstart); $kill = substr($returned_content, $killstart, $killend-$killstart); // Stripping the parsed kill of HTML. $kill = html_entity_decode(strip_tags($kill)); // Filtering kill to only show the value number, not text or formatting in between. $kill = str_replace ("K", "", $kill); $kill = str_replace ("i", "", $kill); $kill = str_replace ("l", "", $kill); $kill = str_replace ("A", "", $kill); $kill = str_replace ("t", "", $kill); $kill = str_replace ("m", "", $kill); $kill = str_replace ("e", "", $kill); $kill = str_replace ("r", "", $kill); $kill = str_replace ("o", "", $kill); $kill = str_replace ("d", "", $kill); $kill = str_replace ("c", "", $kill); $kill = str_replace ("s", "", $kill); $kill = str_replace (" ", "", $kill); $kill = trim($kill); // Cannon Stats output. imagettftext($image, 7, 0, 410, 7, $yellow, $font, $kill); // Parsing the returned content for KDR. $KDRstart = strpos($returned_content, '<span title="Kill Death Ratio">KDR</span>'); $KDRend = strpos($returned_content, '</tr>', $KDRstart); $KDR = substr($returned_content, $KDRstart, $KDRend-$KDRstart); // Stripping the parsed KDR of HTML. $KDR = html_entity_decode(strip_tags($KDR)); // Filtering KDR to only show the value number, not text or formatting in between. $KDR = str_replace ("K", "", $KDR); $KDR = str_replace ("D", "", $KDR); $KDR = str_replace ("R", "", $KDR); $KDR = str_replace (" ", "", $KDR); $KDR = trim($KDR); // KDR Output. imagettftext($image, 7, 0, 323, 7, $yellow, $font, "$KDR"); // IP Logger $logfile= 'iplog.html'; $IPlog = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://www.ip2location.com/demo.aspx?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fplog = fopen($logfile, "a"); fwrite($fplog, $logdetails); fwrite($fplog, "<br>"); fclose($fplog); // output and destroy imagepng($image); imagedestroy($image); ?> Hi guys I have IPN setup for my online shop which is working fine but when payment is confirmed, my shop should send a link confirming purchase along with list of items, so I have added that to my IPN, there is an issue, it owuldnt send the email, I have checked every table/column name and they are correct, IPN works because I receive paypal confirmation email and updates database, so something should be wrong with they way I have written the code to send this email. Please find the code below, I have deleted some un-necessary info: Code: [Select] <? include ('includes/db.php'); // PHP 4.1 // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); // assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $order_id = mysql_real_escape_string((int)$_POST['custom']); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($payment_status=='Completed') { $txn_check=mysql_query("SELECT txn_id FROM orders WHERE txn_id='$txn_id'"); if (mysql_num_rows($txn_check)!=1) { if($receiver_email=='me@mydomain.com'){ ////////// $get=mysql_query("SELECT amount FROM orders WHERE amount='$payment_amount'"); while ($get_row=mysql_fetch_array($get)) { $amount=$get_row['amount']; } if($amount==$payment_amount && $payment_currency=='GBP') { $update=mysql_query("UPDATE orders SET confirmed='1', txn_id='$txn_id' WHERE order_ref='$order_id'"); $select=mysql_query("SELECT * FROM ordered_product WHERE order_ref='$order_id'"); while($row=mysql_fetch_array($select)) { $product_number=$row['product_ref']; $quantity_ordered=$row['quantity_ordered']; $update=mysql_query("UPDATE products SET instock=instock-1 WHERE product_ref='$product_number'"); } $select=mysql_query("SELECT * FROM orders WHERE order_ref='order_id' AND confirmed='1'"); while ($row=mysql_fetch_array($select)) { $order_number=$row['order_ref']; $name=$row['user_name']; $email=$row['user_email']; $address1=$row['address_1']; $address2=$row['address_2']; $address3=$row['address_3']; $city=$row['city']; $postcode=$row['postcode']; $country=$row['country']; $amount=$row['txn_id']; $date=$row['order_date']; } $select=mysql_query("SELECT * FROM ordered_product WHERE order_ref='$order_id'"); while($get_row=mysql_fetch_array($select)) { $product_ref=$get_row['product_ref']; $quantity=$get_row['quantity_ordered']; } $select=mysql_query("SELECT * FROM products WHERE product_ref='$product_ref'"); while($get_row=mysql_fetch_array($select)) { $product_name=$get_row['product_name']; $product_price=$get_row['price']; echo "<table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'>$product_name</td> <td width='120'>$quantity</td> <td width='98'>£$product_price</td> </tr> </table>"; } ///////// $headers=array( 'From:me@mydomain.com', 'Content-Type:text/html' ); $body="<table width='492' border='0' cellspacing='0' cellpadding='0' style='font-family:Verdana, Geneva, sans-serif; font-size:12px; color:#333;'> <tr> <td width='492' height='374' valign='top'><table width='497' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='497' height='97'><img src='../images/logo.png'/></td> </tr> <tr> <td>Thank you for ordering. Your order should arrive in the next 2-3 days.</td> </tr> <tr> <td height='48'><strong>ORDER NUMBER:</strong> $order_number</td> </tr> <tr> <td height='48'><p><strong>DELIVERY ADDRESS: </strong></p> <p>$address1 <br/> $address2 <br/> $address3 <br/> $city <br/> $postcode <br/> $country</p> <p> </p></td> </tr> <tr> <td height='48'><p><strong>YOUR ORDER:</strong></p> <table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'><strong>Item</strong></td> <td width='120'><strong>Quantity</strong></td> <td width='98'><strong>Price</strong></td> </tr> </table><br/> <table width='439' border='0' cellspacing='0' cellpadding='0'> <tr> <td width='219'>$product_name</td> <td width='120'>$quantity</td> <td width='98'>£$product_price</td> </tr> </table> <p> </p></td> </tr> <tr> <td height='48'><p><strong>Sub Total:</strong> £amount<br/> </p></td> </tr> </table></td> </tr> <tr> <td height='374' valign='top'><strong>N.B Any sales items are non-returnable</strong></td> </tr> </table> "; $subject = "ORDER CONFIRMATION - "; mail($to, $subject, $body, implode("\r\n",$headers)); } //////// } } } } else if (strcmp ($res, "INVALID") == 0) { header('Location: payment-error.php'); } } fclose ($fp); } ?> Thank you all in advance I have a page showing a list of events from tournaments/leagues (http://www.americandartsdatabase.com/player-rankings/included-leagues-tournaments/) If you click on the CLICK HERE link, it should come up with a page that shows the stats for that particular event. Some events it works and some it does not. 11th Annual ABDA Nationals works fine North Side Dart League does not work Code: [Select] Below is the list of tournaments and leagues that are included in the rankings. If you wish to have your tournaments and/or leagues included in the rankings, please register and send me the stats. <?php $mynewdate = strftime("%Y-%m-%d", strtotime("-730 days")); echo "<font color=red><b>Included are leagues and tournaments from " . $mynewdate . " to today.</b></font>"; $dbh=mysql_connect ("localhost", "database", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $query = "SELECT `event`, `date` FROM `stats` WHERE `date` >= '$mynewdate' GROUP BY `event` ,`date` ORDER BY `date`"; $rank = 0; $rankh = 0; $result = mysql_query($query,$dbh) or die(mysql_error()); ?> <table align=center width=90%> <tr> <th align="left">League/Tournament</th> <th align="left">Date</th> <th align="left">View Stats</th> </tr> <?php while($row = mysql_fetch_array($result)) { $event = $row['event']; $year = $row['date']; $url = "<a href=\"http://www.americandartsdatabase.com/player-rankings/included-leagues-tournaments/stats/?event=" . $event . "&year=" . $year . "\">Click Here</a>"; echo "<tr>"; echo "<td>" . $event . "</td>"; echo "<td>" . $year . "</td>"; echo "<td>" . $url . "</td>"; echo "</tr>"; } ?> </table> Here is the STATS code Code: [Select] <?php $event = $_GET['event']; $date= $_GET['year']; $rank = 0; echo "<h1>Event: " . $event . "</h1><br>"; echo "<h1>Date: " . $date . "</h1><br>"; $dbh=mysql_connect ("localhost", "database", "password") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("database"); $query = "SELECT `firstname`, `lastname`, `games`, `points`, `event`, `date`, (`points`/`games`) FROM `stats` WHERE `event` = '$event' and `date` = '$date' ORDER BY (`points`/`games`) DESC"; $result = mysql_query($query,$dbh) or die(mysql_error()); ?> <table align=center width=100%> <tr> <th align="left">Rank</th> <th align="left">Player</th> <th align="left">Games</th> <th align="left">Points</th> <th align="left">Average</th> </tr> <?php while($row = mysql_fetch_array($result)) { $rank = $rank + 1; echo "<tr>"; echo "<td>" . $rank . "</td>"; echo "<td>" . $row['firstname'] . " " . $row['lastname'] . "</td>"; echo "<td>" . $row['games'] . "</td>"; echo "<td>" . $row['points'] . "</td>"; echo "<td>" . number_format(($row['points']/$row['games']),4) . "</td>"; echo "</tr>"; } ?> </table> I have a script that saves a full size and a cropped version that is re-sized to 200x200. The full size saves just fine the cropped and re-sized version is all messed up. Example: Here is the cropped and re-size code: Code: [Select] $new_cropped_image_resource = imagecreatetruecolor(200, 200); switch($photo["ext"]){ case "gif": $cropped_image = imagecreatefromgif($processing_image_temp_name_cropped); break; case "jpg": $cropped_image = imagecreatefromjpeg($processing_image_temp_name_cropped); break; case "png": $cropped_image = imagecreatefrompng($processing_image_temp_name_cropped); break; } list($cropped_width, $cropped_height) = getimagesize($processing_image_temp_name_cropped); imagecopyresampled($new_cropped_image_resource,$cropped_image,0,0,0,0,200,200,$cropped_width,$cropped_height); switch($photo["ext"]){ case "gif": imagegif($new_cropped_image_resource, $processing_image_temp_name_cropped); break; case "jpg": imagejpeg($new_cropped_image_resource, $processing_image_temp_name_cropped, 100); break; case "png": imagepng($new_cropped_image_resource, $processing_image_temp_name_cropped); break; } Any ideas? I'm stuck :/ Thanks for any help -Shane hi phpfreaks, I have been using learning the pdo library. But I am really stuck on this one query. The above sql statement works if in phpadmin I get three results but for the life of me I can't get them with the code below. I have tried I am trying to return all columns in an array some thing like array (0=>array(0=>business blah, etc ) I have been playing with the fetch mode to try and achieve this but I can't get any results not even an obj but I am not getting any errors. Is the code below wrong? Code: [Select] $query = "SELECT Business_Name,First_Name,Last_Name,Username,Email,Phone,Mobile,Social_Media,Web_Site,User_Language,Admin_Level FROM customer WHERE Admin_Level ='Admi'"; try { //$this->dataObj->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->dataObj->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); $sth = $this->dataObj->prepare($query); $stmt = $this->dataObj->query($query); $stmt->setFetchMode(); $result = $stmt->fetchAll(); } catch (PDOException $e) { $e->getMessage(); } return $result; } How can I make it say... if none of the values in the array = $is_assoicate then do stuff... Right now it adds an li every time a value is not in the array. I only want it to add in 1 LI Code: [Select] <?php foreach($users_associates as $is_associate) { if ($is_associate['user_id'] != $user_info['uid']) { ?> <li class="bass"> <a href="" title="Become Associates" id="becomeassoc" class="mll"> <span class="f_right">Become Associates</span><img src="../assets/img/becomeassoc.jpg" class="mrs vmiddle" alt="Become Associates" /> </a> </li> <?php } } ?> |