PHP - Voting Script Assistance Required.
Hello,
Im trying to create a simple voting script for my site, i been trying different things but cannot get it too function properly. The idea is you click the 'thumbs up' image to add 1 to the 'likes' value and thumbs down to add '1' to the dislikes. Sound simple but its giving me headaches. Would really appreciate it if someone could take a quick look at my script. The table is called 'youtube_rating' (because thats the look i was going for) and in the table is 4 columns, id (aut0_increment), liked (counts liked votes), disliked (counts dislikes) and item_num which is the id for teh product the rating is for. Code: [Select] <? if ( $row['rating'] == 'YES' ) { require ("../rating/voting/dbcon.php"); $result1 = mysql_query("select * from youtube_rating WHERE item_num='".$page_id."'"); $row = mysql_fetch_array($result1); $dislike = $row['dislike']; $like = $row['liked']; if (isset($_POST['submitted'])) { require_once ("../database/functions.php"); $userip = $_SERVER['REMOTE_ADDR']; $id = safe($_POST['id']); $vote = '1'; // check if user already voted $result = mysql_query("SELECT * FROM youtube_ip WHERE userip='$userip' AND item_num ='".$id."'"); $num = mysql_num_rows($result); // if already voted show error if (isset($_POST['submitted']) && ($num > 0)) { echo '<div class="alreadyvoted">You have already voted!</div>'; } // add like if (isset($_POST['submitted']) && ($_POST['submitted'] == 'like') && ($num == 0)) { // add 1 to value $liked_value = mysql_query("SELECT liked FROM youtube_ip WHERE item_num ='".$id."'"); $liked_total = $liked_value + $vote; $query = "update youtube_rating set liked = '".$liked_total."' where item_num ='".$id."'"; echo '<div class="ilikethis">You like this!</div>'; } // add dislike if (isset($_POST['submitted']) && ($_POST['submitted'] == 'dislike') && ($num == 0)) { // add 1 to value $dislike_value = mysql_query("SELECT dislike FROM youtube_ip WHERE item_num ='".$id."'"); $dislike_total = $dislike_value + $vote; $query = "update youtube_rating set dislike = '".$dislike_total."' where item_num ='".$id."'"; echo '<div class="idislikethis">You Dislike this!</div>'; } // log ip // if (isset($_POST['submitted']) && ($num == 0)) // { // mysql_query ("insert into youtube_ip (userip, item_num) values ('".$userip."', '".$id."')"); // } } ?> <table width="50%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="48%" align="center"> <form action="" method="post"> <input name="id" type="hidden" value="<? echo $page_id ?>" /> <input name="submitted" type="hidden" value="like" /> <button type="submit" class="like_button" name="like" id="like" > <img src="../rating/voting/pixel-vfl73.gif" alt=""> <span><?php echo $like?></span> </button> </form> </td> <td width="52%"> <form action="" method="post"> <input name="id" type="hidden" value="<? echo $page_id ?>" /> <input name="submitted" type="hidden" value="dislike" /> <button type="submit" class="dislike_button" name="dislike" id="dislike" > <img src="../rating/voting/pixel-vfl73.gif" alt=""> <span><? echo $dislike?></span> </button> </form> </td> </tr> </table> <? } ?> The problem is the vote does not add up or update the database, also it doesn't seem to be checking if the user has voted or not, it just attempts (but fails) to add a vote no matter what Thanks for any help. Similar TutorialsHello everyone. I recently coded a Minecraft Voting for Diamonds script. Basically, you enter your username, you vote on the sites, then click "Get Reward". The reward then goes through a RCON script, and rewards the user with their diamonds in-game. the full script works fine, and I am happy with it, but there is one small problem; and that is users being able to abuse the system. If they wanted to, they could just refresh the page, and click Get Rewarded again, and again. I want to make something like this: It has a countdown on the link, which is started upon click, and then the link re-activates when the timer is done. My script already has "disabled=..." tags, so you have to click all links, this way would make sure a user cannot click the link until the timer is done. I'm pretty new to PHP, and please forgive me if it is not 100% PHP, but this place seemed extremely helpful. I am also pretty new to PHP, so make it for dummies xD Thanks everyone! I have a html/php i am creating but getting the following error:
[10-May-2019 09:42:13 UTC] PHP Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\inetpub\wwwroot\SupportDesk\php\Add_New_Engineer.php:88
<?php $server = htmlentities($_SERVER['PHP_SELF']); if (isset($_POST['submit'])) { $result = create_eng(); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Add A New Engineer | DDS Dashboard</title> <meta charset="utf-8" /> <link rel="icon" type="image/png" href="../images/favicon-16x16.png"/> </head> <body> <?php include('nav.php'); include('ConnectionDB.php'); ?> <div class="jumbotron"> <div class="container"> <h1><br><img src="../images/clipboard-customer.png"/> Add New Engineer:</br></h1> </div> </div> <form class="form-horizontal" role="form" id="add_eng" action="<?php $server ?>" method = "post"> <div class="form-group"> <!--<?php //display_msg($msg);?>--> <label for="EngineerName" class="col-sm-2 control-label">Engineer Name:</label> <div class="col-sm-6"> <input type="text" class="form-control" id="EngName" name="EngineersName" placeholder="Enter Engineer's Name"></input> <small class="form-text text-muted"> Enter the new engineer's name above to enter them into the database. </small> </div> <input name="submit" type="submit" value="Create Engineer" class="btn btn-primary default"></input> <input name="reset" type="Reset" value="Reset Form" class="btn btn-primary default"></input> </div> </form> <br><br> </body> </html> <?php $sql = "Select * from [Engineers] where [Engineer] not like '%\_%' Escape '\' order by [Engineer] asc"; $stmt = $conn->prepare($sql); $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); ?> <div class="containerenglist"> <div class="col-sm-5"> <table id="alleng" class="table table-bordered"> <tr> <th>Active Engineer's Names:</th> </tr> <?php foreach ($results as $row) { echo "<tr><td>"; echo $row['Engineer']; echo "</td>"; echo "</tr>"; } ?> </table> </div> </div> </body> </html> <?php Function create_eng(){ global $msgID; global $msg, $conn; include('ConnectionDB.php'); $conn = null; $msgID = 0; //Get POST from submit $eng_name = $_POST['EngineersName']; //SQL Query $sql_count = "select count(*) as num from [Engineers] where [Engineer] = :eng_name"; //Query SQL Statement //echo $eng_name; $stmt = $conn->prepare($sql_count); $stmt->bindValue(':eng_name', $eng_name); //Execute SQL Statement $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); If($results['num'] > 0){ echo $msg = "Engineer $eng_name exist's in the database"; $msgID = 1; }else{ $sql_insert = "insert into [Engineers](Engineer) values '$eng_name'"; //Prepare SQL Statement $stmt = $conn->Prepare($sql_insert); //Execute SQL Statement $stmt->execute(); $results=$stmt->fetchAll(PDO::FETCH_ASSOC); echo $msg = "Engineer $eng_name added to the database"; $msgID = 2; } } ?> Everything works correctly until i try submitting a name to the DB the line that is being pulled is $stmt = $conn->prepare($sql_count);
i want a script which should be easily integrated with the website and should fully customizable like cutephp.. the problem with cutephp is that it can't handle large data since it stores all the news articles in one .txt file on the server.. as the number of articles grow.. the size of .txt file increases and it becomes impossible for the server to handle the script.. i want a script which should be easily integrated into the website and should have the following features. - article categories - admin panel to add news - should use mySQL to store articles or it should create .htm files for articles.. i hope you get the point.. by the way if i want to write my own script.. what is the easiest way to write a script which should have categories, show news on webpages, have admin password protected add news area.. should create seperate files on the server or use mysql..nothing complicated.. simple news posting script.. Hey Friends,
I am new to this forum, and does not know anything about programming. And I require very small help from the experts of forum. I have downloaded free image hosting script from web & it is not working fine, it gets stuck at basic.php (one of the file in script). I am sharing the script here also sharing the website. My website : bsm1313.5gbfree.com
Note : I have uploaded a rar file. Kindly change extension to .rar from .php. as it was not allowing me to upload the rar file.
Any kind of help is highly highly appreciated. Thanks a ton in advance.
Attached Files
easyimagehoster_1.32.php 35.46KB
5 downloads Is there a way or function that stops the execution of a required script but continues to execute the parent script, for example: if this is a.php <?php echo "<br>Good morning"; // function to stop execution of only this script to appear here echo "<br>Good Afternoon"; ?> and then this is b.php <?php require("a.php'); echo "<br>Good Evening"; ?> So if the file b.php is called it is supposed to display: Good morning Good evening So it has to skip "Good afternoon" because of the anonymous function which I need After spending 3 days on internet and struggling with so many different forums , i have found this forum where i believe i will get the solution for my problem. Friends, I am zero in PHP, but still i have managed to do something to fulfill my requirement. I am stuck with one thing now..So i need help on.... I am using one html+php form to submit database into mysql. I created a display of that table through php script on a webpage. Now i want a datepicker option on that displayed page by which i should able to select the date range and display the data of that date range from my mysql table. And then take a export of data displayed of selected date range in excel. This displayed page is login protected, so i want after login the next thing comes in should show a sate selection option which should be fromdate to to date , and then records should displayed from the database and i can take export of those displayed results in excel file. The code i am using on this page is below which do not have any thing included for excel export and datepicker script, I am pasting the code here and request you to please include the required code in it as required. Thanks In advance <?php //database connections $db_host = 'localhost'; $db_user = '***********'; $db_pwd = '*************'; $database = 'qserves1_uksurvey'; $table = 'forms'; $file = 'export'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("SELECT * FROM {$table} ORDER BY date desc"); if (!$result) { die("Query to show fields from table failed"); } $num_rows = mysql_num_rows($result); $fields_num = mysql_num_fields($result); echo "$num_rows"; echo "<h1></h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> Hello, I was wondering is it possible to create vote with php when people vote the voted thing will go away like for exsample if there is ingame map vote and players vote !map de_dust2 the de_dust2 will be removed from map list and the last map that stays will be used? Sorry for bad english. <form action='index.php' method='POST' enctype='multipart/form-dat'> <select name='votes'> <option>SEATOWN</option> <option>vote1</option> <option>vote2</option> <option>vote3</option> </select> <input type='submit' name='vote' value='Vote'> </form> <?php $vote=$_GET['votes']; if(isset($_POST['vote'])) { echo "voted"; echo $vote; } ?> why would this not echo out anything for $vote??? cheers matt Basically I am writing my own voting system but I have a few problems and I would like to address them all in one post rather than three. First: The first thing I need help with is using CURL to check if a user actually voted at the remote top list website. Two: I need maybe a source script of a 10 digit hash generator that will display the hash generated and will insert it into the database This is currently what my hash generator looks like but I need someone to help me change it so that it will echo the actual hash generated and inserts it into the database, <?php function gen_md5_password($len = 6) { return substr(md5(rand().rand()), 0, $len); } ?> Three: I need some sort of way to tell the database that if they hash is not used within 24 hours, it will just dump or delete. I'm trying to make a voting system, Where each person would vote and they'll receive a point for it. I just don't know how to accomplish this.. =/ Hi, I am trying to come up with the best way to create a range voting form. Each candidate will have a "confidence" value associated with the choice.(using a pulldown menu?) So for March Madness it would be: Team ....... Confidence Value..... each team could only be voted to finish the tournament in a particular place, and a value would be associated with that choice. The total choices possible determines the range of confidence value possible. So....if there are 16 teams to vote on....the confidence value would range from 1-16. The voter would assign his highest available value to the team he was most confident in landing in that particular position. Example: 16 teams - 16 conf vals - if certain Duke will end up at #1 - then vote : #1 = Duke, conf val 16 next, if almost as certain that NC will end up last - then vote: #16 = NC, conf val 15 next most certain "", conf val 14 and so on.... the tricky part is making sure that the form code validates each conf val so that it is used, but used on ly once.... ideally the form could return values that could then be imported into excel and comopared. has this been done somewhere? Can you help ? hope so.... thanks!! This is a node voting module I created and it has a slight problem that I cannot figure out. It's supposed to be a simple 'Vote Up' or 'Vote Down' feature. You click 'Vote Up' and one appears in your vote tally. You click 'Vote Down' and your original vote tally is subtracted by one back down to zero. When it goes back to zero, it gets stuck there. It stays on zero no matter if I choose 'Vote Up' or 'Vote Down' again. There's something that's happening when I move my vote tally back down to zero. Maybe something isn't setup correctly with the $current_votes variable. I don't know. I've been at this for hours. Here's the code: <?php function bonnier_vote_perm() { return array('vote on content'); } function bonnier_vote_menu() { $items = array(); $items['vote'] = array( 'title' => 'vote', 'page callback' => 'bonnier_vote_vote', 'access arguments' => array('vote on content'), 'type' => MENU_CALLBACK, ); return $items; } function bonnier_vote_vote() { $nid = $_REQUEST['nid']; $value = $_REQUEST['votes']; $current_votes = db_result(db_query("SELECT votes FROM bonnier_vote WHERE nid = $nid")); if ($current_votes) { $new_votes = $current_votes + $value; db_query("UPDATE bonnier_vote SET votes = $new_votes WHERE nid = $nid"); } else { db_query("INSERT INTO bonnier_vote (nid, votes) VALUES ($nid, $value)"); } drupal_set_message('Your vote has been recorded'); drupal_goto('node/'.$nid); } function bonnier_vote_nodeapi(&$node, $op, $teaser = null, $page = null) { if ($op == 'view' && !$teaser) { $votes = db_result(db_query("SELECT votes FROM bonnier_vote WHERE nid = {$node->nid}")); if (!$votes) { $votes = 0; } $widget = '<div>'; $widget .= l('Vote Up', 'vote', array('query' => array('nid' => $node->nid, 'votes' => 1))); $widget .= ' '; $widget .= l('Vote Down', 'vote', array('query' => array('nid' => $node->nid, 'value' => -1))); $widget .= ' '; $widget .= 'Sco '. $votes; $widget .= '</div>'; $node->content['vote_widget'] = array( '#value' => $widget, '#weight' => -10, ); } } Any bit of advice would be much appreciated. I made a website for school where everyone can upload their summaries, download them and rate them (thumbs up, thumbs down). You upload a summary with some data: a specific class, subject, name etc. The path to the file, the name, subject etc. comes in a mysql table and the summaries show in a list on the site. Now here comes the problem, when you vote a summary up you go to the page up.php like this: Code: [Select] <!--Directing to up.php--> --some mysql-- while ( $summary = mysql_fetch_assoc($result) ) { echo "<a href=\"up.php?id=".$summary['id']."&page=".$summary['class'].$summary['period']."\">"; } On the page up.php I have the following code which adds +1 in the thumbsup row in myqsl: Code: [Select] <!-- thumbsup +1 --> --some mysql-- $sql2 = "UPDATE locatie SET thumbsup = thumbsup + '1' WHERE id='".strval($_GET['id'])."'"; $uitvoeren2 = mysql_query($sql2); and sends you back to the previous page Code: [Select] header("Location: ".$_GET['page'].".php"); Google crawls all my pages, and also the page Code: [Select] up.php?id=1&page=class1periode3, which changes my mysql. Leading to that all of the summaries are being voted on by google, which is every annoying. This probably isn't the best voting script but I'm fairly new to php and thought this up on my own, so I was wondering if I could get it working properly Thanks in advance hi guys i am building a voting system for my gaming website people sign up for matches, and those will be played at 3-5 different maps people can vote for wich maps they want to play each player can choose 3 maps, also 3 x the same map now the results of that voting system are shown on the page like this There is 1 vote for Map 1 There are 5 votes for Map 2 There is 1 vote for Map 3 There are 2 votes for Map 7 There is 1 vote for Map 4 There is 1 vote for Map 5 There are 8 votes for Map 8 now i want to make a script that picks the maps that will be played, so only show the 3-5 best results in the example above it woud be 2 x map 8 and 1x map 2 but im not sure how to start on this the db table of the votes is built like this id matchid playerid mapid mapname 1 113 195 1 NukeTown 2 113 195 2 Grid 3 113 195 1 NukeTown 4 114 195 1 NukeTown 5 114 195 1 NukeTown any advice or thoughts on this? thanks Hi there, im hoping someone can help me with this. What i’m trying to do is prevent users from voting twice with cookies, ive tried to set several myself but none of them have worked. Any help would be amazing. Thanks. EDIT: unsure why its formatted this way. how to fix?
<?php include 'functions.php'; // Connect to MySQL $pdo = pdo_connect_mysql(); // If the GET request "id" exists (poll id)... if (isset($_GET['id'])) { // MySQL query that selects the poll records by the GET request "id" $stmt = $pdo->prepare('SELECT * FROM polls WHERE id = ?'); $stmt->execute([$_GET['id']]); // Fetch the record $poll = $stmt->fetch(PDO::FETCH_ASSOC); // Check if the poll record exists with the id specified if ($poll) { // MySQL query that selects all the poll answers $stmt = $pdo->prepare('SELECT * FROM poll_answers WHERE poll_id = ?'); $stmt->execute([$_GET['id']]); // Fetch all the poll anwsers $poll_answers = $stmt->fetchAll(PDO::FETCH_ASSOC); // If the user clicked the "Vote" button... if (isset($_POST['poll_answer'])) { // Update and increase the vote for the answer the user voted for $stmt = $pdo->prepare('UPDATE poll_answers SET votes = votes +1 WHERE id = ?'); $stmt->execute([$_POST['poll_answer']]); // Redirect user to the result page header ('Location: result.php?id=' . $_GET['id']); exit; } } else { die ('Poll with that ID does not exist.'); } } else { die ('No poll ID specified.'); } ?> <?=template_header('Poll Vote')?> <div class="content poll-vote"> <h2><?=$poll['title']?></h2> <p><?=$poll['des']?></p> <form action="vote.php?id=<?=$_GET['id']?>" onSubmit="disable()" method="post"> <?php for ($i = 0; $i < count($poll_answers); $i++): ?> <label> <input type="radio" name="poll_answer" value="<?=$poll_answers[$i]['id']?>"<?=$i == 0 ? ' checked' : ''?>> <?=$poll_answers[$i]['title']?> </label> <?php endfor; ?> <div> <input type="submit" name="submit" value="Vote"> <a href="result.php?id=<?=$poll['id']?>">View Result</a> </div> </form> </div> <?=template_footer()?> Edited July 1, 2020 by requinix cleaning up post So I have made an anonymous poll system but I would like to limit the possibility to vote only once from a single pc. I think that I could store and check 3 things regarding a user that has voted: 1) $_SERVER['HTTP_CLIENT_IP']."!".$_SERVER['HTTP_X_FORWARDED_FOR']."!".$_SERVER['REMOTE_ADDR']; 2) HTTP cookie 3) Flash cookie LSO (because this contrary to the HTTP cookei can be detected in multiple browsers( (only if Flash is installed))) But there can be a simple situation - a simple user votes one time from Firefox and after a time his IP changes (for example he uses some Mobile internet where dynamic addressing is used) . Then for some reason he wants to use Internet Explorer where Flash is not installed. In result - it is possible to vote twice. Can anyone please suggest something regarding this? I know there is not 100% bulletproof solution - I just want to minimise the possibility to vote more than once. Also I am thinking about using EverCookie(undeletable cookie) but that could cause a lot of other problems. Hi Guys, I am designing this website that takes votes on images. I need to store the votes for each image against the image name and a username. For this purpose, I need to modify the current code which retrieves votes from the voting system but doesn't have a system to enter the image name dynamically. Below is the code for the same: Code: [Select] <?php ob_start(); $host="localhost"; $username="computat_abhi"; $password="[..]"; $databasename="computat_button"; $tbl_name="record"; $db=mysql_connect ("localhost", "computat_abhi", "[..]")or die(mysql_error()); mysql_select_db($databasename, $db) or die(mysql_error()); if( isset($_POST['Like']) ) { $sql = 'INSERT INTO record(ImageNumber,LikeCounter) VALUES (\'b1\', 1)'; mysql_query($sql, $db) or die(mysql_error()); echo 'Like vote is registered'; } elseif(isset($_POST['Dislike'])) { $sql = 'INSERT INTO record(ImageNumber,DislikeCounter) VALUES (\'b1\', 1)'; mysql_query($sql, $db) or die(mysql_error()); echo 'Dislike vote is registered'; } ob_end_flush(); ?> <html> <head> <title> Do you Like/Dislike this image? </title> </head> <body> <h1> Do you Like/Dislike this image? </h1> <form name="form1" method ="post"> <input type="submit" name="Like" value="Like"> <input type="submit" name="Dislike" value="dislike"> </form> </body> </html> Another issue is to register a new user on the website www.computationalphotography.in and link it with the voting system above. Looking forward to your help and suggestions. ok... I'm still struggling with PHP syntax, my editor's linting keeps flagging a line as incorrect. it's supposed to read as " when d1 minus 1 is less than or equal to d2 with d2 being less than or equal to d1 plus 1" so in other words its supposed to be true if d2 is between d1 minus 1 and d1 plus 1, inclusive. I don't want d2 being the previous number, the same number or the next number relative to d1. The same goes for d3, d4, and d5 (4 and 5 are un coded because why code in errors).
That being said... This isn't exactly my correct goal but I'm not sure how to code what I really want... I can't seem to find a good way to test this without the commands I know from other languages like CountIf, Iffn and RandSamp. (those are Ti-Basic commands) I know "please do it for me" is frowned upon, and hate saying it (I'd rather learn to do it myself), but if anyone can explain how to do this I'd really appreciate it. Edited March 23, 2019 by Karaethon Hello all, I wrote a script that will upload an avatar to a users profile and to do this the user has to get a randomly generated pin that is stored to thier profile info in a MySQL db what i am trying to accomplish with this code is once the form is submitted this code checks the database to see if the ID is there and that the pin matches if so then it continues to upload the file if not it stops displays an error and the upload form. For some reason the script continues to upload even when i input fake values that are not in the DB .... i know its something simple that im jsut over looking so perhaps a fresh set of eyes will help... <?php include './config.php'; include './access.php'; // Receiving variables @$steamid = addslashes($_POST['steamid']); @$pin = addslashes($_POST['pin']); @$avatar_Name1 = $_FILES['avatar']['name']; @$avatar_Size = $_FILES['avatar']['size']; @$avatar_Temp = $_FILES['avatar']['tmp_name']; @$avatar_Mime_Type = $_FILES['avatar']['type']; @$ava_strQuery1 = "SELECT * FROM $member_table WHERE authid='$steamid' AND private_pin='$pin'"; @$ava_host1 = "$hostname"; @$ava_user1 = "$username"; @$ava_pw1 = "$password"; @$ava_db1 = "$database"; $ava_link1 = mysql_connect($ava_host1, $ava_user1, $ava_pw1); if (!$ava_link1) { die('Could not connect: ' . mysql_error()); } $ava_db_selected1 = mysql_select_db($ava_db1, $ava_link1); if (!$ava_db_selected1) { die ('Can not use $ava_db1 : ' . mysql_error()); } //upload file and insert new record if ID and PIN match $ava_result1 = mysql_query($ava_strQuery1); if (!$ava_result1) { function findexts ($avatar_Name1) { $filename = strtolower($avatar_Name1) ; $exts = split("[/\\.]", $avatar_Name1) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['avatar']['name']) ; $ran = rand () ; $ran2 = $ran."."; $avatar_Name = $ran2.$ext; //Checking/Making Folder function RecursiveMkdir($path) { if (!file_exists($path)) { RecursiveMkdir(dirname($path)); mkdir($path, 0777); } } // Validation if (strlen($steamid) <15) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($steamid) >20) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($steamid) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid steamid <br>(ex: STEAM_0:0:00000)</font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($pin) !=12) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid pin<br>Dont have a pin? click <a href='#'>here</a></font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if (strlen($pin) == 0 ) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please enter a valid pin<br>Dont have a pin? click <a href='#'>here</a></font></p><p align='center'><a href='avatar.php'>BACK</a></p>"); } if( $avatar_Size == 0) { die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } if( $avatar_Size >51200) { //delete file unlink($avatar_Temp); die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } if( $avatar_Mime_Type != "image/gif" AND $avatar_Mime_Type != "image/jpeg" AND $avatar_Mime_Type != "image/pjpeg" AND $avatar_Mime_Type != "image/png" AND $avatar_Mime_Type != "image/x-png") { unlink($avatar_Temp); die("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Please select an image that is 50KB or less in size and its type is .jpg, .gif, or .png</font></p><p align='center'><a href='avatar_upload.php'>BACK</a></p>"); } $uploadFile = "avatars/".$avatar_Name ; if (!is_dir(dirname($uploadFile))) { @RecursiveMkdir(dirname($uploadFile)); } else { @chmod(dirname($uploadFile), 0777); } @move_uploaded_file( $avatar_Temp , $uploadFile); chmod($uploadFile, 0644); $avatar_URL = "*************/".$avatar_Name ; //saving record to MySQL database @$ava_strQuery = "UPDATE $member_table SET avatar ='$avatar_Name' WHERE authid='$steamid' AND private_pin='$pin'"; @$ava_host = "$hostname"; @$ava_user = "$username"; @$ava_pw = "$password"; @$ava_db = "$database"; $ava_link = mysql_connect($ava_host, $ava_user, $ava_pw); if (!$ava_link) { die('Could not connect: ' . mysql_error()); } $ava_db_selected = mysql_select_db($ava_db, $ava_link); if (!$ava_db_selected) { die ('Can not use $ava_db : ' . mysql_error()); } //insert new record $ava_result = mysql_query($ava_strQuery); if (!$ava_result) { die('Invalid query: ' . mysql_error()); } mysql_close($ava_link); echo("<p align='center'><font face='Arial' size='3' color='#66CCFF'>Image uploaded OK!</font></p><p align='center'></p>"); echo "<div align='center'>"; echo "<p><img src=$avatar_URL></p>"; include ('./includes/avatar_upload.php'); echo "</div>"; }else{ //if ID and PIN dont match display error and form echo "Wrong SteamID/Pin Please Try Again..."; echo "<br />"; include ('./includes/avatar_upload.php'); } mysql_close($ava_link1); ?> So I have the following and for some reason or another it's not wanting to work with me. If I do the query directly in phpmyadmin it will return the number, however for some reason when I throw it into a variable it won't return anything. I have a feeling it's because of the text string? How do you properly represent a string of text that has a space between it? 1st query get's the name from another table: $query = "SELECT name FROM info WHERE userdid = 4"; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); $tname = $row['name']; Table: testing rows: number name data: 4 Testing This $query1 = "SELECT number FROM testing WHERE name = '" . $tname . "'"; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_query($data1); $numreturn = $row1['number']; // Do stuff |