dsunj08246 2015-06-05 11:04
浏览 36

mysql插入脚本适用于localhost,但不能在服务器上运行?

I am using the following code which all works fine on my localhost and produces no errors except when I run the file from my server it does not insert the values into my table. I am not getting any errors.

Please can someone show me where I am going wrong? Thanks in advance.

code:

<?php
session_start(); 
$reference=$_GET['reference']; 
include '../../include/config.php';
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
$sql = "UPDATE new_supplier_request
        SET action_taken='actioned', status = 'Actioned', process_description = 'Supplier Contacted' WHERE reference = '$reference'";

mysql_select_db('hewden1');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not update data: ' . mysql_error());
}


$first = "SELECT * FROM new_supplier_request WHERE reference = '$reference'"; 
$result = mysql_query($first);
while($row = mysql_fetch_assoc($result)) {
$user1 = substr($row['contact_second_name'], 0, 5) . '';
$user2 = substr($row['contact_first_name'], 0, 1) . '';
$digits = 2;
$num = rand(pow(10, $digits-1), pow(10, $digits)-1);


$digits2 = 8;
$ref = rand(pow(10, $digits2-1), pow(10, $digits2)-1);

$user = $user1.$user2.$num;


$comp_name = $row['company_name'];
$first_name = $row['contact_first_name'];
$second_name = $row['contact_second_name'];
$email = $row['contact_email'];
}

include '../../dependables/secure.php';  

$query = "INSERT INTO supplier_users(user_id, user_name, company_name, user_first_name, user_last_name, user_email, user_password_hash, salt, account_created)
VALUES ('".$ref."','".$user."','".$comp_name."','".$first_name."','".$second_name."','".$email."','".$hash."','".$salt."',now())";
$result1 = mysql_query($query, $conn);

$query2 = "INSERT INTO supplier_stats(user_id, user_name, company_name, user_first_name, user_last_name, user_email)  SELECT user_id, user_name, company_name, user_first_name, user_last_name, user_email FROM supplier_users WHERE user_id = '$ref' ";
$result2 = mysql_query($query2, $conn);


include '../send_emails/send_email1.php';
mysql_close($conn);


if($result2) {

    $_SESSION['success'] = '<div id="bottom_notification"><div id="bottom_notification_heading"><h23>Request Received Successfully!</h23><div class="boxclose" id="boxclose">&#10006;</div></div><p>Thank you, the request was actioned successfully. Your reference is: '.$reference.'.</p><p><a href="track_request.php">Track this request.</a>.</div>';
    $_SESSION['message2'] = '<div class="message_box_prompt"><div class="boxclose2" id="boxclose2" style="float:right; margin:10px; cursor:pointer; cursor:hand;" onclick="this.parentNode.parentNode.removeChild(this.parentNode);">&#10006;</div><div class="message_box_text"><strong>Success!</strong> Your request was actioned successfully. Your reference is: '.$reference.'.</div></div>';
    header('Location: ' . $_SERVER['HTTP_REFERER']);

    }else{


    $_SESSION['success'] = '<div id="bottom_notification"><div id="bottom_notification_heading"><h23>There was a problem!</h23><div class="boxclose" id="boxclose">&#10006;</div></div><p>We had difficulty processing your request.</p><p><a href="track_request.php">Track this request.</a>.</div>';
    $_SESSION['message2'] = '<div class="message_box_prompt"><div class="boxclose2" id="boxclose2" style="float:right; margin:10px; cursor:pointer; cursor:hand;" onclick="this.parentNode.parentNode.removeChild(this.parentNode);">&#10006;</div><div class="message_box_text"><strong>Oooops!</strong> There was a problem processing your request.</div></div>';
    header('Location: ' . $_SERVER['HTTP_REFERER']);

    }

?> 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c