bokivaol Posted September 22, 2010 Share Posted September 22, 2010 Hi guys! I need a little help in PHP. I need to put into the PHP code functions which will insert to mysql database "jobs" STATUS=2 for Pause button and STATUS=1 for Run button PHP code: <?php include("include/header.php"); if(!isset($_SESSION["userlogin"])) { header("location: login.php"); exit(); } $edit=dbFetchArray(dbQuery("select * from `user_registration` where `email`='".$_SESSION["userlogin"]."'"),MYSQL_BOTH); $Id=base64_decode($_REQUEST['Id']); $up=mysql_fetch_array(mysql_query("select * from `jobs` where `id`='".$Id."'")); $status=stripslashes($up["highlighted"]); $name=stripslashes($up["title"]); $explode=explode(" ",$name); $tit=isset($explode[0])?$explode[0]:''; $col=isset($explode[1])?$explode[1]:''; $cat=isset($explode[2])?$explode[2]:''; $user=mysql_fetch_array(mysql_query("select * from `user_registration` where `email`='".$_SESSION["userlogin"]."'")); $fullname=stripslashes($user['fullname']); $customer_id=$user['id']; $current_balence=$user['current_balance']; if(isset($_POST["Button"])) { if(isset($_REQUEST["Available_positions"])) { $Available_positions=$_POST["Available_positions"]; if(strpos($Available_positions,'.')===false) { $pos=$Available_positions; $pos1=0; } else { $pieces = explode(".", $Available_positions); $pos=$pieces[0]; $pos1=$pieces[1]; } $Payment_per_task=$_POST["Payment_per_task"]; $hid=$_REQUEST['hid']; if($pos1>0) { ?> <script> alert('Job Posting Suspended'); window.location.href="edit_job.php?Id=<?=base64_decode($hid)?>"; </script> <? } else { dbQuery("update `jobs` set `wd2`='".$Available_positions."',`price`='".$Payment_per_task."' where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'"); ?> <script> window.location.href="employer.php"; </script> <? } } $_SESSION['hid']=$hid; if($hid>0) { $_SESSION["success"]=''; } else { $_SESSION["error"]=''; } } else if(isset($_POST["Cancel"])) { $hid=$_REQUEST['hid']; dbQuery("update `jobs` set `status`='3' where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'"); $resJ=dbFetchArray(dbQuery("select * from `jobs` where `id`='".$hid."' and `email`='".$_SESSION["userlogin"]."'"),MYSQL_BOTH); if($resJ["wd1"]!=$resJ["wd2"]) { $CJ= $resJ["wd2"] - $resJ["wd1"]; $CJFees = $CJ*$resJ["price"]; dbQuery("insert into `myaccount`(`email`,`amount`,`type`,`createdate`,`jobid`) values('".$_SESSION['userlogin']."','$CJFees','10',NOW(),'".$resJ["id"]."')"); $rescurbal=dbFetchArray(dbQuery("select * from `user_registration` where `email`='".$_SESSION['userlogin']."'"),MYSQL_BOTH); dbQuery("update `user_registration` set `current_balance`='".($rescurbal["current_balance"]+$CJFees)."' where `email`='".$_SESSION['userlogin']."'"); } ?> <script> window.location.href="employer.php"; </script> <? } ?> ... and the buttons code: ... <br><input type="submit" value="Submit Campaign" <?php if($up["status"]=='3') { echo 'disabled="disabled"';} ?> name="Button"> <input type="submit" value="Finished Campaign" <?php if($up["status"]=='3') { echo 'disabled="disabled"';} ?> name="Cancel"><br /> ... I tried to do that, but I always get some error . Please help! Link to comment https://forums.phpfreaks.com/topic/214065-pause-and-run-button-in-php-script-help/ Share on other sites More sharing options...
btherl Posted September 22, 2010 Share Posted September 22, 2010 What error do you get? The first step is to check for errors in EVERY call to mysql_query(). If any mysql_query() returns false your script needs to stop right there and report the problem. Link to comment https://forums.phpfreaks.com/topic/214065-pause-and-run-button-in-php-script-help/#findComment-1113985 Share on other sites More sharing options...
bokivaol Posted September 22, 2010 Author Share Posted September 22, 2010 Every time I got an error which is not connected with mysql database, but with added PHP code in the script above. Last error was "unexpected end". I know that most time it is because of "}", but I could not find that any } missing or is sinker. This script is OK, but when I add some code in it, it is always wrong. I need someone to add functions in the script which will insert to mysql database "jobs" STATUS=2 for Pause button and STATUS=1 for Run button . I lost my nerves :'(. I know that it is easy for someone, but for me ... Link to comment https://forums.phpfreaks.com/topic/214065-pause-and-run-button-in-php-script-help/#findComment-1114007 Share on other sites More sharing options...
btherl Posted September 22, 2010 Share Posted September 22, 2010 A good way to find missing "}" is to indent your code like this: if ($a == 1) { while ($row = mysql_fetch_row($res)) { print $row['val']; } } By indenting whenever you have a "{" and reducing indent when you have a "}", it is obvious when one is missing. If you want someone else to do the code for you then you should try the freelancing section of the forum. In this section we will help you to learn to do the code yourself. Link to comment https://forums.phpfreaks.com/topic/214065-pause-and-run-button-in-php-script-help/#findComment-1114275 Share on other sites More sharing options...
bokivaol Posted September 22, 2010 Author Share Posted September 22, 2010 Thank you. I will check in PHP Freelancing section. Link to comment https://forums.phpfreaks.com/topic/214065-pause-and-run-button-in-php-script-help/#findComment-1114279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.